Giter Site home page Giter Site logo

winshlex's Introduction

Winshlex

Alternative to shlex for easy split of windows path. Inspired by a stack overflow post.

Python package for multi-platform variant of shlex.split() for command-line splitting. For use with subprocess, for argv injection etc. Using fast REGEX.

Build with: Python 3.7.2

Installation

In your terminal execute

pip install winshlex

Usage

On windows with shlex

>>> import shlex 

>>> to_split = "C:\Users\samsung\Desktop\Dev2\package-winshlex"

>>> shlex.split()

>>> ['C:UserssamsungDesktopDev2package-winshlex']

On windows with winshlex

>>> import winshlex 

>>> to_split = "C:\Users\samsung\Desktop\Dev2\package-winshlex"

>>> winshlex.split()

>>> ['C:\\Users\\samsung\\Desktop\\Dev2\\package-winshlex']

winshlex's People

Contributors

jdjebi avatar mbwihahos avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Forkers

everclear72216

winshlex's Issues

Same issue as with `shlex`

I like the general idea, but the one reason I was looking for a package like yours isn't covered: winshlex also fails to deal with UNC paths, just like shlex (which works reasonable well otherwise on Windows in its current form).

For example:

from winshlex import split

print(split(r'copy "\\server\path with space\some.file" -o"\\other_server\path"'))

Result:

['copy', '\\server\\path with space\\some.file', '-o\\other_server\\path']

Note how the double backslashes before servers have been removed, just like shlex does, while Windows requires them there. On the other hand, using double forward slashes on POSIX platforms works just fine with shlex, so they're not quite equivalent.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.