preparse 2.0.0.dev5__py3-none-any.whl → 2.0.0.dev7__py3-none-any.whl
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/_items/Bundle.py +5 -5
- preparse/_items/Item.py +1 -1
- preparse/_items/Long.py +1 -1
- preparse/_items/Option.py +1 -1
- preparse/_items/Positional.py +1 -1
- preparse/_items/Special.py +1 -1
- preparse/_processing/__init__.py +14 -14
- preparse/_processing/digesting.py +22 -42
- preparse/_processing/parsing.py +40 -32
- preparse/core/Optdict.py +4 -3
- preparse/core/PreParser.py +37 -37
- preparse/core/__init__.py +3 -2
- preparse/core/warnings.py +152 -0
- preparse/tests/data.toml +176686 -176640
- preparse/tests/test_data_toml.py +16 -2
- preparse/tests/test_enums.py +1 -1
- preparse/tests/test_expit_toml.py +1 -1
- preparse/tests/test_optdict.py +7 -6
- preparse/tests/test_preparser.py +4 -3
- {preparse-2.0.0.dev5.dist-info → preparse-2.0.0.dev7.dist-info}/METADATA +1 -1
- preparse-2.0.0.dev7.dist-info/RECORD +34 -0
- preparse/core/PreparseWarning.py +0 -6
- preparse/warners/AmbiguousOptionWarner.py +0 -38
- preparse/warners/DualWarner.py +0 -33
- preparse/warners/InvalidOptionWarner.py +0 -14
- preparse/warners/LongonlyWarner.py +0 -13
- preparse/warners/RequiredArgumentWarner.py +0 -14
- preparse/warners/UnallowedArgumentWarner.py +0 -25
- preparse/warners/WarnerABC.py +0 -60
- preparse/warners/__init__.py +0 -0
- preparse-2.0.0.dev5.dist-info/RECORD +0 -42
- /preparse/{enums/__init__.py → core/enums.py} +0 -0
- {preparse-2.0.0.dev5.dist-info → preparse-2.0.0.dev7.dist-info}/WHEEL +0 -0
- {preparse-2.0.0.dev5.dist-info → preparse-2.0.0.dev7.dist-info}/licenses/LICENSE.txt +0 -0
- {preparse-2.0.0.dev5.dist-info → preparse-2.0.0.dev7.dist-info}/top_level.txt +0 -0
preparse/_items/Bundle.py
CHANGED
|
@@ -5,7 +5,7 @@ import setdoc
|
|
|
5
5
|
from preparse._items.Item import Item
|
|
6
6
|
from preparse._items.Option import Option
|
|
7
7
|
from preparse._utils.dataprop import dataprop
|
|
8
|
-
from preparse.enums import *
|
|
8
|
+
from preparse.core.enums import *
|
|
9
9
|
|
|
10
10
|
__all__ = ["Bundle"]
|
|
11
11
|
|
|
@@ -32,7 +32,7 @@ class Bundle(Option):
|
|
|
32
32
|
self.right = right
|
|
33
33
|
|
|
34
34
|
@classmethod
|
|
35
|
-
def
|
|
35
|
+
def _split_allowslong(cls: type, chars: str) -> list[str]:
|
|
36
36
|
ans: list[str]
|
|
37
37
|
x: str
|
|
38
38
|
ans = list()
|
|
@@ -73,12 +73,12 @@ class Bundle(Option):
|
|
|
73
73
|
else:
|
|
74
74
|
return ["-" + self.chars, self.right]
|
|
75
75
|
|
|
76
|
-
def split(self: Self, *,
|
|
76
|
+
def split(self: Self, *, allowslong: bool) -> list[Item]:
|
|
77
77
|
ans: list[Self]
|
|
78
78
|
parts: list[str]
|
|
79
79
|
x: str
|
|
80
|
-
if
|
|
81
|
-
parts = self.
|
|
80
|
+
if allowslong:
|
|
81
|
+
parts = self._split_allowslong(self.chars)
|
|
82
82
|
else:
|
|
83
83
|
parts = self._split_shortonly(self.chars)
|
|
84
84
|
ans = list()
|
preparse/_items/Item.py
CHANGED
preparse/_items/Long.py
CHANGED
preparse/_items/Option.py
CHANGED
preparse/_items/Positional.py
CHANGED
preparse/_items/Special.py
CHANGED
preparse/_processing/__init__.py
CHANGED
|
@@ -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.enums import *
|
|
10
|
+
from preparse.core.enums import *
|
|
11
11
|
|
|
12
12
|
__all__ = ["process"]
|
|
13
13
|
|
|
@@ -15,15 +15,15 @@ __all__ = ["process"]
|
|
|
15
15
|
def process(
|
|
16
16
|
args: Optional[Iterable] = None,
|
|
17
17
|
*,
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
allowslong: bool,
|
|
19
|
+
allowsshort: bool,
|
|
20
20
|
bundling: Tuning,
|
|
21
21
|
expandsabbr: bool,
|
|
22
22
|
expectsabbr: bool,
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
expectsposix: bool,
|
|
24
|
+
optdict: dict,
|
|
25
25
|
prog: str,
|
|
26
|
-
|
|
26
|
+
reconcilesorders: bool,
|
|
27
27
|
special: Tuning,
|
|
28
28
|
warn: FunctionType,
|
|
29
29
|
) -> list[str]:
|
|
@@ -32,21 +32,21 @@ def process(
|
|
|
32
32
|
items = pull(args)
|
|
33
33
|
items = parse(
|
|
34
34
|
items,
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
allowslong=allowslong,
|
|
36
|
+
allowsshort=allowsshort,
|
|
37
|
+
expandsabbr=expandsabbr,
|
|
37
38
|
expectsabbr=expectsabbr,
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
expectsposix=expectsposix,
|
|
40
|
+
optdict=optdict,
|
|
40
41
|
prog=prog,
|
|
41
42
|
warn=warn,
|
|
42
43
|
)
|
|
43
44
|
items = digest(
|
|
44
45
|
items,
|
|
45
|
-
|
|
46
|
+
allowslong=allowslong,
|
|
46
47
|
bundling=bundling,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
reconcilesOrders=reconcilesOrders,
|
|
48
|
+
expectsposix=expectsposix,
|
|
49
|
+
reconcilesorders=reconcilesorders,
|
|
50
50
|
special=special,
|
|
51
51
|
)
|
|
52
52
|
return deparse(items)
|
|
@@ -2,11 +2,11 @@ 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
|
|
6
5
|
from preparse._items.Option import Option
|
|
7
6
|
from preparse._items.Positional import Positional
|
|
8
7
|
from preparse._items.Special import Special
|
|
9
|
-
from preparse.enums import *
|
|
8
|
+
from preparse.core.enums import *
|
|
9
|
+
from preparse.core.warnings import *
|
|
10
10
|
|
|
11
11
|
__all__ = ["digest"]
|
|
12
12
|
|
|
@@ -14,62 +14,42 @@ __all__ = ["digest"]
|
|
|
14
14
|
def digest(
|
|
15
15
|
items: list[Item],
|
|
16
16
|
*,
|
|
17
|
-
|
|
17
|
+
allowslong: bool,
|
|
18
18
|
bundling: Tuning,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
reconcilesOrders: bool,
|
|
19
|
+
expectsposix: bool,
|
|
20
|
+
reconcilesorders: bool,
|
|
22
21
|
special: Tuning,
|
|
23
22
|
) -> list[Item]:
|
|
24
23
|
ans: list[Item]
|
|
25
24
|
ans = list(items)
|
|
26
|
-
|
|
27
|
-
ans,
|
|
28
|
-
expandsabbr=expandsabbr,
|
|
29
|
-
)
|
|
25
|
+
|
|
30
26
|
ans = digest_special(
|
|
31
27
|
ans,
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
expectsposix=expectsposix,
|
|
29
|
+
reconcilesorders=reconcilesorders,
|
|
34
30
|
special=special,
|
|
35
31
|
)
|
|
36
32
|
ans = digest_order(
|
|
37
33
|
ans,
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
expectsposix=expectsposix,
|
|
35
|
+
reconcilesorders=reconcilesorders,
|
|
40
36
|
)
|
|
41
37
|
ans = digest_bundling(
|
|
42
38
|
ans,
|
|
43
39
|
bundling=bundling,
|
|
44
|
-
|
|
40
|
+
allowslong=allowslong,
|
|
45
41
|
)
|
|
46
42
|
return ans
|
|
47
43
|
|
|
48
44
|
|
|
49
|
-
def digest_abbr(
|
|
50
|
-
items: list[Item],
|
|
51
|
-
*,
|
|
52
|
-
expandsabbr: bool,
|
|
53
|
-
) -> list[Item]:
|
|
54
|
-
ans: list[Item]
|
|
55
|
-
item: Item
|
|
56
|
-
ans = list(items)
|
|
57
|
-
if not expandsabbr:
|
|
58
|
-
return ans
|
|
59
|
-
for item in ans:
|
|
60
|
-
if isinstance(item, Long):
|
|
61
|
-
item.abbrlen = None
|
|
62
|
-
return ans
|
|
63
|
-
|
|
64
|
-
|
|
65
45
|
def digest_bundling(
|
|
66
46
|
items: list[Item],
|
|
67
47
|
*,
|
|
68
|
-
|
|
48
|
+
allowslong: bool,
|
|
69
49
|
bundling: Tuning,
|
|
70
50
|
) -> list[Item]:
|
|
71
51
|
if bundling == Tuning.MINIMIZE:
|
|
72
|
-
return digest_bundling_min(items,
|
|
52
|
+
return digest_bundling_min(items, allowslong=allowslong)
|
|
73
53
|
if bundling == Tuning.MAXIMIZE:
|
|
74
54
|
return digest_bundling_max(items)
|
|
75
55
|
return items
|
|
@@ -78,14 +58,14 @@ def digest_bundling(
|
|
|
78
58
|
def digest_bundling_min(
|
|
79
59
|
items: list[Item],
|
|
80
60
|
*,
|
|
81
|
-
|
|
61
|
+
allowslong: bool,
|
|
82
62
|
) -> list[Item]:
|
|
83
63
|
ans: list[Item]
|
|
84
64
|
item: Item
|
|
85
65
|
ans = list()
|
|
86
66
|
for item in items:
|
|
87
67
|
if isinstance(item, Bundle):
|
|
88
|
-
ans += item.split(
|
|
68
|
+
ans += item.split(allowslong=allowslong)
|
|
89
69
|
else:
|
|
90
70
|
ans.append(item)
|
|
91
71
|
return ans
|
|
@@ -116,16 +96,16 @@ def digest_bundling_max(items: list[Item]) -> list[Item]:
|
|
|
116
96
|
def digest_order(
|
|
117
97
|
items: list[Item],
|
|
118
98
|
*,
|
|
119
|
-
|
|
120
|
-
|
|
99
|
+
expectsposix: bool,
|
|
100
|
+
reconcilesorders: bool,
|
|
121
101
|
) -> list[Item]:
|
|
122
102
|
ans: list[Item]
|
|
123
103
|
comp: bool
|
|
124
104
|
index: int
|
|
125
105
|
ans = list(items)
|
|
126
|
-
if not
|
|
106
|
+
if not reconcilesorders:
|
|
127
107
|
return ans
|
|
128
|
-
if not
|
|
108
|
+
if not expectsposix:
|
|
129
109
|
ans.sort(key=digest_order_key)
|
|
130
110
|
return ans
|
|
131
111
|
index = len(ans)
|
|
@@ -187,8 +167,8 @@ def digest_special_max(items: list[Item]) -> list[Item]:
|
|
|
187
167
|
def digest_special_min(
|
|
188
168
|
items: list[Item],
|
|
189
169
|
*,
|
|
190
|
-
|
|
191
|
-
|
|
170
|
+
expectsposix: bool,
|
|
171
|
+
reconcilesorders: bool,
|
|
192
172
|
) -> list[Item]:
|
|
193
173
|
ans: list[Item]
|
|
194
174
|
index: int
|
|
@@ -196,7 +176,7 @@ def digest_special_min(
|
|
|
196
176
|
isposix: bool
|
|
197
177
|
ans = list(items)
|
|
198
178
|
isdel = True
|
|
199
|
-
isposix =
|
|
179
|
+
isposix = expectsposix and not reconcilesorders
|
|
200
180
|
index = len(items)
|
|
201
181
|
while True:
|
|
202
182
|
index -= 1
|
preparse/_processing/parsing.py
CHANGED
|
@@ -7,14 +7,16 @@ 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.
|
|
11
|
-
from preparse.
|
|
12
|
-
from preparse.warners.InvalidOptionWarner import InvalidOptionWarner as PIOW
|
|
13
|
-
from preparse.warners.RequiredArgumentWarner import RequiredArgumentWarner as PRAW
|
|
14
|
-
from preparse.warners.UnallowedArgumentWarner import UnallowedArgumentWarner as PUAW
|
|
10
|
+
from preparse.core import warnings
|
|
11
|
+
from preparse.core.enums import *
|
|
15
12
|
|
|
16
13
|
__all__ = ["parse"]
|
|
17
14
|
|
|
15
|
+
PAOW = warnings.PreparseAmbiguousOptionWarning
|
|
16
|
+
PIOW = warnings.PreparseInvalidOptionWarning
|
|
17
|
+
PUAW = warnings.PreparseUnallowedArgumentWarning
|
|
18
|
+
PRAW = warnings.PreparseRequiredArgumentWarning
|
|
19
|
+
|
|
18
20
|
|
|
19
21
|
def parse(args: list[str], **kwargs: Any) -> list[Item]:
|
|
20
22
|
return list(parse_generator(args, **kwargs))
|
|
@@ -24,7 +26,7 @@ def parse_bundling(
|
|
|
24
26
|
arg: str,
|
|
25
27
|
*,
|
|
26
28
|
cause: FunctionType,
|
|
27
|
-
|
|
29
|
+
optdict: dict,
|
|
28
30
|
) -> Bundle:
|
|
29
31
|
ans: Bundle
|
|
30
32
|
x: int
|
|
@@ -35,7 +37,7 @@ def parse_bundling(
|
|
|
35
37
|
continue
|
|
36
38
|
ans.chars += y
|
|
37
39
|
try:
|
|
38
|
-
ans.nargs =
|
|
40
|
+
ans.nargs = optdict["-" + y]
|
|
39
41
|
except KeyError:
|
|
40
42
|
cause(PIOW, option=y, islong=False)
|
|
41
43
|
ans.nargs = Nargs.NO_ARGUMENT
|
|
@@ -62,11 +64,12 @@ def parse_cause(
|
|
|
62
64
|
def parse_generator(
|
|
63
65
|
items: list[Positional],
|
|
64
66
|
*,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
allowslong: bool,
|
|
68
|
+
allowsshort: bool,
|
|
69
|
+
expandsabbr: bool,
|
|
67
70
|
expectsabbr: bool,
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
expectsposix: bool,
|
|
72
|
+
optdict: dict,
|
|
70
73
|
prog: str,
|
|
71
74
|
warn: FunctionType,
|
|
72
75
|
) -> Generator[Any, Any, Any]:
|
|
@@ -74,7 +77,7 @@ def parse_generator(
|
|
|
74
77
|
cause: FunctionType
|
|
75
78
|
last: Optional[Option]
|
|
76
79
|
item: Positional
|
|
77
|
-
broken = not (
|
|
80
|
+
broken = not (allowslong or allowsshort)
|
|
78
81
|
cause = parse_cause(prog=prog, warn=warn)
|
|
79
82
|
last = None
|
|
80
83
|
for item in items:
|
|
@@ -96,15 +99,16 @@ def parse_generator(
|
|
|
96
99
|
if item.isobvious():
|
|
97
100
|
# if the item is positional
|
|
98
101
|
yield item
|
|
99
|
-
broken =
|
|
102
|
+
broken = expectsposix
|
|
100
103
|
continue
|
|
101
104
|
last = parse_option(
|
|
102
105
|
item.value,
|
|
103
|
-
|
|
104
|
-
|
|
106
|
+
allowslong=allowslong,
|
|
107
|
+
allowsshort=allowsshort,
|
|
105
108
|
cause=cause,
|
|
109
|
+
expandsabbr=expandsabbr,
|
|
106
110
|
expectsabbr=expectsabbr,
|
|
107
|
-
|
|
111
|
+
optdict=optdict,
|
|
108
112
|
)
|
|
109
113
|
if not last.ishungry():
|
|
110
114
|
yield last
|
|
@@ -122,21 +126,22 @@ def parse_generator(
|
|
|
122
126
|
def parse_islong(
|
|
123
127
|
arg: str,
|
|
124
128
|
*,
|
|
125
|
-
|
|
126
|
-
|
|
129
|
+
allowslong: bool,
|
|
130
|
+
allowsshort: bool,
|
|
127
131
|
) -> bool:
|
|
128
|
-
if
|
|
132
|
+
if allowslong and allowsshort:
|
|
129
133
|
return arg.startswith("--")
|
|
130
134
|
else:
|
|
131
|
-
return not
|
|
135
|
+
return not allowsshort
|
|
132
136
|
|
|
133
137
|
|
|
134
138
|
def parse_long(
|
|
135
139
|
arg: str,
|
|
136
140
|
*,
|
|
137
141
|
cause: FunctionType,
|
|
142
|
+
expandsabbr: bool,
|
|
138
143
|
expectsabbr: bool,
|
|
139
|
-
|
|
144
|
+
optdict: dict,
|
|
140
145
|
) -> Long:
|
|
141
146
|
ans: Long
|
|
142
147
|
parts: list[str]
|
|
@@ -146,13 +151,10 @@ def parse_long(
|
|
|
146
151
|
ans.joined = True
|
|
147
152
|
ans.right = parts.pop()
|
|
148
153
|
ans.abbrlen = len(ans.fullkey)
|
|
149
|
-
if ans.fullkey in
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
return ans
|
|
154
|
-
if expectsabbr:
|
|
155
|
-
parts = parse_long_startswith(ans.abbr, keys=optDict.keys())
|
|
154
|
+
if ans.fullkey in optdict.keys():
|
|
155
|
+
parts = [ans.fullkey]
|
|
156
|
+
elif expectsabbr:
|
|
157
|
+
parts = parse_long_startswith(ans.abbr, keys=optdict.keys())
|
|
156
158
|
else:
|
|
157
159
|
parts = list() # can be assumed
|
|
158
160
|
if len(parts) == 0:
|
|
@@ -164,7 +166,11 @@ def parse_long(
|
|
|
164
166
|
cause(PAOW, option=arg, possibilities=parts)
|
|
165
167
|
return ans
|
|
166
168
|
(ans.fullkey,) = parts
|
|
167
|
-
|
|
169
|
+
if expandsabbr:
|
|
170
|
+
ans.abbrlen = len(ans.fullkey)
|
|
171
|
+
ans.nargs = optdict[ans.fullkey]
|
|
172
|
+
if (ans.nargs == Nargs.NO_ARGUMENT) and (ans.right is not None):
|
|
173
|
+
cause(PUAW, option=ans.fullkey)
|
|
168
174
|
return ans
|
|
169
175
|
|
|
170
176
|
|
|
@@ -186,20 +192,22 @@ def parse_option(
|
|
|
186
192
|
arg: str,
|
|
187
193
|
*,
|
|
188
194
|
cause: FunctionType,
|
|
195
|
+
expandsabbr: bool,
|
|
189
196
|
expectsabbr: bool,
|
|
190
|
-
|
|
197
|
+
optdict: dict,
|
|
191
198
|
**kwargs: Any,
|
|
192
199
|
) -> Option:
|
|
193
200
|
if parse_islong(arg, **kwargs):
|
|
194
201
|
return parse_long(
|
|
195
202
|
arg,
|
|
196
203
|
cause=cause,
|
|
204
|
+
expandsabbr=expandsabbr,
|
|
197
205
|
expectsabbr=expectsabbr,
|
|
198
|
-
|
|
206
|
+
optdict=optdict,
|
|
199
207
|
)
|
|
200
208
|
else:
|
|
201
209
|
return parse_bundling(
|
|
202
210
|
arg,
|
|
203
211
|
cause=cause,
|
|
204
|
-
|
|
212
|
+
optdict=optdict,
|
|
205
213
|
)
|
preparse/core/Optdict.py
CHANGED
|
@@ -6,12 +6,13 @@ import setdoc
|
|
|
6
6
|
from datarepr import datarepr
|
|
7
7
|
from frozendict import frozendict
|
|
8
8
|
|
|
9
|
-
from preparse.enums import *
|
|
9
|
+
from preparse.core.enums import *
|
|
10
|
+
from preparse.core.warnings import *
|
|
10
11
|
|
|
11
|
-
__all__ = ["
|
|
12
|
+
__all__ = ["Optdict"]
|
|
12
13
|
|
|
13
14
|
|
|
14
|
-
class
|
|
15
|
+
class Optdict(cmp3.CmpABC, datahold.HoldDict[str, Nargs]):
|
|
15
16
|
__slots__ = ()
|
|
16
17
|
|
|
17
18
|
data: frozendict[str, Nargs]
|
preparse/core/PreParser.py
CHANGED
|
@@ -14,26 +14,26 @@ 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.
|
|
19
|
-
from preparse.
|
|
17
|
+
from preparse.core.enums import *
|
|
18
|
+
from preparse.core.Optdict import *
|
|
19
|
+
from preparse.core.warnings import *
|
|
20
20
|
|
|
21
21
|
__all__ = ["PreParser"]
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
class PreParser(Copyable):
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
allowslong: bool
|
|
27
|
+
allowsshort: bool
|
|
28
28
|
bundling: Tuning
|
|
29
29
|
expandsabbr: bool
|
|
30
30
|
expectsabbr: bool
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
expectsposix: bool
|
|
32
|
+
optdict: Optdict
|
|
33
33
|
prog: str
|
|
34
|
-
|
|
34
|
+
reconcilesorders: bool
|
|
35
35
|
special: Tuning
|
|
36
|
-
warn:
|
|
36
|
+
warn: types.FunctionType
|
|
37
37
|
|
|
38
38
|
__slots__ = ("_data",)
|
|
39
39
|
|
|
@@ -41,27 +41,27 @@ class PreParser(Copyable):
|
|
|
41
41
|
def __init__(
|
|
42
42
|
self: Self,
|
|
43
43
|
*,
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
allowslong: Any = True,
|
|
45
|
+
allowsshort: Any = True,
|
|
46
46
|
bundling: Any = Tuning.MAINTAIN,
|
|
47
47
|
expandsabbr: Any = True,
|
|
48
48
|
expectsabbr: Any = True,
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
expectsposix: Any = False,
|
|
50
|
+
optdict: Any = (),
|
|
51
51
|
prog: Any = None,
|
|
52
|
-
|
|
52
|
+
reconcilesorders: Any = True,
|
|
53
53
|
special: Any = Tuning.MAINTAIN,
|
|
54
|
-
warn:
|
|
54
|
+
warn: Callable = str,
|
|
55
55
|
) -> None:
|
|
56
|
-
self.
|
|
57
|
-
self.
|
|
56
|
+
self.allowslong = allowslong
|
|
57
|
+
self.allowsshort = allowsshort
|
|
58
58
|
self.bundling = bundling
|
|
59
59
|
self.expandsabbr = expandsabbr
|
|
60
60
|
self.expectsabbr = expectsabbr
|
|
61
|
-
self.
|
|
62
|
-
self.
|
|
61
|
+
self.expectsposix = expectsposix
|
|
62
|
+
self.optdict = optdict
|
|
63
63
|
self.prog = prog
|
|
64
|
-
self.
|
|
64
|
+
self.reconcilesorders = reconcilesorders
|
|
65
65
|
self.special = special
|
|
66
66
|
self.warn = warn
|
|
67
67
|
|
|
@@ -70,11 +70,11 @@ class PreParser(Copyable):
|
|
|
70
70
|
return datarepr(type(self).__name__, **self.todict())
|
|
71
71
|
|
|
72
72
|
@dataprop
|
|
73
|
-
def
|
|
73
|
+
def allowslong(self: Self, value: Any) -> bool:
|
|
74
74
|
return bool(value)
|
|
75
75
|
|
|
76
76
|
@dataprop
|
|
77
|
-
def
|
|
77
|
+
def allowsshort(self: Self, value: Any) -> bool:
|
|
78
78
|
return bool(value)
|
|
79
79
|
|
|
80
80
|
@dataprop
|
|
@@ -99,22 +99,22 @@ class PreParser(Copyable):
|
|
|
99
99
|
return bool(value)
|
|
100
100
|
|
|
101
101
|
@dataprop
|
|
102
|
-
def
|
|
102
|
+
def expectsposix(self: Self, value: Any) -> bool:
|
|
103
103
|
if value == "infer":
|
|
104
104
|
return bool(os.environ.get("POSIXLY_CORRECT"))
|
|
105
105
|
else:
|
|
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,
|
|
@@ -132,16 +132,16 @@ class PreParser(Copyable):
|
|
|
132
132
|
return str(value)
|
|
133
133
|
|
|
134
134
|
@dataprop
|
|
135
|
-
def
|
|
135
|
+
def reconcilesorders(self: Self, value: Any) -> bool:
|
|
136
136
|
return bool(value)
|
|
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."
|
preparse/core/__init__.py
CHANGED