OS-independent wrapper for shlex and mslex
Project description
oslex2
oslex2 is an OS-independent wrapper for Python's shlex (POSIX) and mslex (Windows) modules.
Like
os.pathabstracts overposixpathandntpath,oslex2abstracts overshlexandmslexfor shell-quoting and splitting.
Features
- Unified API for shell quoting, splitting, and joining on all platforms
- Automatically uses
shlexon POSIX andmslexon Windows - Drop-in replacement for
shlexin cross-platform code
Installation
pip install oslex2
Usage
import oslex2
# Safely quote a string for the shell
cmd = oslex2.quote('foo; rm -rf /')
# Split a shell command into arguments
args = oslex2.split('python -m pip install "oslex2>=1.0.0"')
# Join arguments into a shell command
command = oslex2.join(["python", "-m", "pip", "install", "oslex2>=1.0.0"])
API
oslex2.quote(s: str, **kwargs) -> str: Shell-escape a string for safe use as a single token.oslex2.split(s: str, **kwargs) -> List[str]: Split a shell command string into arguments.oslex2.join(args: List[str]) -> str: Join arguments into a shell-escaped command string.
Note: All functions accept **kwargs and pass them through to the underlying shlex or mslex implementation. This allows you to use platform-specific options (such as posix, punctuation_chars, etc.) as needed.
Platform Detection
- On Windows, uses
mslexfor Windows shell syntax. - On all other platforms, uses the standard library
shlex.
License
- MIT License (this library)
mslexis Apache 2.0
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file oslex2-1.0.0.tar.gz.
File metadata
- Download URL: oslex2-1.0.0.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f85ade0d6594e77b4388105c45de7880c7ec57ef018a6ff80088cd392bcd1876
|
|
| MD5 |
1910a9f13a2ba837757d98b1d7a77d76
|
|
| BLAKE2b-256 |
c65dfaf8eff4efea3e55ce6cc597ab777af4c9d5a5b3f21dba3224729a7e8bc1
|
Provenance
The following attestation bundles were made for oslex2-1.0.0.tar.gz:
Publisher:
pypi.yml on jessielw/oslex2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
oslex2-1.0.0.tar.gz -
Subject digest:
f85ade0d6594e77b4388105c45de7880c7ec57ef018a6ff80088cd392bcd1876 - Sigstore transparency entry: 529707885
- Sigstore integration time:
-
Permalink:
jessielw/oslex2@2d8ad647c899bc056646d3ff513cb5c5239f1070 -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/jessielw
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@2d8ad647c899bc056646d3ff513cb5c5239f1070 -
Trigger Event:
release
-
Statement type:
File details
Details for the file oslex2-1.0.0-py3-none-any.whl.
File metadata
- Download URL: oslex2-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2db57a36da65b83b482ff140f7637a02249fc324ba23189b1ed64bd7b928151
|
|
| MD5 |
7c1ceba808e0d6462ffb6ee4530018bb
|
|
| BLAKE2b-256 |
ae33671e0118ee490cd4be9e9674d94aa483dccb66ba37b8a440ca1951b4e2ef
|
Provenance
The following attestation bundles were made for oslex2-1.0.0-py3-none-any.whl:
Publisher:
pypi.yml on jessielw/oslex2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
oslex2-1.0.0-py3-none-any.whl -
Subject digest:
e2db57a36da65b83b482ff140f7637a02249fc324ba23189b1ed64bd7b928151 - Sigstore transparency entry: 529707894
- Sigstore integration time:
-
Permalink:
jessielw/oslex2@2d8ad647c899bc056646d3ff513cb5c5239f1070 -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/jessielw
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@2d8ad647c899bc056646d3ff513cb5c5239f1070 -
Trigger Event:
release
-
Statement type: