preparse 2.0.0.dev0__tar.gz → 2.0.0.dev2__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.
- {preparse-2.0.0.dev0/src/preparse.egg-info → preparse-2.0.0.dev2}/PKG-INFO +1 -1
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/docs/v1.0.rst +6 -6
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/pyproject.toml +1 -1
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/_items/Bundle.py +1 -1
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/_items/Item.py +1 -1
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/_items/Long.py +1 -1
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/_items/Option.py +1 -1
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/_items/Positional.py +1 -1
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/_items/Special.py +1 -1
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/_processing/__init__.py +3 -3
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/_processing/digesting.py +1 -1
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/_processing/parsing.py +13 -13
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/core/Optdict.py +3 -3
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/core/PreParser.py +18 -18
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/core/__init__.py +2 -2
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/tests/data.toml +35328 -35328
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/tests/test_enums.py +1 -1
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/tests/test_optdict.py +6 -6
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/tests/test_preparser.py +3 -3
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2/src/preparse.egg-info}/PKG-INFO +1 -1
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse.egg-info/SOURCES.txt +1 -1
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/LICENSE.txt +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/MANIFEST.in +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/README.rst +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/setup.cfg +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/__init__.py +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/_items/__init__.py +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/_processing/deparsing.py +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/_processing/pulling.py +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/_utils/__init__.py +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/_utils/dataprop.py +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/core/Click.py +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/core/PreparseWarning.py +0 -0
- /preparse-2.0.0.dev0/src/preparse/core/enums.py → /preparse-2.0.0.dev2/src/preparse/enums/__init__.py +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/tests/__init__.py +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/tests/expit.toml +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/tests/test_data_toml.py +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/tests/test_expit_toml.py +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/warners/AmbiguousOptionWarner.py +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/warners/DualWarner.py +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/warners/InvalidOptionWarner.py +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/warners/LongonlyWarner.py +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/warners/RequiredArgumentWarner.py +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/warners/UnallowedArgumentWarner.py +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/warners/WarnerABC.py +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse/warners/__init__.py +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse.egg-info/dependency_links.txt +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse.egg-info/requires.txt +0 -0
- {preparse-2.0.0.dev0 → preparse-2.0.0.dev2}/src/preparse.egg-info/top_level.txt +0 -0
|
@@ -64,7 +64,7 @@ Features
|
|
|
64
64
|
The PreParser class
|
|
65
65
|
~~~~~~~~~~~~~~~~~~~
|
|
66
66
|
|
|
67
|
-
``class preparse.PreParser(*, allowslong: Any = True, allowsshort: Any = True, bundling: Any = Tuning.MAINTAIN, expandsabbr: Any = True, expectsabbr: Any = True, expectsposix: Any = False,
|
|
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
68
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
69
69
|
|
|
70
70
|
This class is the centerpiece of the preparse. Its behaviour follows the principles of getopt from C.
|
|
@@ -109,7 +109,7 @@ This boolean property determines whether abbreviations of long options are expec
|
|
|
109
109
|
|
|
110
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
111
|
|
|
112
|
-
``
|
|
112
|
+
``optDict: preparse.OptDict``
|
|
113
113
|
"""""""""""""""""""""""""""""
|
|
114
114
|
|
|
115
115
|
This property holds a dict-like object.
|
|
@@ -143,7 +143,7 @@ POSIX and the interleaving of options with positonal arguments, should be enforc
|
|
|
143
143
|
"""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
144
144
|
|
|
145
145
|
This method alters the current instance to reflect a ``click.Command`` object.
|
|
146
|
-
Concretely the
|
|
146
|
+
Concretely the optDict property is changed.
|
|
147
147
|
|
|
148
148
|
``reflectClickContext(ctx: click.Context) -> None``
|
|
149
149
|
"""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
@@ -202,15 +202,15 @@ This property determines if the ``reflectClickContext`` method of parser is to b
|
|
|
202
202
|
|
|
203
203
|
This property holds the parser to be embedded.
|
|
204
204
|
|
|
205
|
-
The
|
|
205
|
+
The OptDict class
|
|
206
206
|
~~~~~~~~~~~~~~~~~
|
|
207
207
|
|
|
208
|
-
``class preparse.
|
|
208
|
+
``class preparse.OptDict``
|
|
209
209
|
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
210
210
|
|
|
211
211
|
This class is a subclass of ``datahold.HoldDict[str, preparse.Nargs]``
|
|
212
212
|
with strings as keys and with ``preparse.Nargs`` as values.
|
|
213
|
-
It is designed for ``preparse.PreParser.
|
|
213
|
+
It is designed for ``preparse.PreParser.optDict``.
|
|
214
214
|
|
|
215
215
|
The Enums
|
|
216
216
|
~~~~~~~~~
|
|
@@ -7,7 +7,7 @@ from preparse._processing.digesting import *
|
|
|
7
7
|
from preparse._processing.parsing import *
|
|
8
8
|
from preparse._processing.pulling import *
|
|
9
9
|
from preparse._utils import *
|
|
10
|
-
from preparse.
|
|
10
|
+
from preparse.enums import *
|
|
11
11
|
|
|
12
12
|
__all__ = ["process"]
|
|
13
13
|
|
|
@@ -21,7 +21,7 @@ def process(
|
|
|
21
21
|
expandsabbr: bool,
|
|
22
22
|
expectsabbr: bool,
|
|
23
23
|
expectsposix: bool,
|
|
24
|
-
|
|
24
|
+
optDict: dict,
|
|
25
25
|
prog: str,
|
|
26
26
|
reconcilesorders: bool,
|
|
27
27
|
special: Tuning,
|
|
@@ -36,7 +36,7 @@ def process(
|
|
|
36
36
|
allowsshort=allowsshort,
|
|
37
37
|
expectsabbr=expectsabbr,
|
|
38
38
|
expectsposix=expectsposix,
|
|
39
|
-
|
|
39
|
+
optDict=optDict,
|
|
40
40
|
prog=prog,
|
|
41
41
|
warn=warn,
|
|
42
42
|
)
|
|
@@ -6,7 +6,7 @@ from preparse._items.Long import Long
|
|
|
6
6
|
from preparse._items.Option import Option
|
|
7
7
|
from preparse._items.Positional import Positional
|
|
8
8
|
from preparse._items.Special import Special
|
|
9
|
-
from preparse.
|
|
9
|
+
from preparse.enums import *
|
|
10
10
|
|
|
11
11
|
__all__ = ["digest"]
|
|
12
12
|
|
|
@@ -7,7 +7,7 @@ from preparse._items.Long import Long
|
|
|
7
7
|
from preparse._items.Option import Option
|
|
8
8
|
from preparse._items.Positional import Positional
|
|
9
9
|
from preparse._items.Special import Special
|
|
10
|
-
from preparse.
|
|
10
|
+
from preparse.enums import *
|
|
11
11
|
from preparse.warners.AmbiguousOptionWarner import AmbiguousOptionWarner as PAOW
|
|
12
12
|
from preparse.warners.InvalidOptionWarner import InvalidOptionWarner as PIOW
|
|
13
13
|
from preparse.warners.RequiredArgumentWarner import RequiredArgumentWarner as PRAW
|
|
@@ -24,7 +24,7 @@ def parse_bundling(
|
|
|
24
24
|
arg: str,
|
|
25
25
|
*,
|
|
26
26
|
cause: FunctionType,
|
|
27
|
-
|
|
27
|
+
optDict: dict,
|
|
28
28
|
) -> Bundle:
|
|
29
29
|
ans: Bundle
|
|
30
30
|
x: int
|
|
@@ -35,7 +35,7 @@ def parse_bundling(
|
|
|
35
35
|
continue
|
|
36
36
|
ans.chars += y
|
|
37
37
|
try:
|
|
38
|
-
ans.nargs =
|
|
38
|
+
ans.nargs = optDict["-" + y]
|
|
39
39
|
except KeyError:
|
|
40
40
|
cause(PIOW, option=y, islong=False)
|
|
41
41
|
ans.nargs = Nargs.NO_ARGUMENT
|
|
@@ -66,7 +66,7 @@ def parse_generator(
|
|
|
66
66
|
allowsshort: bool,
|
|
67
67
|
expectsabbr: bool,
|
|
68
68
|
expectsposix: bool,
|
|
69
|
-
|
|
69
|
+
optDict: dict,
|
|
70
70
|
prog: str,
|
|
71
71
|
warn: FunctionType,
|
|
72
72
|
) -> Generator[Any, Any, Any]:
|
|
@@ -104,7 +104,7 @@ def parse_generator(
|
|
|
104
104
|
allowsshort=allowsshort,
|
|
105
105
|
cause=cause,
|
|
106
106
|
expectsabbr=expectsabbr,
|
|
107
|
-
|
|
107
|
+
optDict=optDict,
|
|
108
108
|
)
|
|
109
109
|
if not last.ishungry():
|
|
110
110
|
yield last
|
|
@@ -136,7 +136,7 @@ def parse_long(
|
|
|
136
136
|
*,
|
|
137
137
|
cause: FunctionType,
|
|
138
138
|
expectsabbr: bool,
|
|
139
|
-
|
|
139
|
+
optDict: dict,
|
|
140
140
|
) -> Long:
|
|
141
141
|
ans: Long
|
|
142
142
|
parts: list[str]
|
|
@@ -146,13 +146,13 @@ def parse_long(
|
|
|
146
146
|
ans.joined = True
|
|
147
147
|
ans.right = parts.pop()
|
|
148
148
|
ans.abbrlen = len(ans.fullkey)
|
|
149
|
-
if ans.fullkey in
|
|
150
|
-
ans.nargs =
|
|
149
|
+
if ans.fullkey in optDict.keys():
|
|
150
|
+
ans.nargs = optDict[ans.fullkey]
|
|
151
151
|
if (ans.nargs == Nargs.NO_ARGUMENT) and (ans.right is not None):
|
|
152
152
|
cause(PUAW, option=ans.fullkey)
|
|
153
153
|
return ans
|
|
154
154
|
if expectsabbr:
|
|
155
|
-
parts = parse_long_startswith(ans.abbr, keys=
|
|
155
|
+
parts = parse_long_startswith(ans.abbr, keys=optDict.keys())
|
|
156
156
|
else:
|
|
157
157
|
parts = list() # can be assumed
|
|
158
158
|
if len(parts) == 0:
|
|
@@ -164,7 +164,7 @@ def parse_long(
|
|
|
164
164
|
cause(PAOW, option=arg, possibilities=parts)
|
|
165
165
|
return ans
|
|
166
166
|
(ans.fullkey,) = parts
|
|
167
|
-
ans.nargs =
|
|
167
|
+
ans.nargs = optDict[ans.fullkey]
|
|
168
168
|
return ans
|
|
169
169
|
|
|
170
170
|
|
|
@@ -187,7 +187,7 @@ def parse_option(
|
|
|
187
187
|
*,
|
|
188
188
|
cause: FunctionType,
|
|
189
189
|
expectsabbr: bool,
|
|
190
|
-
|
|
190
|
+
optDict: dict,
|
|
191
191
|
**kwargs: Any,
|
|
192
192
|
) -> Option:
|
|
193
193
|
if parse_islong(arg, **kwargs):
|
|
@@ -195,11 +195,11 @@ def parse_option(
|
|
|
195
195
|
arg,
|
|
196
196
|
cause=cause,
|
|
197
197
|
expectsabbr=expectsabbr,
|
|
198
|
-
|
|
198
|
+
optDict=optDict,
|
|
199
199
|
)
|
|
200
200
|
else:
|
|
201
201
|
return parse_bundling(
|
|
202
202
|
arg,
|
|
203
203
|
cause=cause,
|
|
204
|
-
|
|
204
|
+
optDict=optDict,
|
|
205
205
|
)
|
|
@@ -6,12 +6,12 @@ import setdoc
|
|
|
6
6
|
from datarepr import datarepr
|
|
7
7
|
from frozendict import frozendict
|
|
8
8
|
|
|
9
|
-
from preparse.
|
|
9
|
+
from preparse.enums import *
|
|
10
10
|
|
|
11
|
-
__all__ = ["
|
|
11
|
+
__all__ = ["OptDict"]
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
class
|
|
14
|
+
class OptDict(cmp3.CmpABC, datahold.HoldDict[str, Nargs]):
|
|
15
15
|
__slots__ = ()
|
|
16
16
|
|
|
17
17
|
data: frozendict[str, Nargs]
|
|
@@ -14,8 +14,8 @@ from tofunc import tofunc
|
|
|
14
14
|
from preparse._processing import *
|
|
15
15
|
from preparse._utils.dataprop import dataprop
|
|
16
16
|
from preparse.core.Click import Click
|
|
17
|
-
from preparse.core.
|
|
18
|
-
from preparse.
|
|
17
|
+
from preparse.core.OptDict import OptDict
|
|
18
|
+
from preparse.enums import *
|
|
19
19
|
from preparse.warners import *
|
|
20
20
|
|
|
21
21
|
__all__ = ["PreParser"]
|
|
@@ -29,7 +29,7 @@ class PreParser(Copyable):
|
|
|
29
29
|
expandsabbr: bool
|
|
30
30
|
expectsabbr: bool
|
|
31
31
|
expectsposix: bool
|
|
32
|
-
|
|
32
|
+
optDict: OptDict
|
|
33
33
|
prog: str
|
|
34
34
|
reconcilesorders: bool
|
|
35
35
|
special: Tuning
|
|
@@ -47,7 +47,7 @@ class PreParser(Copyable):
|
|
|
47
47
|
expandsabbr: Any = True,
|
|
48
48
|
expectsabbr: Any = True,
|
|
49
49
|
expectsposix: Any = False,
|
|
50
|
-
|
|
50
|
+
optDict: Any = (),
|
|
51
51
|
prog: Any = None,
|
|
52
52
|
reconcilesorders: Any = True,
|
|
53
53
|
special: Any = Tuning.MAINTAIN,
|
|
@@ -59,7 +59,7 @@ class PreParser(Copyable):
|
|
|
59
59
|
self.expandsabbr = expandsabbr
|
|
60
60
|
self.expectsabbr = expectsabbr
|
|
61
61
|
self.expectsposix = expectsposix
|
|
62
|
-
self.
|
|
62
|
+
self.optDict = optDict
|
|
63
63
|
self.prog = prog
|
|
64
64
|
self.reconcilesorders = reconcilesorders
|
|
65
65
|
self.special = special
|
|
@@ -106,15 +106,15 @@ class PreParser(Copyable):
|
|
|
106
106
|
return bool(value)
|
|
107
107
|
|
|
108
108
|
@dataprop
|
|
109
|
-
def
|
|
109
|
+
def optDict(self: Self, value: Any) -> OptDict:
|
|
110
110
|
"This property gives a dictionary of options."
|
|
111
|
-
dataA:
|
|
112
|
-
if "
|
|
113
|
-
self._data["
|
|
114
|
-
dataA =
|
|
115
|
-
self._data["
|
|
116
|
-
self._data["
|
|
117
|
-
return self._data["
|
|
111
|
+
dataA: OptDict
|
|
112
|
+
if "optDict" not in self._data.keys():
|
|
113
|
+
self._data["optDict"] = OptDict()
|
|
114
|
+
dataA = OptDict(value)
|
|
115
|
+
self._data["optDict"].clear()
|
|
116
|
+
self._data["optDict"].update(dataA)
|
|
117
|
+
return self._data["optDict"]
|
|
118
118
|
|
|
119
119
|
def parse_args(
|
|
120
120
|
self: Self,
|
|
@@ -137,11 +137,11 @@ class PreParser(Copyable):
|
|
|
137
137
|
|
|
138
138
|
def reflectClickCommand(self: Self, cmd: cl.Command) -> None:
|
|
139
139
|
"This method causes the current instance to reflect a click.Command object."
|
|
140
|
-
|
|
140
|
+
optDict: dict[str, Nargs]
|
|
141
141
|
nargs: Nargs
|
|
142
142
|
opt: Any
|
|
143
143
|
param: Any
|
|
144
|
-
|
|
144
|
+
optDict = dict()
|
|
145
145
|
for param in cmd.params:
|
|
146
146
|
if not isinstance(param, cl.Option):
|
|
147
147
|
continue
|
|
@@ -152,9 +152,9 @@ class PreParser(Copyable):
|
|
|
152
152
|
else:
|
|
153
153
|
nargs = Nargs.OPTIONAL_ARGUMENT
|
|
154
154
|
for opt in param.opts:
|
|
155
|
-
|
|
156
|
-
self.
|
|
157
|
-
self.
|
|
155
|
+
optDict[str(opt)] = nargs
|
|
156
|
+
self.optDict.clear()
|
|
157
|
+
self.optDict.update(optDict)
|
|
158
158
|
|
|
159
159
|
def reflectClickContext(self: Self, ctx: cl.Context) -> None:
|
|
160
160
|
"This method causes the current instance to reflect a click.Context object."
|