OS-independent wrapper for shlex and mslex
Low maintenance activity. Last release 7 months ago, commits in 0 of the last 26 weeks. Weaker on commit activity and release cadence.
pip install oslexoslex
oslex is an OS-independent wrapper for shlex and mslex.
Its main purpose is to provide functions similar in functionality to shlex.quote(), shlex.split() and shlex.join() on both Windows and POSIX-compatible platforms.
This goal is achieved by simply forwarding the calls to either shlex (from the standard library) on POSIX-compatible systems, or the excellent mslex library (written by Lawrence D'Anna / @smoofra) on Windows.
In other words, oslex is to shlex/mslex what os.path is to posixpath/ntpath.
Reference
The three main interface functions are oslex.join(), oslex.quote() and oslex.split().
They all support taking a single positional argument, and a variety of optional keyword arguments. Keyword arguments starting with ms_ are passed to the underlying mslex function on Windows, and are ignored on non-Windows platforms. Keyword arguments starting with sh_ are passed to the underlying shlex function on non-Windows platforms, and are ignored on Windows. The default values of keyword arguments are the same as for the underlying libraries.
In addition, each function has two extra variants: one with the suffix _sh, and one with the suffix _ms. They have the exact same interface as the main variants, except they always call the shlex or mslex library functions instead of deciding based on platform. They can be useful in situations when a specific implementation is needed regardless of platform, but support for Path arguments is desirable.
oslex.join()
Quote arguments according to platform-specific rules, then join them to form a full command line. Returns str.
Calls mslex.join() on Windows, and shlex.join() on non-Windows platforms.
Arguments:
| Name | Type | Default | Kind | Description |
|---|---|---|---|---|