preparse 1.0.14.dev2__tar.gz → 1.0.15__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.
Files changed (44) hide show
  1. preparse-1.0.15/PKG-INFO +38 -0
  2. preparse-1.0.15/README.rst +7 -0
  3. {preparse-1.0.14.dev2 → preparse-1.0.15}/pyproject.toml +6 -6
  4. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/_processing/digesting.py +22 -1
  5. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/_processing/parsing.py +8 -28
  6. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/tests/test_data_toml.py +2 -16
  7. preparse-1.0.15/src/preparse.egg-info/PKG-INFO +38 -0
  8. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse.egg-info/SOURCES.txt +0 -2
  9. preparse-1.0.14.dev2/PKG-INFO +0 -57
  10. preparse-1.0.14.dev2/README.rst +0 -5
  11. preparse-1.0.14.dev2/docs/v1.0.rst +0 -303
  12. preparse-1.0.14.dev2/src/preparse.egg-info/PKG-INFO +0 -57
  13. {preparse-1.0.14.dev2 → preparse-1.0.15}/LICENSE.txt +0 -0
  14. {preparse-1.0.14.dev2 → preparse-1.0.15}/MANIFEST.in +0 -0
  15. {preparse-1.0.14.dev2 → preparse-1.0.15}/setup.cfg +0 -0
  16. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/__init__.py +0 -0
  17. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/_items/Bundle.py +0 -0
  18. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/_items/Item.py +0 -0
  19. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/_items/Long.py +0 -0
  20. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/_items/Option.py +0 -0
  21. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/_items/Positional.py +0 -0
  22. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/_items/Special.py +0 -0
  23. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/_items/__init__.py +0 -0
  24. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/_processing/__init__.py +1 -1
  25. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/_processing/deparsing.py +0 -0
  26. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/_processing/pulling.py +0 -0
  27. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/_utils/__init__.py +0 -0
  28. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/_utils/dataprop.py +0 -0
  29. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/core/Click.py +0 -0
  30. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/core/Optdict.py +0 -0
  31. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/core/PreParser.py +0 -0
  32. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/core/__init__.py +0 -0
  33. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/core/enums.py +0 -0
  34. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/core/warnings.py +0 -0
  35. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/tests/__init__.py +0 -0
  36. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/tests/data.toml +0 -0
  37. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/tests/expit.toml +0 -0
  38. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/tests/test_enums.py +0 -0
  39. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/tests/test_expit_toml.py +0 -0
  40. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/tests/test_optdict.py +0 -0
  41. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse/tests/test_preparser.py +0 -0
  42. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse.egg-info/dependency_links.txt +0 -0
  43. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse.egg-info/requires.txt +0 -0
  44. {preparse-1.0.14.dev2 → preparse-1.0.15}/src/preparse.egg-info/top_level.txt +0 -0
@@ -0,0 +1,38 @@
1
+ Metadata-Version: 2.4
2
+ Name: preparse
3
+ Version: 1.0.15
4
+ Summary: This project preparses args for further parsing later on.
5
+ Author-email: Johannes <johannes.programming@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Download, https://pypi.org/project/preparse/#files
8
+ Project-URL: Index, https://pypi.org/project/preparse/
9
+ Project-URL: Source, https://github.com/johannes-programming/preparse/
10
+ Project-URL: Website, https://preparse.johannes-programming.online/
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Natural Language :: English
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Typing :: Typed
18
+ Requires-Python: >=3.11
19
+ Description-Content-Type: text/x-rst
20
+ License-File: LICENSE.txt
21
+ Requires-Dist: click<9,>=8.2
22
+ Requires-Dist: cmp3<2,>=1.0
23
+ Requires-Dist: copyable<2,>=1.0
24
+ Requires-Dist: datahold<4,>=3.0
25
+ Requires-Dist: datarepr<2,>=1.1
26
+ Requires-Dist: frozendict<3,>=2.4.7
27
+ Requires-Dist: overloadable<2,>=1.1
28
+ Requires-Dist: setdoc<2,>=1.2.10
29
+ Requires-Dist: tofunc<2,>=1.0
30
+ Dynamic: license-file
31
+
32
+ ========
33
+ preparse
34
+ ========
35
+
36
+ Each minor version has its own documentation.
37
+ These docs can be found as rst-files in the ``docs/`` directory of this project.
38
+ They can also be viewed on the website `https://preparse.johannes-programming.online/ <https://preparse.johannes-programming.online/>`_.
@@ -0,0 +1,7 @@
1
+ ========
2
+ preparse
3
+ ========
4
+
5
+ Each minor version has its own documentation.
6
+ These docs can be found as rst-files in the ``docs/`` directory of this project.
7
+ They can also be viewed on the website `https://preparse.johannes-programming.online/ <https://preparse.johannes-programming.online/>`_.
@@ -9,8 +9,7 @@ authors = [
9
9
  { email = "johannes.programming@gmail.com", name = "Johannes" },
10
10
  ]
11
11
  classifiers = [
12
- "Development Status :: 3 - Alpha",
13
- "License :: OSI Approved :: MIT License",
12
+ "Development Status :: 5 - Production/Stable",
14
13
  "Natural Language :: English",
15
14
  "Operating System :: OS Independent",
16
15
  "Programming Language :: Python",
@@ -31,13 +30,14 @@ dependencies = [
31
30
  ]
32
31
  description = "This project preparses args for further parsing later on."
33
32
  keywords = []
33
+ license = "MIT"
34
+ license-files = [
35
+ "LICENSE.txt",
36
+ ]
34
37
  name = "preparse"
35
38
  readme = "README.rst"
36
39
  requires-python = ">=3.11"
37
- version = "1.0.14.dev2"
38
-
39
- [project.license]
40
- file = "LICENSE.txt"
40
+ version = "1.0.15"
41
41
 
42
42
  [project.urls]
43
43
  Download = "https://pypi.org/project/preparse/#files"
@@ -2,6 +2,7 @@ from typing import *
2
2
 
3
3
  from preparse._items.Bundle import Bundle
4
4
  from preparse._items.Item import Item
5
+ from preparse._items.Long import Long
5
6
  from preparse._items.Option import Option
6
7
  from preparse._items.Positional import Positional
7
8
  from preparse._items.Special import Special
@@ -16,13 +17,17 @@ def digest(
16
17
  *,
17
18
  allowslong: bool,
18
19
  bundling: Tuning,
20
+ expandsabbr: bool,
19
21
  expectsposix: bool,
20
22
  reconcilesorders: bool,
21
23
  special: Tuning,
22
24
  ) -> list[Item]:
23
25
  ans: list[Item]
24
26
  ans = list(items)
25
-
27
+ ans = digest_abbr(
28
+ ans,
29
+ expandsabbr=expandsabbr,
30
+ )
26
31
  ans = digest_special(
27
32
  ans,
28
33
  expectsposix=expectsposix,
@@ -42,6 +47,22 @@ def digest(
42
47
  return ans
43
48
 
44
49
 
50
+ def digest_abbr(
51
+ items: list[Item],
52
+ *,
53
+ expandsabbr: bool,
54
+ ) -> list[Item]:
55
+ ans: list[Item]
56
+ item: Item
57
+ ans = list(items)
58
+ if not expandsabbr:
59
+ return ans
60
+ for item in ans:
61
+ if isinstance(item, Long):
62
+ item.abbrlen = None
63
+ return ans
64
+
65
+
45
66
  def digest_bundling(
46
67
  items: list[Item],
47
68
  *,
@@ -18,26 +18,8 @@ PUAW = warnings.PreparseUnallowedArgumentWarning
18
18
  PRAW = warnings.PreparseRequiredArgumentWarning
19
19
 
20
20
 
21
- def parse(
22
- args: list[str],
23
- expandsabbr: bool,
24
- expectsabbr: bool,
25
- **kwargs: Any,
26
- ) -> list[Item]:
27
- abbr: Optional[Tuning]
28
- if not expectsabbr:
29
- abbr = None
30
- elif expandsabbr:
31
- abbr = Tuning.MINIMIZE
32
- else:
33
- abbr = Tuning.MAINTAIN
34
- return list(
35
- parse_generator(
36
- args,
37
- abbr=abbr,
38
- **kwargs,
39
- )
40
- )
21
+ def parse(args: list[str], **kwargs: Any) -> list[Item]:
22
+ return list(parse_generator(args, **kwargs))
41
23
 
42
24
 
43
25
  def parse_bundling(
@@ -82,9 +64,9 @@ def parse_cause(
82
64
  def parse_generator(
83
65
  items: list[Positional],
84
66
  *,
85
- abbr: Optional[Tuning],
86
67
  allowslong: bool,
87
68
  allowsshort: bool,
69
+ expectsabbr: bool,
88
70
  expectsposix: bool,
89
71
  optdict: dict,
90
72
  prog: str,
@@ -120,10 +102,10 @@ def parse_generator(
120
102
  continue
121
103
  last = parse_option(
122
104
  item.value,
123
- abbr=abbr,
124
105
  allowslong=allowslong,
125
106
  allowsshort=allowsshort,
126
107
  cause=cause,
108
+ expectsabbr=expectsabbr,
127
109
  optdict=optdict,
128
110
  )
129
111
  if not last.ishungry():
@@ -154,8 +136,8 @@ def parse_islong(
154
136
  def parse_long(
155
137
  arg: str,
156
138
  *,
157
- abbr: Optional[Tuning],
158
139
  cause: FunctionType,
140
+ expectsabbr: bool,
159
141
  optdict: dict,
160
142
  ) -> Long:
161
143
  ans: Long
@@ -168,7 +150,7 @@ def parse_long(
168
150
  ans.abbrlen = len(ans.fullkey)
169
151
  if ans.fullkey in optdict.keys():
170
152
  parts = [ans.fullkey]
171
- elif abbr is not None:
153
+ elif expectsabbr:
172
154
  parts = parse_long_startswith(ans.abbr, keys=optdict.keys())
173
155
  else:
174
156
  parts = list() # can be assumed
@@ -181,8 +163,6 @@ def parse_long(
181
163
  cause(PAOW, option=arg, possibilities=parts)
182
164
  return ans
183
165
  (ans.fullkey,) = parts
184
- if abbr == Tuning.MINIMIZE:
185
- ans.abbrlen = len(ans.fullkey)
186
166
  ans.nargs = optdict[ans.fullkey]
187
167
  if (ans.nargs == Nargs.NO_ARGUMENT) and (ans.right is not None):
188
168
  cause(PUAW, option=ans.fullkey)
@@ -206,16 +186,16 @@ def parse_long_startswith(
206
186
  def parse_option(
207
187
  arg: str,
208
188
  *,
209
- abbr: Optional[Tuning],
210
189
  cause: FunctionType,
190
+ expectsabbr: bool,
211
191
  optdict: dict,
212
192
  **kwargs: Any,
213
193
  ) -> Option:
214
194
  if parse_islong(arg, **kwargs):
215
195
  return parse_long(
216
196
  arg,
217
- abbr=abbr,
218
197
  cause=cause,
198
+ expectsabbr=expectsabbr,
219
199
  optdict=optdict,
220
200
  )
221
201
  else:
@@ -31,24 +31,10 @@ class TestDataToml(unittest.TestCase):
31
31
  data: dict[str, Any]
32
32
  name: str
33
33
  kwargs: dict
34
- kwargs_: dict
35
34
  data = utils.get_data()
36
35
  for name, kwargs in data.items():
37
36
  with self.subTest(msg=name, **kwargs):
38
- kwargs_ = self.convert(**kwargs)
39
- self.parse(**kwargs_)
40
-
41
- def convert(self: Self, **kwargs: Any) -> dict:
42
- ans: dict
43
- x: str
44
- y: Any
45
- ans = dict()
46
- for x, y in kwargs.items():
47
- if utils.istestable(y):
48
- ans[x] = y
49
- else:
50
- ans[x] = None
51
- return ans
37
+ self.parse(**kwargs)
52
38
 
53
39
  def parse(
54
40
  self: Self,
@@ -88,7 +74,7 @@ class TestDataToml(unittest.TestCase):
88
74
  self.assertEqual(answer, superanswer, msg=msg)
89
75
  msg = "\n\ndata=%s,\nanswer=%s,\nsolution=%s,\n\n" % (data, answer, solution)
90
76
  self.assertEqual(answer, solution, msg=msg)
91
- if warnings is None:
77
+ if not utils.istestable(warnings):
92
78
  return
93
79
  msg = "\n\ndata=%s,\nerranswer=%s,\nwarnings=%s,\n\n" % (
94
80
  data,
@@ -0,0 +1,38 @@
1
+ Metadata-Version: 2.4
2
+ Name: preparse
3
+ Version: 1.0.15
4
+ Summary: This project preparses args for further parsing later on.
5
+ Author-email: Johannes <johannes.programming@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Download, https://pypi.org/project/preparse/#files
8
+ Project-URL: Index, https://pypi.org/project/preparse/
9
+ Project-URL: Source, https://github.com/johannes-programming/preparse/
10
+ Project-URL: Website, https://preparse.johannes-programming.online/
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Natural Language :: English
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Typing :: Typed
18
+ Requires-Python: >=3.11
19
+ Description-Content-Type: text/x-rst
20
+ License-File: LICENSE.txt
21
+ Requires-Dist: click<9,>=8.2
22
+ Requires-Dist: cmp3<2,>=1.0
23
+ Requires-Dist: copyable<2,>=1.0
24
+ Requires-Dist: datahold<4,>=3.0
25
+ Requires-Dist: datarepr<2,>=1.1
26
+ Requires-Dist: frozendict<3,>=2.4.7
27
+ Requires-Dist: overloadable<2,>=1.1
28
+ Requires-Dist: setdoc<2,>=1.2.10
29
+ Requires-Dist: tofunc<2,>=1.0
30
+ Dynamic: license-file
31
+
32
+ ========
33
+ preparse
34
+ ========
35
+
36
+ Each minor version has its own documentation.
37
+ These docs can be found as rst-files in the ``docs/`` directory of this project.
38
+ They can also be viewed on the website `https://preparse.johannes-programming.online/ <https://preparse.johannes-programming.online/>`_.
@@ -3,7 +3,6 @@ MANIFEST.in
3
3
  README.rst
4
4
  pyproject.toml
5
5
  setup.cfg
6
- docs/v1.0.rst
7
6
  src/preparse/__init__.py
8
7
  src/preparse.egg-info/PKG-INFO
9
8
  src/preparse.egg-info/SOURCES.txt
@@ -25,7 +24,6 @@ src/preparse/_processing/pulling.py
25
24
  src/preparse/_utils/__init__.py
26
25
  src/preparse/_utils/dataprop.py
27
26
  src/preparse/core/Click.py
28
- src/preparse/core/OptDict.py
29
27
  src/preparse/core/Optdict.py
30
28
  src/preparse/core/PreParser.py
31
29
  src/preparse/core/__init__.py
@@ -1,57 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: preparse
3
- Version: 1.0.14.dev2
4
- Summary: This project preparses args for further parsing later on.
5
- Author-email: Johannes <johannes.programming@gmail.com>
6
- License: The MIT License (MIT)
7
-
8
- Copyright (c) 2024 Johannes
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
- Project-URL: Download, https://pypi.org/project/preparse/#files
28
- Project-URL: Index, https://pypi.org/project/preparse/
29
- Project-URL: Source, https://github.com/johannes-programming/preparse/
30
- Project-URL: Website, https://preparse.johannes-programming.online/
31
- Classifier: Development Status :: 3 - Alpha
32
- Classifier: License :: OSI Approved :: MIT License
33
- Classifier: Natural Language :: English
34
- Classifier: Operating System :: OS Independent
35
- Classifier: Programming Language :: Python
36
- Classifier: Programming Language :: Python :: 3
37
- Classifier: Programming Language :: Python :: 3 :: Only
38
- Classifier: Typing :: Typed
39
- Requires-Python: >=3.11
40
- Description-Content-Type: text/x-rst
41
- License-File: LICENSE.txt
42
- Requires-Dist: click<9,>=8.2
43
- Requires-Dist: cmp3<2,>=1.0
44
- Requires-Dist: copyable<2,>=1.0
45
- Requires-Dist: datahold<4,>=3.0
46
- Requires-Dist: datarepr<2,>=1.1
47
- Requires-Dist: frozendict<3,>=2.4.7
48
- Requires-Dist: overloadable<2,>=1.1
49
- Requires-Dist: setdoc<2,>=1.2.10
50
- Requires-Dist: tofunc<2,>=1.0
51
- Dynamic: license-file
52
-
53
- ========
54
- preparse
55
- ========
56
-
57
- Visit the website `https://preparse.johannes-programming.online/ <https://preparse.johannes-programming.online/>`_ for more information.
@@ -1,5 +0,0 @@
1
- ========
2
- preparse
3
- ========
4
-
5
- Visit the website `https://preparse.johannes-programming.online/ <https://preparse.johannes-programming.online/>`_ for more information.
@@ -1,303 +0,0 @@
1
- Overview
2
- --------
3
-
4
- The preparse project allows to preparse arguments before the main parsing.
5
- Its ability to deabbreviate options is especially useful for use with ``click``.
6
-
7
- Links
8
- -----
9
-
10
- - Download: https://pypi.org/project/preparse/#files
11
- - Index: https://pypi.org/project/preparse/
12
- - Source: https://github.com/johannes-programming/preparse/
13
- - Website: https://preparse.johannes-programming.online/
14
-
15
- Installation
16
- ------------
17
-
18
- To install preparse, you can use pip. Open your terminal and run:
19
-
20
- .. code-block:: shell
21
-
22
- pip install preparse
23
-
24
- Introduction
25
- ------------
26
-
27
- The preparse project allows for preprocessing a list of arguments so that they can be parsed definitively in a later step. This way, the functionality of another parsing system can be modified. The project is especially adapted to work with the click project.
28
-
29
- The project preparse is strongly inspired by the getopt and getopt_long libraries within C.
30
-
31
- Here is the implementation of the ``expit`` project (Version 1.0.13) to illustrate how preparse can be used to modify click.
32
-
33
- .. code-block:: python
34
-
35
- import math
36
-
37
- import click
38
- import preparse
39
-
40
- __all__ = ["function", "main"]
41
-
42
-
43
- def function(x: float) -> float:
44
- "This function is the logistical sigmoid, i.e. the expit function."
45
- try:
46
- p = math.exp(-x)
47
- except OverflowError:
48
- p = float("+inf")
49
- return 1 / (1 + p)
50
-
51
-
52
- @preparse.PreParser().click()
53
- @click.command(add_help_option=False)
54
- @click.help_option("-h", "--help")
55
- @click.version_option(None, "-V", "--version")
56
- @click.argument("x", type=float)
57
- def main(x: float) -> None:
58
- "This command applies the expit function to x."
59
- click.echo(function(x))
60
-
61
- Features
62
- --------
63
-
64
- The PreParser class
65
- ~~~~~~~~~~~~~~~~~~~
66
-
67
- ``class preparse.PreParser(*, allowslong: Any = True, allowsshort: Any = True, bundling: Any = Tuning.MAINTAIN, expandsabbr: Any = True, expectsabbr: Any = True, expectsposix: Any = False, optdict: Any = (), prog: Any = None, reconcilesorders: Any = True, special: Any = preparse.Tuning.MAINTAIN, warn: Callable = str)``
68
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
69
-
70
- This class is the centerpiece of the preparse. Its behaviour follows the principles of getopt from C.
71
-
72
- ``allowslong: bool``
73
- """"""""""""""""""""
74
-
75
- This boolean property determines whether long options are allowed.
76
-
77
- ``allowsshort: bool``
78
- """""""""""""""""""""
79
-
80
- This boolean property determines whether short options are allowed.
81
-
82
- ``bundling: preparse.Tuning``
83
- """""""""""""""""""""""""""""
84
-
85
- This ``preparse.Tuning`` property determines the approach to bundling of short option.
86
-
87
- ``click(cmd: Any = True, ctx: Any = True) -> preparse.Click``
88
- """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
89
-
90
- This method returns a decorator that infuses the current instance into ``parse_args``.
91
-
92
- ``copy() -> Self``
93
- """"""""""""""""""
94
-
95
- This method returns a copy of the current instance.
96
-
97
- ``expandsabbr: bool``
98
- """""""""""""""""""""
99
-
100
- This boolean property determines whether recognized abbreviations of long options are to be expanded to their full length.
101
-
102
- ``expectsabbr: bool``
103
- """""""""""""""""""""
104
-
105
- This boolean property determines whether abbreviations of long options are expected.
106
-
107
- ``expectsposix: bool``
108
- """"""""""""""""""""""
109
-
110
- This boolean property determines whether the order of arguments to conform to the POSIX standard, i.e. all arguments after the first positional argument also being positonal.
111
-
112
- ``optdict: preparse.Optdict``
113
- """""""""""""""""""""""""""""
114
-
115
- This property holds a dict-like object.
116
- Its keys are the options.
117
- Its values specify ``preparse.Nargs``.
118
- Options not found within the dictionary
119
- cause a ``preparse.PreparseInvalidOptionWarning``
120
- and are then assumed to have no arguments.
121
-
122
- ``parse_args(args: Optional[Iterable] = None) -> list[str]``
123
- """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
124
-
125
- This method is at the core of the class.
126
- It returns a preparsed list of arguments.
127
- If ``None`` is passed as args then ``sys.argv[1:]`` is used.
128
- If the method is applied repeatedly to a list there will be no changes after the first run.
129
-
130
- ``prog: str``
131
- """""""""""""
132
-
133
- This ``str`` property represents the name of the program.
134
- If the value passed to the property is ``None`` then ``str(sys.argv[0])`` is saved.
135
-
136
- ``reconcilesorders: bool``
137
- """"""""""""""""""""""""""
138
-
139
- This boolean property determines whether compatibility with both orders,
140
- POSIX and the interleaving of options with positonal arguments, should be enforced.
141
-
142
- ``reflectClickCommand(cmd: click.Command) -> None``
143
- """""""""""""""""""""""""""""""""""""""""""""""""""
144
-
145
- This method alters the current instance to reflect a ``click.Command`` object.
146
- Concretely the optdict property is changed.
147
-
148
- ``reflectClickContext(ctx: click.Context) -> None``
149
- """""""""""""""""""""""""""""""""""""""""""""""""""
150
-
151
- This method alters the current instance to reflect a ``click.Context`` object.
152
- Concretely the prog property is changed.
153
-
154
- ``special: preparse.Tuning``
155
- """"""""""""""""""""""""""""
156
-
157
- This ``preparse.Tuning`` property determines the approach to the special argument ``'--'``.
158
-
159
- ``todict() -> dict``
160
- """"""""""""""""""""
161
-
162
- This method a dict representing the current instance.
163
-
164
- ``warn: types.FunctionType``
165
- """"""""""""""""""""""""""""
166
-
167
- This property holds a function that is called whenever ``parse_args`` encounters a warning.
168
- The warning is given as the only positional arguments.
169
- No keyword arguments are given.
170
- Its return value is discarded.
171
- Therefore, ``str`` is used to discard the warnings.
172
-
173
- The Click class
174
- ~~~~~~~~~~~~~~~
175
-
176
- ``class preparse.Click(parser: preparse.PreParser, cmd: Any = True, ctx: Any = True)``
177
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
178
-
179
- This dataclass provides decorators for embedding a ``PreParser`` object.
180
-
181
- ``__call__(target: Any) -> Any``
182
- """"""""""""""""""""""""""""""""
183
-
184
- This magic method implements ``self(target)``.
185
- It works as a decorator that embeds its parser into a given target from the library click.
186
-
187
- ``cmd: Any``
188
- """"""""""""
189
-
190
- This property determines if the ``reflectClickCommand`` method of parser is to be called.
191
-
192
- ``copy() -> Self``
193
- """"""""""""""""""
194
-
195
- ``ctx: Any``
196
- """"""""""""
197
-
198
- This property determines if the ``reflectClickContext`` method of parser is to be called.
199
-
200
- ``parser: preparse.PreParser``
201
- """"""""""""""""""""""""""""""
202
-
203
- This property holds the parser to be embedded.
204
-
205
- The Optdict class
206
- ~~~~~~~~~~~~~~~~~
207
-
208
- ``class preparse.Optdict``
209
- ^^^^^^^^^^^^^^^^^^^^^^^^^^
210
-
211
- This class is a subclass of ``datahold.HoldDict[str, preparse.Nargs]``
212
- with strings as keys and with ``preparse.Nargs`` as values.
213
- It is designed for ``preparse.PreParser.optdict``.
214
-
215
- The Enums
216
- ~~~~~~~~~
217
-
218
- These classes are subclasses of ``enum.IntEnum``.
219
- Any value different from ``0`` (meaning no) and ``1`` (meaning yes) is interpreted as ``2`` (meaning intermediate).
220
-
221
- ``class preparse.Tuning``
222
- ^^^^^^^^^^^^^^^^^^^^^^^^^
223
-
224
- +--------------+-------+-----------------------------------------------------------------------------+
225
- | Name | Value | Explanation |
226
- +==============+=======+=============================================================================+
227
- | ``MINIMIZE`` | ``0`` | The PreParser minimizes the aspect in question. |
228
- +--------------+-------+-----------------------------------------------------------------------------+
229
- | ``MAXIMIZE`` | ``1`` | The PreParser maximizes the aspect in question. |
230
- +--------------+-------+-----------------------------------------------------------------------------+
231
- | ``MAINTAIN`` | ``2`` | The PreParser does not make any unforced changes to the aspect in question. |
232
- +--------------+-------+-----------------------------------------------------------------------------+
233
-
234
- ``class preparse.Nargs``
235
- ^^^^^^^^^^^^^^^^^^^^^^^^
236
-
237
- +-------------------+-------+----------------------------------------------+
238
- | Name | Value | Explanation |
239
- +===================+=======+==============================================+
240
- | NO_ARGUMENT | ``0`` | The option does not take an argument. |
241
- +-------------------+-------+----------------------------------------------+
242
- | REQUIRED_ARGUMENT | ``1`` | The option requires an argument. |
243
- +-------------------+-------+----------------------------------------------+
244
- | OPTIONAL_ARGUMENT | ``2`` | The option may take an argument. |
245
- +-------------------+-------+----------------------------------------------+
246
-
247
- The Warnings
248
- ~~~~~~~~~~~~
249
-
250
- These classes are subclasses of ``Warning`` that are specifically designed to communicate issues with parsing.
251
-
252
- ``class preparse.PreparseWarning``
253
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
254
-
255
- This abstract base class is the base for all other warning types.
256
-
257
- ``class preparse.PreparseAmbiguousOptionWarning(prog: Any, option: Any, possibilities: Any)``
258
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
259
-
260
- This class warns about ambiguous options. This can only happen for long options.
261
-
262
- ``class preparse.PreparseInvalidOptionWarning(prog: Any, option: Any, islong: Any)``
263
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
264
-
265
- This class warns about invalid options.
266
-
267
- ``class preparse.PreparseRequiredArgumentWarning(prog: Any, option: Any, islong: Any)``
268
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
269
-
270
- This class warns about missing required arguments.
271
-
272
- ``class preparse.PreparseUnallowedArgumentWarning(prog: Any, option: Any)``
273
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
274
-
275
- This class warns about unallowed arguments. This can only happen for long options.
276
-
277
- The Tests
278
- ~~~~~~~~~
279
-
280
- ``preparse.test() -> unittest.TextTestResult``
281
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
282
-
283
- This project can be tested through its test function.
284
-
285
- .. code-block:: python
286
-
287
- import preparse
288
- preparse.test()
289
-
290
- License
291
- -------
292
-
293
- This project is licensed under the MIT License.
294
-
295
- Impressum
296
- ---------
297
-
298
- **Johannes Programming**
299
-
300
- - Name: Johannes
301
- - Email: johannes.programming@gmail.com
302
- - Homepage: https://www.johannes-programming.online/
303
- - Gravatar: https://www.johannes-programming.fyi/
@@ -1,57 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: preparse
3
- Version: 1.0.14.dev2
4
- Summary: This project preparses args for further parsing later on.
5
- Author-email: Johannes <johannes.programming@gmail.com>
6
- License: The MIT License (MIT)
7
-
8
- Copyright (c) 2024 Johannes
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
- Project-URL: Download, https://pypi.org/project/preparse/#files
28
- Project-URL: Index, https://pypi.org/project/preparse/
29
- Project-URL: Source, https://github.com/johannes-programming/preparse/
30
- Project-URL: Website, https://preparse.johannes-programming.online/
31
- Classifier: Development Status :: 3 - Alpha
32
- Classifier: License :: OSI Approved :: MIT License
33
- Classifier: Natural Language :: English
34
- Classifier: Operating System :: OS Independent
35
- Classifier: Programming Language :: Python
36
- Classifier: Programming Language :: Python :: 3
37
- Classifier: Programming Language :: Python :: 3 :: Only
38
- Classifier: Typing :: Typed
39
- Requires-Python: >=3.11
40
- Description-Content-Type: text/x-rst
41
- License-File: LICENSE.txt
42
- Requires-Dist: click<9,>=8.2
43
- Requires-Dist: cmp3<2,>=1.0
44
- Requires-Dist: copyable<2,>=1.0
45
- Requires-Dist: datahold<4,>=3.0
46
- Requires-Dist: datarepr<2,>=1.1
47
- Requires-Dist: frozendict<3,>=2.4.7
48
- Requires-Dist: overloadable<2,>=1.1
49
- Requires-Dist: setdoc<2,>=1.2.10
50
- Requires-Dist: tofunc<2,>=1.0
51
- Dynamic: license-file
52
-
53
- ========
54
- preparse
55
- ========
56
-
57
- Visit the website `https://preparse.johannes-programming.online/ <https://preparse.johannes-programming.online/>`_ for more information.
File without changes
File without changes
File without changes
@@ -34,7 +34,6 @@ def process(
34
34
  items,
35
35
  allowslong=allowslong,
36
36
  allowsshort=allowsshort,
37
- expandsabbr=expandsabbr,
38
37
  expectsabbr=expectsabbr,
39
38
  expectsposix=expectsposix,
40
39
  optdict=optdict,
@@ -45,6 +44,7 @@ def process(
45
44
  items,
46
45
  allowslong=allowslong,
47
46
  bundling=bundling,
47
+ expandsabbr=expandsabbr,
48
48
  expectsposix=expectsposix,
49
49
  reconcilesorders=reconcilesorders,
50
50
  special=special,