oslex2 0.1.5__tar.gz → 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,55 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: ["**"]
6
+ paths:
7
+ - "oslex2/**"
8
+ - "tests/**"
9
+ pull_request:
10
+ branches: ["**"]
11
+ paths:
12
+ - "oslex2/**"
13
+ - "tests/**"
14
+ workflow_dispatch:
15
+
16
+ jobs:
17
+ test:
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ - name: Set up Python
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: "3.11"
25
+ - name: Install uv
26
+ run: pip install uv
27
+ - name: Create virtual environment
28
+ run: uv venv .venv
29
+ - name: Install dependencies
30
+ run: . .venv/bin/activate && uv pip install -r requirements.txt || uv pip install pytest
31
+ - name: Run tests
32
+ run: . .venv/bin/activate && uv run pytest
33
+
34
+ build:
35
+ needs: test
36
+ runs-on: ubuntu-latest
37
+ steps:
38
+ - uses: actions/checkout@v4
39
+ - name: Set up Python
40
+ uses: actions/setup-python@v5
41
+ with:
42
+ python-version: "3.11"
43
+ - name: Install uv
44
+ run: pip install uv
45
+ - name: Create virtual environment
46
+ run: uv venv .venv
47
+ - name: Install build tools
48
+ run: . .venv/bin/activate && uv pip install build
49
+ - name: Build package
50
+ run: . .venv/bin/activate && python -m build
51
+ - name: Upload dist
52
+ uses: actions/upload-artifact@v4
53
+ with:
54
+ name: dist
55
+ path: dist/
@@ -0,0 +1,43 @@
1
+ name: PyPI
2
+
3
+ on:
4
+ release:
5
+ types:
6
+ - created
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ publish_to_pypi:
11
+ runs-on: ubuntu-latest
12
+
13
+ environment:
14
+ name: pypi
15
+ url: https://pypi.org/p/oslex/
16
+
17
+ permissions:
18
+ id-token: write
19
+
20
+ steps:
21
+ - name: Checkout code
22
+ uses: actions/checkout@v4
23
+
24
+ - name: Set up Python
25
+ uses: actions/setup-python@v5
26
+ with:
27
+ python-version: "3.11"
28
+
29
+
30
+ - name: Install uv
31
+ run: pip install uv
32
+
33
+ - name: Create virtual environment
34
+ run: uv venv .venv
35
+
36
+ - name: Install build tools
37
+ run: . .venv/bin/activate && uv pip install build twine
38
+
39
+ - name: Build the package
40
+ run: . .venv/bin/activate && python -m build
41
+
42
+ - name: Publish to PyPI
43
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -1,160 +1,162 @@
1
- # Byte-compiled / optimized / DLL files
2
- __pycache__/
3
- *.py[cod]
4
- *$py.class
5
-
6
- # C extensions
7
- *.so
8
-
9
- # Distribution / packaging
10
- .Python
11
- build/
12
- develop-eggs/
13
- dist/
14
- downloads/
15
- eggs/
16
- .eggs/
17
- lib/
18
- lib64/
19
- parts/
20
- sdist/
21
- var/
22
- wheels/
23
- share/python-wheels/
24
- *.egg-info/
25
- .installed.cfg
26
- *.egg
27
- MANIFEST
28
-
29
- # PyInstaller
30
- # Usually these files are written by a python script from a template
31
- # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
- *.manifest
33
- *.spec
34
-
35
- # Installer logs
36
- pip-log.txt
37
- pip-delete-this-directory.txt
38
-
39
- # Unit test / coverage reports
40
- htmlcov/
41
- .tox/
42
- .nox/
43
- .coverage
44
- .coverage.*
45
- .cache
46
- nosetests.xml
47
- coverage.xml
48
- *.cover
49
- *.py,cover
50
- .hypothesis/
51
- .pytest_cache/
52
- cover/
53
-
54
- # Translations
55
- *.mo
56
- *.pot
57
-
58
- # Django stuff:
59
- *.log
60
- local_settings.py
61
- db.sqlite3
62
- db.sqlite3-journal
63
-
64
- # Flask stuff:
65
- instance/
66
- .webassets-cache
67
-
68
- # Scrapy stuff:
69
- .scrapy
70
-
71
- # Sphinx documentation
72
- docs/_build/
73
-
74
- # PyBuilder
75
- .pybuilder/
76
- target/
77
-
78
- # Jupyter Notebook
79
- .ipynb_checkpoints
80
-
81
- # IPython
82
- profile_default/
83
- ipython_config.py
84
-
85
- # pyenv
86
- # For a library or package, you might want to ignore these files since the code is
87
- # intended to run in multiple environments; otherwise, check them in:
88
- # .python-version
89
-
90
- # pipenv
91
- # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
- # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
- # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
- # install all needed dependencies.
95
- #Pipfile.lock
96
-
97
- # poetry
98
- # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
- # This is especially recommended for binary packages to ensure reproducibility, and is more
100
- # commonly ignored for libraries.
101
- # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
- #poetry.lock
103
-
104
- # pdm
105
- # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
- #pdm.lock
107
- # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
- # in version control.
109
- # https://pdm.fming.dev/#use-with-ide
110
- .pdm.toml
111
-
112
- # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
- __pypackages__/
114
-
115
- # Celery stuff
116
- celerybeat-schedule
117
- celerybeat.pid
118
-
119
- # SageMath parsed files
120
- *.sage.py
121
-
122
- # Environments
123
- .env
124
- .venv
125
- env/
126
- venv/
127
- ENV/
128
- env.bak/
129
- venv.bak/
130
-
131
- # Spyder project settings
132
- .spyderproject
133
- .spyproject
134
-
135
- # Rope project settings
136
- .ropeproject
137
-
138
- # mkdocs documentation
139
- /site
140
-
141
- # mypy
142
- .mypy_cache/
143
- .dmypy.json
144
- dmypy.json
145
-
146
- # Pyre type checker
147
- .pyre/
148
-
149
- # pytype static type analyzer
150
- .pytype/
151
-
152
- # Cython debug symbols
153
- cython_debug/
154
-
155
- # PyCharm
156
- # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
- # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158
- # and can be added to the global gitignore or merged into this file. For a more nuclear
159
- # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
- #.idea/
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # PyCharm
156
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
159
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
+ #.idea/
161
+
162
+ .vscode/
@@ -0,0 +1,18 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.0] - 2025-09-17
9
+
10
+ ### Added
11
+
12
+ - CI runners.
13
+
14
+ ### Changed
15
+
16
+ - Improved readme.
17
+ - Improved platform detection.
18
+ - Modernized the code.
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Tamás PEREGI
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Jessie Wilson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
oslex2-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,83 @@
1
+ Metadata-Version: 2.4
2
+ Name: oslex2
3
+ Version: 1.0.0
4
+ Summary: OS-independent wrapper for shlex and mslex
5
+ Project-URL: Homepage, https://github.com/jessielw/oslex2
6
+ Project-URL: Bug Tracker, https://github.com/jessielw/oslex2/issues
7
+ Author-email: Jessie Wilson <jessielw4049@gmail.com>
8
+ License-File: LICENSE
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: MacOS
11
+ Classifier: Operating System :: Microsoft :: Windows
12
+ Classifier: Operating System :: POSIX
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.7
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Requires-Python: <3.15,>=3.7
22
+ Requires-Dist: mslex>=1.3.0
23
+ Description-Content-Type: text/markdown
24
+
25
+ # oslex2
26
+
27
+ [![CI](https://github.com/jessielw/oslex2/actions/workflows/ci.yml/badge.svg)](https://github.com/jessielw/oslex2/actions/workflows/ci.yml)
28
+ [![PyPI version](https://badge.fury.io/py/oslex2.svg)](https://badge.fury.io/py/oslex2)
29
+
30
+ **oslex2** is an OS-independent wrapper for Python's [`shlex`](https://docs.python.org/3/library/shlex.html) (POSIX) and [`mslex`](https://pypi.org/project/mslex/) (Windows) modules.
31
+
32
+ > Like `os.path` abstracts over `posixpath` and `ntpath`, `oslex2` abstracts over `shlex` and `mslex` for shell-quoting and splitting.
33
+
34
+ ## Features
35
+
36
+ - Unified API for shell quoting, splitting, and joining on all platforms
37
+ - Automatically uses `shlex` on POSIX and `mslex` on Windows
38
+ - Drop-in replacement for `shlex` in cross-platform code
39
+
40
+ ## Installation
41
+
42
+ ```sh
43
+ pip install oslex2
44
+ ```
45
+
46
+ ## Usage
47
+
48
+ ```python
49
+ import oslex2
50
+
51
+ # Safely quote a string for the shell
52
+ cmd = oslex2.quote('foo; rm -rf /')
53
+
54
+ # Split a shell command into arguments
55
+ args = oslex2.split('python -m pip install "oslex2>=1.0.0"')
56
+
57
+ # Join arguments into a shell command
58
+ command = oslex2.join(["python", "-m", "pip", "install", "oslex2>=1.0.0"])
59
+ ```
60
+
61
+ ## API
62
+
63
+ - `oslex2.quote(s: str, **kwargs) -> str`: Shell-escape a string for safe use as a single token.
64
+ - `oslex2.split(s: str, **kwargs) -> List[str]`: Split a shell command string into arguments.
65
+ - `oslex2.join(args: List[str]) -> str`: Join arguments into a shell-escaped command string.
66
+
67
+ **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.
68
+
69
+ ## Platform Detection
70
+
71
+ - On Windows, uses `mslex` for Windows shell syntax.
72
+ - On all other platforms, uses the standard library `shlex`.
73
+
74
+ ## License
75
+
76
+ - MIT License (this library)
77
+ - [`mslex`](https://pypi.org/project/mslex/) is Apache 2.0
78
+
79
+ ## Links
80
+
81
+ - [GitHub](https://github.com/jessielw/oslex2/)
82
+ - [PyPI](https://pypi.org/project/oslex2/)
83
+ - [mslex on PyPI](https://pypi.org/project/mslex/)
oslex2-1.0.0/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # oslex2
2
+
3
+ [![CI](https://github.com/jessielw/oslex2/actions/workflows/ci.yml/badge.svg)](https://github.com/jessielw/oslex2/actions/workflows/ci.yml)
4
+ [![PyPI version](https://badge.fury.io/py/oslex2.svg)](https://badge.fury.io/py/oslex2)
5
+
6
+ **oslex2** is an OS-independent wrapper for Python's [`shlex`](https://docs.python.org/3/library/shlex.html) (POSIX) and [`mslex`](https://pypi.org/project/mslex/) (Windows) modules.
7
+
8
+ > Like `os.path` abstracts over `posixpath` and `ntpath`, `oslex2` abstracts over `shlex` and `mslex` for shell-quoting and splitting.
9
+
10
+ ## Features
11
+
12
+ - Unified API for shell quoting, splitting, and joining on all platforms
13
+ - Automatically uses `shlex` on POSIX and `mslex` on Windows
14
+ - Drop-in replacement for `shlex` in cross-platform code
15
+
16
+ ## Installation
17
+
18
+ ```sh
19
+ pip install oslex2
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ```python
25
+ import oslex2
26
+
27
+ # Safely quote a string for the shell
28
+ cmd = oslex2.quote('foo; rm -rf /')
29
+
30
+ # Split a shell command into arguments
31
+ args = oslex2.split('python -m pip install "oslex2>=1.0.0"')
32
+
33
+ # Join arguments into a shell command
34
+ command = oslex2.join(["python", "-m", "pip", "install", "oslex2>=1.0.0"])
35
+ ```
36
+
37
+ ## API
38
+
39
+ - `oslex2.quote(s: str, **kwargs) -> str`: Shell-escape a string for safe use as a single token.
40
+ - `oslex2.split(s: str, **kwargs) -> List[str]`: Split a shell command string into arguments.
41
+ - `oslex2.join(args: List[str]) -> str`: Join arguments into a shell-escaped command string.
42
+
43
+ **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.
44
+
45
+ ## Platform Detection
46
+
47
+ - On Windows, uses `mslex` for Windows shell syntax.
48
+ - On all other platforms, uses the standard library `shlex`.
49
+
50
+ ## License
51
+
52
+ - MIT License (this library)
53
+ - [`mslex`](https://pypi.org/project/mslex/) is Apache 2.0
54
+
55
+ ## Links
56
+
57
+ - [GitHub](https://github.com/jessielw/oslex2/)
58
+ - [PyPI](https://pypi.org/project/oslex2/)
59
+ - [mslex on PyPI](https://pypi.org/project/mslex/)