oslex2 0.1.5__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,6 @@
1
+ [*]
2
+ trim_trailing_whitespace = true
3
+ insert_final_newline = true
4
+ indent_style = "space"
5
+ indent_size = 4
6
+
@@ -0,0 +1,160 @@
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/
oslex2-0.1.5/LICENSE ADDED
@@ -0,0 +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.
oslex2-0.1.5/PKG-INFO ADDED
@@ -0,0 +1,38 @@
1
+ Metadata-Version: 2.3
2
+ Name: oslex2
3
+ Version: 0.1.5
4
+ Summary: OS-independent wrapper for shlex and mslex, meant to be temporary until original repo updates PR
5
+ Project-URL: Homepage, https://github.com/petamas/oslex
6
+ Project-URL: Bug Tracker, https://github.com/petamas/oslex/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.6
15
+ Classifier: Programming Language :: Python :: 3.7
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Requires-Python: >=3.5
21
+ Requires-Dist: mslex
22
+ Description-Content-Type: text/markdown
23
+
24
+ # oslex
25
+
26
+ `oslex` is an OS-independent wrapper for [`shlex`](https://docs.python.org/3/library/shlex.html) and [`mslex`](https://pypi.org/project/mslex/).
27
+
28
+ 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.
29
+
30
+ 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.
31
+
32
+ In other words, `oslex` is to `shlex`/`mslex` what `os-path` is to `posixpath`/`ntpath`.
33
+
34
+ ## Licensing
35
+
36
+ This library itself is licensed under the MIT license.
37
+
38
+ `oslex` uses the [`mslex`](https://pypi.org/project/mslex/) library, which is distributed under the Apache 2.0 license.
oslex2-0.1.5/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # oslex
2
+
3
+ `oslex` is an OS-independent wrapper for [`shlex`](https://docs.python.org/3/library/shlex.html) and [`mslex`](https://pypi.org/project/mslex/).
4
+
5
+ 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.
6
+
7
+ 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.
8
+
9
+ In other words, `oslex` is to `shlex`/`mslex` what `os-path` is to `posixpath`/`ntpath`.
10
+
11
+ ## Licensing
12
+
13
+ This library itself is licensed under the MIT license.
14
+
15
+ `oslex` uses the [`mslex`](https://pypi.org/project/mslex/) library, which is distributed under the Apache 2.0 license.
@@ -0,0 +1,69 @@
1
+ import sys
2
+ from typing import List
3
+
4
+
5
+ def is_posix() -> bool:
6
+ """
7
+ Returns whether the system running Python is POSIX compatible.
8
+ This is the condition for oslex.underlying being shlex.
9
+ This is also the condition for os.path being posixpath.
10
+ """
11
+ return "posix" in sys.builtin_module_names
12
+
13
+
14
+ def is_windows() -> bool:
15
+ """
16
+ Returns whether the system running Python is Windows based.
17
+ This is the condition for oslex.underlying being mslex.
18
+ This is also the condition for os.path being ntpath.
19
+ """
20
+
21
+ if is_posix():
22
+ # This early return is likely redundant, but we want to be 100% equivalent to the if-elseif structure found in os.py
23
+ # See https://github.com/python/cpython/blob/3.7/Lib/os.py
24
+ return False
25
+
26
+ return "nt" in sys.builtin_module_names
27
+
28
+
29
+ # Import OS-specific module
30
+
31
+ if is_posix():
32
+ import shlex as underlying
33
+ elif is_windows():
34
+ # mslex has no type annotations -> we have to ignore the "import" error
35
+ # also, mypy does not understand conditional importing, so it thinks we are redefining the name "underlying" -> we have to ignore the "no-redef" error
36
+ import mslex as underlying # type: ignore[import, no-redef]
37
+ else:
38
+ raise ImportError("no os specific module found")
39
+
40
+ # Define functions
41
+
42
+
43
+ def quote(s: str, **kwargs) -> str:
44
+ """
45
+ Return a shell-escaped version of the string s. The returned value is a string that can safely be used as one token in a shell command line, for cases where you cannot use a list.
46
+ This function is safe to use both for POSIX-compatible shells and for Windows's cmd.
47
+ """
48
+ return underlying.quote(s, **kwargs)
49
+
50
+
51
+ def split(s: str, **kwargs) -> List[str]:
52
+ """
53
+ Split the string s using shell-like syntax.
54
+ This function is safe to use both for POSIX-compatible shells and for Windows's cmd.
55
+ """
56
+ return underlying.split(s, **kwargs)
57
+
58
+
59
+ def join(split_command: List[str]) -> str:
60
+ """
61
+ Concatenate the tokens of the list split_command and return a string. This function is the inverse of split().
62
+ The returned value is shell-escaped to protect against injection vulnerabilities (see quote()).
63
+ This function is safe to use both for POSIX-compatible shells and for Windows's cmd.
64
+ """
65
+ # shlex only has join() since Python 3.8
66
+ # mslex doesn't have it at all
67
+ # It's easier to just implement it without trying to import the functionality
68
+ # Implementation is the same as shlex.join(), see https://github.com/python/cpython/blob/3.8/Lib/shlex.py
69
+ return " ".join(quote(arg) for arg in split_command)
File without changes
@@ -0,0 +1,33 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "oslex2"
7
+ version = "0.1.5"
8
+ authors = [
9
+ { name="Jessie Wilson", email="jessielw4049@gmail.com" },
10
+ ]
11
+ description = "OS-independent wrapper for shlex and mslex, meant to be temporary until original repo updates PR"
12
+ readme = "README.md"
13
+ requires-python = ">=3.5"
14
+ dependencies = [
15
+ "mslex",
16
+ ]
17
+ classifiers = [
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.6",
20
+ "Programming Language :: Python :: 3.7",
21
+ "Programming Language :: Python :: 3.8",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "License :: OSI Approved :: MIT License",
26
+ "Operating System :: MacOS",
27
+ "Operating System :: Microsoft :: Windows",
28
+ "Operating System :: POSIX",
29
+ ]
30
+
31
+ [project.urls]
32
+ "Homepage" = "https://github.com/petamas/oslex"
33
+ "Bug Tracker" = "https://github.com/petamas/oslex/issues"
oslex2-0.1.5/test.py ADDED
@@ -0,0 +1,6 @@
1
+ import oslex
2
+
3
+
4
+ test = oslex.split("cmd /c echo hi!")
5
+
6
+ print(test)