preparse 1.1.9__tar.gz → 1.1.11__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-1.1.9 → preparse-1.1.11}/PKG-INFO +1 -1
- {preparse-1.1.9 → preparse-1.1.11}/docs/v1.1.rst +9 -7
- {preparse-1.1.9 → preparse-1.1.11}/pyproject.toml +1 -1
- preparse-1.1.11/src/preparse/_tests/secondary.py +16 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/core/Optdict.py +11 -5
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/core/PreParser.py +10 -6
- preparse-1.1.11/src/preparse/tests/secondary.toml +7 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/tests/test_data_toml.py +5 -8
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/tests/test_expit_toml.py +5 -8
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/tests/test_optdict.py +26 -1
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/warnings/PreparseDualWarning.py +1 -1
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse.egg-info/PKG-INFO +1 -1
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse.egg-info/SOURCES.txt +2 -0
- {preparse-1.1.9 → preparse-1.1.11}/LICENSE.txt +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/MANIFEST.in +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/README.rst +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/docs/v1.0.rst +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/setup.cfg +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/__init__.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/_items/Bundle.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/_items/Item.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/_items/Long.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/_items/Option.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/_items/Positional.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/_items/Special.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/_items/__init__.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/_processing/__init__.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/_processing/deparsing.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/_processing/digesting.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/_processing/parsing.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/_processing/pulling.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/_tests/__init__.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/_tests/expit.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/core/Click.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/core/__init__.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/enums/BaseEnum.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/enums/Nargs.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/enums/Tuning.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/enums/__init__.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/py.typed +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/tests/__init__.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/tests/data.toml +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/tests/expit.toml +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/tests/test_enums.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/tests/test_preparser.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/typing/SupportsKeysAndGetitem.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/typing/__init__.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/warnings/PreparseAmbiguousOptionWarning.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/warnings/PreparseInvalidOptionWarning.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/warnings/PreparseLongonlyWarning.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/warnings/PreparseRequiredArgumentWarning.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/warnings/PreparseUnallowedArgumentWarning.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/warnings/PreparseWarning.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse/warnings/__init__.py +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse.egg-info/dependency_links.txt +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse.egg-info/requires.txt +0 -0
- {preparse-1.1.9 → preparse-1.1.11}/src/preparse.egg-info/top_level.txt +0 -0
|
@@ -85,7 +85,7 @@ It works as a decorator that embeds its parser into a given target from the libr
|
|
|
85
85
|
``cmd: object``
|
|
86
86
|
"""""""""""""""
|
|
87
87
|
|
|
88
|
-
This
|
|
88
|
+
This dataclass field determines if the ``reflectClickCommand`` method of parser is to be called.
|
|
89
89
|
|
|
90
90
|
``copy() -> Self``
|
|
91
91
|
""""""""""""""""""
|
|
@@ -95,12 +95,12 @@ This method returns a shallow copy of the current decorator.
|
|
|
95
95
|
``ctx: object``
|
|
96
96
|
"""""""""""""""
|
|
97
97
|
|
|
98
|
-
This
|
|
98
|
+
This dataclass field determines if the ``reflectClickContext`` method of parser is to be called.
|
|
99
99
|
|
|
100
100
|
``parser: preparse.core.PreParser.PreParser``
|
|
101
101
|
"""""""""""""""""""""""""""""""""""""""""""""
|
|
102
102
|
|
|
103
|
-
This
|
|
103
|
+
This dataclass field holds the parser to be embedded.
|
|
104
104
|
|
|
105
105
|
``class preparse.core.Optdict.Optdict(data: preparse.typing.SupportsKeysAndGetitem.SupportsKeysAndGetitem | Iterable[tuple[Hashable, object]] = (), /)``
|
|
106
106
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
@@ -166,8 +166,10 @@ This ``property`` holds a dict-like object.
|
|
|
166
166
|
Its keys are the options.
|
|
167
167
|
Its values specify ``preparse.Nargs``.
|
|
168
168
|
Options not found within the dictionary
|
|
169
|
-
cause a ``preparse.PreparseInvalidOptionWarning
|
|
170
|
-
|
|
169
|
+
cause a ``preparse.PreparseInvalidOptionWarning``.
|
|
170
|
+
Unknown short options are assumed to take no argument.
|
|
171
|
+
Unknown long options are assumed to take an optional argument.
|
|
172
|
+
This behaviour reflects ``getopt``.
|
|
171
173
|
|
|
172
174
|
``parse_args(args: Optional[Iterable[object]] = None) -> list[str]``
|
|
173
175
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
@@ -292,8 +294,8 @@ These classes are subclasses of ``Warning`` that are specifically designed to co
|
|
|
292
294
|
|
|
293
295
|
This abstract base ``class`` is the base for all other warning types.
|
|
294
296
|
|
|
295
|
-
``class preparse.warnings.PreparseAmbiguousOptionWarning.PreparseAmbiguousOptionWarning(*, prog:
|
|
296
|
-
|
|
297
|
+
``class preparse.warnings.PreparseAmbiguousOptionWarning.PreparseAmbiguousOptionWarning(*, prog: object, option: object, possibilities: Iterable[object])``
|
|
298
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
297
299
|
|
|
298
300
|
This ``class`` warns about ambiguous options. This can only happen for long options.
|
|
299
301
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
|
|
5
|
+
__all__ = ["secondary"]
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@click.command()
|
|
9
|
+
@click.option("-v", "--verbose", is_flag=True)
|
|
10
|
+
@click.option("--name", required=True)
|
|
11
|
+
@click.option("--color/--no-color", default=True)
|
|
12
|
+
@click.option("--mode", is_flag=False, flag_value="auto", default=None)
|
|
13
|
+
def secondary(**kwargs: Any) -> None:
|
|
14
|
+
i: tuple[str, Any]
|
|
15
|
+
for i in sorted(kwargs.items()):
|
|
16
|
+
print("%s = %r" % i)
|
|
@@ -52,9 +52,15 @@ class Optdict(
|
|
|
52
52
|
/,
|
|
53
53
|
) -> None:
|
|
54
54
|
a: frozendict[Hashable, object]
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
b: list[tuple[str, Nargs]]
|
|
56
|
+
x: Hashable
|
|
57
|
+
y: object
|
|
57
58
|
a = frozendict(value) # type: ignore[arg-type]
|
|
58
|
-
|
|
59
|
-
y
|
|
60
|
-
|
|
59
|
+
b = list()
|
|
60
|
+
for x, y in a.items():
|
|
61
|
+
if isinstance(y, int):
|
|
62
|
+
b.append((str(x), Nargs(y)))
|
|
63
|
+
else:
|
|
64
|
+
b.append((str(x), Nargs.OPTIONAL_ARGUMENT))
|
|
65
|
+
b.sort()
|
|
66
|
+
self._data = frozendict(b)
|
|
@@ -178,14 +178,18 @@ class PreParser(Copyable):
|
|
|
178
178
|
for param in cmd.params:
|
|
179
179
|
if not isinstance(param, cl.Option):
|
|
180
180
|
continue
|
|
181
|
-
if param.is_flag
|
|
181
|
+
if param.is_flag:
|
|
182
182
|
nargs = Nargs.NO_ARGUMENT
|
|
183
|
-
elif param.nargs
|
|
184
|
-
nargs = Nargs.
|
|
185
|
-
|
|
183
|
+
elif not param.nargs:
|
|
184
|
+
nargs = Nargs.NO_ARGUMENT
|
|
185
|
+
elif param.flag_value is not None:
|
|
186
186
|
nargs = Nargs.OPTIONAL_ARGUMENT
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
elif param.prompt and not param.prompt_required:
|
|
188
|
+
nargs = Nargs.OPTIONAL_ARGUMENT
|
|
189
|
+
else:
|
|
190
|
+
nargs = Nargs.REQUIRED_ARGUMENT
|
|
191
|
+
for opt in param.opts + param.secondary_opts:
|
|
192
|
+
optdict[opt] = nargs
|
|
189
193
|
self.optdict.clear()
|
|
190
194
|
self.optdict.update(optdict)
|
|
191
195
|
|
|
@@ -2,6 +2,7 @@ import enum
|
|
|
2
2
|
import math
|
|
3
3
|
import tomllib
|
|
4
4
|
import unittest
|
|
5
|
+
from functools import cached_property
|
|
5
6
|
from importlib import resources
|
|
6
7
|
from typing import Any, Self
|
|
7
8
|
|
|
@@ -13,13 +14,11 @@ __all__ = ["TestDataToml"]
|
|
|
13
14
|
class Utils(enum.Enum):
|
|
14
15
|
utils = None
|
|
15
16
|
|
|
16
|
-
@
|
|
17
|
-
def
|
|
17
|
+
@cached_property
|
|
18
|
+
def data(self: Self) -> dict[str, Any]:
|
|
18
19
|
text: str
|
|
19
|
-
data: dict[str, Any]
|
|
20
20
|
text = resources.read_text("preparse.tests", "data.toml")
|
|
21
|
-
|
|
22
|
-
return data
|
|
21
|
+
return tomllib.loads(text)
|
|
23
22
|
|
|
24
23
|
@staticmethod
|
|
25
24
|
def istestable(x: Any) -> bool:
|
|
@@ -33,11 +32,9 @@ class Utils(enum.Enum):
|
|
|
33
32
|
class TestDataToml(unittest.TestCase):
|
|
34
33
|
|
|
35
34
|
def test_0(self: Self) -> None:
|
|
36
|
-
data: dict[str, Any]
|
|
37
35
|
name: str
|
|
38
36
|
kwargs: dict[str, Any]
|
|
39
|
-
|
|
40
|
-
for name, kwargs in data.items():
|
|
37
|
+
for name, kwargs in Utils.utils.data.items():
|
|
41
38
|
with self.subTest(msg=name, **kwargs):
|
|
42
39
|
self.parse(**kwargs)
|
|
43
40
|
|
|
@@ -2,6 +2,7 @@ import enum
|
|
|
2
2
|
import math
|
|
3
3
|
import tomllib
|
|
4
4
|
import unittest
|
|
5
|
+
from functools import cached_property
|
|
5
6
|
from importlib import resources
|
|
6
7
|
from typing import Any, Self
|
|
7
8
|
|
|
@@ -15,13 +16,11 @@ __all__ = ["TestMainFunction"]
|
|
|
15
16
|
class Utils(enum.Enum):
|
|
16
17
|
utils = None
|
|
17
18
|
|
|
18
|
-
@
|
|
19
|
-
def
|
|
20
|
-
data: dict[Any, Any]
|
|
19
|
+
@cached_property
|
|
20
|
+
def data(self: Self) -> dict[str, Any]:
|
|
21
21
|
text: str
|
|
22
22
|
text = resources.read_text("preparse.tests", "expit.toml")
|
|
23
|
-
|
|
24
|
-
return data
|
|
23
|
+
return tomllib.loads(text)
|
|
25
24
|
|
|
26
25
|
@staticmethod
|
|
27
26
|
def istestable(x: Any) -> bool:
|
|
@@ -64,11 +63,9 @@ class TestMainFunction(unittest.TestCase):
|
|
|
64
63
|
self.assertEqual(stderr, result.stderr)
|
|
65
64
|
|
|
66
65
|
def test_0(self: Self) -> None:
|
|
67
|
-
data: dict[Any, Any]
|
|
68
66
|
kwargs: dict[Any, Any]
|
|
69
67
|
name: str
|
|
70
|
-
|
|
71
|
-
for name, kwargs in data.items():
|
|
68
|
+
for name, kwargs in Utils.utils.data.items():
|
|
72
69
|
with self.subTest(msg=name, **kwargs):
|
|
73
70
|
self.parse(**kwargs)
|
|
74
71
|
|
|
@@ -1,12 +1,28 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
import tomllib
|
|
1
3
|
import unittest
|
|
2
|
-
from
|
|
4
|
+
from functools import cached_property
|
|
5
|
+
from importlib import resources
|
|
6
|
+
from typing import Any, Self
|
|
3
7
|
|
|
8
|
+
from preparse._tests.secondary import secondary
|
|
4
9
|
from preparse.core.Optdict import Optdict
|
|
10
|
+
from preparse.core.PreParser import PreParser
|
|
5
11
|
from preparse.enums.Nargs import Nargs
|
|
6
12
|
|
|
7
13
|
__all__ = ["TestPreparse"]
|
|
8
14
|
|
|
9
15
|
|
|
16
|
+
class Utils(enum.Enum):
|
|
17
|
+
utils = None
|
|
18
|
+
|
|
19
|
+
@cached_property
|
|
20
|
+
def data(sefl: Self) -> dict[str, Any]:
|
|
21
|
+
text: str
|
|
22
|
+
text = resources.read_text("preparse.tests", "secondary.toml")
|
|
23
|
+
return tomllib.loads(text)
|
|
24
|
+
|
|
25
|
+
|
|
10
26
|
class TestPreparse(unittest.TestCase):
|
|
11
27
|
|
|
12
28
|
def test_optdict_copy(self: Self) -> None:
|
|
@@ -25,6 +41,15 @@ class TestPreparse(unittest.TestCase):
|
|
|
25
41
|
self.assertEqual(repr(original), str(original))
|
|
26
42
|
self.assertEqual(repr(original), format(original))
|
|
27
43
|
|
|
44
|
+
def test_secondary(self: Self) -> None:
|
|
45
|
+
parser: PreParser
|
|
46
|
+
parser = PreParser()
|
|
47
|
+
parser.reflectClickCommand(secondary)
|
|
48
|
+
self.assertEqual(
|
|
49
|
+
tuple(parser.optdict.items()),
|
|
50
|
+
tuple(Utils.utils.data["optdict"].items()),
|
|
51
|
+
)
|
|
52
|
+
|
|
28
53
|
|
|
29
54
|
if __name__ == "__main__":
|
|
30
55
|
unittest.main()
|
|
@@ -26,6 +26,7 @@ src/preparse/_processing/parsing.py
|
|
|
26
26
|
src/preparse/_processing/pulling.py
|
|
27
27
|
src/preparse/_tests/__init__.py
|
|
28
28
|
src/preparse/_tests/expit.py
|
|
29
|
+
src/preparse/_tests/secondary.py
|
|
29
30
|
src/preparse/core/Click.py
|
|
30
31
|
src/preparse/core/Optdict.py
|
|
31
32
|
src/preparse/core/PreParser.py
|
|
@@ -37,6 +38,7 @@ src/preparse/enums/__init__.py
|
|
|
37
38
|
src/preparse/tests/__init__.py
|
|
38
39
|
src/preparse/tests/data.toml
|
|
39
40
|
src/preparse/tests/expit.toml
|
|
41
|
+
src/preparse/tests/secondary.toml
|
|
40
42
|
src/preparse/tests/test_data_toml.py
|
|
41
43
|
src/preparse/tests/test_enums.py
|
|
42
44
|
src/preparse/tests/test_expit_toml.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{preparse-1.1.9 → preparse-1.1.11}/src/preparse/warnings/PreparseUnallowedArgumentWarning.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|