preparse 1.0.13.post0__tar.gz → 1.0.13.post1.dev0__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.0.13.post0 → preparse-1.0.13.post1.dev0}/PKG-INFO +1 -1
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/docs/v1.0.rst +6 -6
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/pyproject.toml +1 -1
- preparse-1.0.13.post1.dev0/src/preparse/__init__.py +33 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/_items/Bundle.py +8 -8
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/_items/Item.py +7 -7
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/_items/Long.py +9 -9
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/_items/Option.py +7 -7
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/_items/Positional.py +5 -5
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/_items/Special.py +5 -5
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/_items/__init__.py +9 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/_processing/__init__.py +13 -12
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/_processing/deparsing.py +1 -3
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/_processing/digesting.py +11 -5
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/_processing/parsing.py +15 -9
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/_processing/pulling.py +6 -5
- preparse-1.0.13.post1.dev0/src/preparse/_utils/__init__.py +3 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/_utils/dataprop.py +6 -4
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/core/Click.py +5 -4
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/core/Optdict.py +16 -9
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/core/PreParser.py +20 -13
- preparse-1.0.13.post1.dev0/src/preparse/core/__init__.py +26 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/core/enums.py +4 -7
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/core/warnings.py +17 -16
- preparse-1.0.13.post1.dev0/src/preparse/py.typed +0 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/tests/__init__.py +3 -3
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/tests/test_data_toml.py +24 -11
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/tests/test_enums.py +4 -4
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/tests/test_expit_toml.py +24 -11
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/tests/test_optdict.py +12 -6
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/tests/test_preparser.py +12 -6
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse.egg-info/PKG-INFO +1 -1
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse.egg-info/SOURCES.txt +1 -0
- preparse-1.0.13.post0/src/preparse/__init__.py +0 -2
- preparse-1.0.13.post0/src/preparse/_utils/__init__.py +0 -1
- preparse-1.0.13.post0/src/preparse/core/__init__.py +0 -5
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/LICENSE.txt +0 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/MANIFEST.in +0 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/README.rst +0 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/setup.cfg +0 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/tests/data.toml +0 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse/tests/expit.toml +0 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse.egg-info/dependency_links.txt +0 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse.egg-info/requires.txt +0 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse.egg-info/top_level.txt +0 -0
|
@@ -56,8 +56,8 @@ Features
|
|
|
56
56
|
The PreParser class
|
|
57
57
|
~~~~~~~~~~~~~~~~~~~
|
|
58
58
|
|
|
59
|
-
``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)``
|
|
60
|
-
|
|
59
|
+
``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[..., Any] = str)``
|
|
60
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
61
61
|
|
|
62
62
|
This class is the centerpiece of the preparse. Its behaviour follows the principles of getopt from C.
|
|
63
63
|
|
|
@@ -111,8 +111,8 @@ Options not found within the dictionary
|
|
|
111
111
|
cause a ``preparse.PreparseInvalidOptionWarning``
|
|
112
112
|
and are then assumed to have no arguments.
|
|
113
113
|
|
|
114
|
-
``parse_args(args:
|
|
115
|
-
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
114
|
+
``parse_args(args: Iterable[Any] | None = None) -> list[str]``
|
|
115
|
+
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
116
116
|
|
|
117
117
|
This method is at the core of the class.
|
|
118
118
|
It returns a preparsed list of arguments.
|
|
@@ -148,8 +148,8 @@ Concretely the prog property is changed.
|
|
|
148
148
|
|
|
149
149
|
This ``preparse.Tuning`` property determines the approach to the special argument ``'--'``.
|
|
150
150
|
|
|
151
|
-
``todict() -> dict``
|
|
152
|
-
""""""""""""""""""""
|
|
151
|
+
``todict() -> dict[str, Any]``
|
|
152
|
+
""""""""""""""""""""""""""""""
|
|
153
153
|
|
|
154
154
|
This method a dict representing the current instance.
|
|
155
155
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
__all__: list[str] = [
|
|
2
|
+
"Click",
|
|
3
|
+
"Nargs",
|
|
4
|
+
"Optdict",
|
|
5
|
+
"PreParser",
|
|
6
|
+
"PreparseAmbiguousOptionWarning",
|
|
7
|
+
"PreparseInvalidOptionWarning",
|
|
8
|
+
"PreparseRequiredArgumentWarning",
|
|
9
|
+
"PreparseUnallowedArgumentWarning",
|
|
10
|
+
"PreparseWarning",
|
|
11
|
+
"Tuning",
|
|
12
|
+
"core",
|
|
13
|
+
"enums",
|
|
14
|
+
"test",
|
|
15
|
+
"tests",
|
|
16
|
+
"warnings",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
from preparse.core import (
|
|
20
|
+
Click,
|
|
21
|
+
Nargs,
|
|
22
|
+
Optdict,
|
|
23
|
+
PreparseAmbiguousOptionWarning,
|
|
24
|
+
PreparseInvalidOptionWarning,
|
|
25
|
+
PreParser,
|
|
26
|
+
PreparseRequiredArgumentWarning,
|
|
27
|
+
PreparseUnallowedArgumentWarning,
|
|
28
|
+
PreparseWarning,
|
|
29
|
+
Tuning,
|
|
30
|
+
enums,
|
|
31
|
+
warnings,
|
|
32
|
+
)
|
|
33
|
+
from preparse.tests import test
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
__all__: list[str] = ["Bundle"]
|
|
2
|
+
|
|
3
|
+
from typing import Any, Self
|
|
2
4
|
|
|
3
5
|
import setdoc
|
|
4
6
|
|
|
5
7
|
from preparse._items.Item import Item
|
|
6
8
|
from preparse._items.Option import Option
|
|
7
9
|
from preparse._utils.dataprop import dataprop
|
|
8
|
-
from preparse.core.enums import
|
|
9
|
-
|
|
10
|
-
__all__ = ["Bundle"]
|
|
10
|
+
from preparse.core.enums import Nargs, Tuning
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class Bundle(Option):
|
|
@@ -15,7 +15,7 @@ class Bundle(Option):
|
|
|
15
15
|
chars: str
|
|
16
16
|
joined: bool
|
|
17
17
|
nargs: Nargs
|
|
18
|
-
right:
|
|
18
|
+
right: str | None
|
|
19
19
|
|
|
20
20
|
__slots__ = ()
|
|
21
21
|
|
|
@@ -25,14 +25,14 @@ class Bundle(Option):
|
|
|
25
25
|
*,
|
|
26
26
|
chars: str,
|
|
27
27
|
joined: bool = False,
|
|
28
|
-
right:
|
|
28
|
+
right: str | None = None,
|
|
29
29
|
) -> None:
|
|
30
30
|
self.chars = chars
|
|
31
31
|
self.joined = joined
|
|
32
32
|
self.right = right
|
|
33
33
|
|
|
34
34
|
@classmethod
|
|
35
|
-
def _split_allowslong(cls: type, chars: str) -> list[str]:
|
|
35
|
+
def _split_allowslong(cls: type[Self], chars: str) -> list[str]:
|
|
36
36
|
ans: list[str]
|
|
37
37
|
x: str
|
|
38
38
|
ans = list()
|
|
@@ -44,7 +44,7 @@ class Bundle(Option):
|
|
|
44
44
|
return ans
|
|
45
45
|
|
|
46
46
|
@classmethod
|
|
47
|
-
def _split_shortonly(cls: type, chars: str) -> list[str]:
|
|
47
|
+
def _split_shortonly(cls: type[Self], chars: str) -> list[str]:
|
|
48
48
|
ans: list[str]
|
|
49
49
|
x: str
|
|
50
50
|
ans = list()
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
__all__: list[str] = ["Item"]
|
|
2
|
+
|
|
1
3
|
import abc
|
|
2
|
-
from typing import
|
|
4
|
+
from typing import Any, Self
|
|
3
5
|
|
|
4
6
|
import setdoc
|
|
5
7
|
from copyable import Copyable
|
|
6
8
|
|
|
7
|
-
from preparse.core.enums import
|
|
8
|
-
|
|
9
|
-
__all__ = ["Item"]
|
|
9
|
+
from preparse.core.enums import Nargs, Tuning
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class Item(Copyable):
|
|
@@ -21,11 +21,11 @@ class Item(Copyable):
|
|
|
21
21
|
|
|
22
22
|
@classmethod
|
|
23
23
|
@abc.abstractmethod
|
|
24
|
-
def sortkey(cls: type) -> int: ...
|
|
24
|
+
def sortkey(cls: type[Self]) -> int: ...
|
|
25
25
|
|
|
26
|
-
def todict(self: Self) -> dict:
|
|
26
|
+
def todict(self: Self) -> dict[str, Any]:
|
|
27
27
|
"This method returns a dict representing the current instance."
|
|
28
|
-
ans: dict
|
|
28
|
+
ans: dict[str, Any]
|
|
29
29
|
try:
|
|
30
30
|
ans = self._data
|
|
31
31
|
except AttributeError:
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
+
__all__: list[str] = ["Long"]
|
|
2
|
+
|
|
1
3
|
import operator
|
|
2
|
-
from typing import
|
|
4
|
+
from typing import Any, Self, SupportsIndex
|
|
3
5
|
|
|
4
6
|
import setdoc
|
|
5
7
|
|
|
6
8
|
from preparse._items.Option import Option
|
|
7
9
|
from preparse._utils.dataprop import dataprop
|
|
8
|
-
from preparse.core.enums import
|
|
9
|
-
|
|
10
|
-
__all__ = ["Long"]
|
|
10
|
+
from preparse.core.enums import Nargs, Tuning
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class Long(Option):
|
|
14
14
|
|
|
15
15
|
abbr: str
|
|
16
|
-
abbrlen:
|
|
16
|
+
abbrlen: int | None
|
|
17
17
|
fullkey: str
|
|
18
18
|
joined: bool
|
|
19
19
|
nargs: Nargs
|
|
20
|
-
right:
|
|
20
|
+
right: str | None
|
|
21
21
|
|
|
22
22
|
__slots__ = ()
|
|
23
23
|
|
|
@@ -25,10 +25,10 @@ class Long(Option):
|
|
|
25
25
|
def __init__(
|
|
26
26
|
self: Self,
|
|
27
27
|
*,
|
|
28
|
+
abbrlen: int | None = None,
|
|
28
29
|
fullkey: str,
|
|
29
|
-
abbrlen: Optional[int] = None,
|
|
30
30
|
joined: bool | str = False,
|
|
31
|
-
right:
|
|
31
|
+
right: str | None = None,
|
|
32
32
|
) -> None:
|
|
33
33
|
self.fullkey = fullkey
|
|
34
34
|
self.abbrlen = abbrlen
|
|
@@ -40,7 +40,7 @@ class Long(Option):
|
|
|
40
40
|
return self.fullkey[: self.abbrlen]
|
|
41
41
|
|
|
42
42
|
@dataprop
|
|
43
|
-
def abbrlen(self: Self, x:
|
|
43
|
+
def abbrlen(self: Self, x: SupportsIndex | None) -> int | None:
|
|
44
44
|
if x is not None:
|
|
45
45
|
return operator.index(x)
|
|
46
46
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
+
__all__: list[str] = ["Option"]
|
|
2
|
+
|
|
1
3
|
import operator
|
|
2
|
-
from typing import
|
|
4
|
+
from typing import Any, Self, SupportsIndex
|
|
3
5
|
|
|
4
6
|
from preparse._items.Item import Item
|
|
5
7
|
from preparse._utils.dataprop import dataprop
|
|
6
|
-
from preparse.core.enums import
|
|
7
|
-
|
|
8
|
-
__all__ = ["Option"]
|
|
8
|
+
from preparse.core.enums import Nargs, Tuning
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class Option(Item):
|
|
12
12
|
|
|
13
13
|
joined: bool
|
|
14
14
|
nargs: Nargs
|
|
15
|
-
right:
|
|
15
|
+
right: str | None
|
|
16
16
|
|
|
17
17
|
__slots__ = ()
|
|
18
18
|
|
|
@@ -28,10 +28,10 @@ class Option(Item):
|
|
|
28
28
|
return Nargs(x)
|
|
29
29
|
|
|
30
30
|
@dataprop
|
|
31
|
-
def right(self: Self, x: Any) ->
|
|
31
|
+
def right(self: Self, x: Any) -> str | None:
|
|
32
32
|
if x is not None:
|
|
33
33
|
return str(x)
|
|
34
34
|
|
|
35
35
|
@classmethod
|
|
36
|
-
def sortkey(cls: type) -> int:
|
|
36
|
+
def sortkey(cls: type[Self]) -> int:
|
|
37
37
|
return 0
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
__all__: list[str] = ["Positional"]
|
|
2
|
+
|
|
3
|
+
from typing import Any, Self
|
|
2
4
|
|
|
3
5
|
import setdoc
|
|
4
6
|
|
|
5
7
|
from preparse._items.Item import Item
|
|
6
8
|
from preparse._utils.dataprop import dataprop
|
|
7
|
-
from preparse.core.enums import
|
|
8
|
-
|
|
9
|
-
__all__ = ["Positional"]
|
|
9
|
+
from preparse.core.enums import Nargs, Tuning
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class Positional(Item):
|
|
@@ -26,7 +26,7 @@ class Positional(Item):
|
|
|
26
26
|
return self.value == "-" or not self.value.startswith("-")
|
|
27
27
|
|
|
28
28
|
@classmethod
|
|
29
|
-
def sortkey(cls: type) -> int:
|
|
29
|
+
def sortkey(cls: type[Self]) -> int:
|
|
30
30
|
return 2
|
|
31
31
|
|
|
32
32
|
@dataprop
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
__all__: list[str] = ["Special"]
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
from preparse.core.enums import *
|
|
3
|
+
from typing import Self
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
from preparse._items.Item import Item
|
|
6
|
+
from preparse.core.enums import Nargs, Tuning
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class Special(Item):
|
|
@@ -14,5 +14,5 @@ class Special(Item):
|
|
|
14
14
|
return ["--"]
|
|
15
15
|
|
|
16
16
|
@classmethod
|
|
17
|
-
def sortkey(cls: type) -> int:
|
|
17
|
+
def sortkey(cls: type[Self]) -> int:
|
|
18
18
|
return 1
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
from typing import *
|
|
1
|
+
__all__: list[str] = ["process"]
|
|
3
2
|
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from
|
|
7
|
-
from preparse._processing.parsing import *
|
|
8
|
-
from preparse._processing.pulling import *
|
|
9
|
-
from preparse._utils import *
|
|
10
|
-
from preparse.core.enums import *
|
|
3
|
+
from collections.abc import Iterable
|
|
4
|
+
from types import FunctionType
|
|
5
|
+
from typing import Any
|
|
11
6
|
|
|
12
|
-
|
|
7
|
+
from preparse._items import Bundle, Item, Long, Option, Positional, Special
|
|
8
|
+
from preparse._processing.deparsing import deparse
|
|
9
|
+
from preparse._processing.digesting import digest
|
|
10
|
+
from preparse._processing.parsing import parse
|
|
11
|
+
from preparse._processing.pulling import pull
|
|
12
|
+
from preparse._utils import dataprop
|
|
13
|
+
from preparse.core.enums import Nargs, Tuning
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
def process(
|
|
16
|
-
args:
|
|
17
|
+
args: Iterable[Any] | None = None,
|
|
17
18
|
*,
|
|
18
19
|
allowslong: bool,
|
|
19
20
|
allowsshort: bool,
|
|
@@ -21,7 +22,7 @@ def process(
|
|
|
21
22
|
expandsabbr: bool,
|
|
22
23
|
expectsabbr: bool,
|
|
23
24
|
expectsposix: bool,
|
|
24
|
-
optdict: dict,
|
|
25
|
+
optdict: dict[str, Nargs],
|
|
25
26
|
prog: str,
|
|
26
27
|
reconcilesorders: bool,
|
|
27
28
|
special: Tuning,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
__all__: list[str] = ["digest"]
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
2
4
|
|
|
3
5
|
from preparse._items.Bundle import Bundle
|
|
4
6
|
from preparse._items.Item import Item
|
|
@@ -6,10 +8,14 @@ from preparse._items.Long import Long
|
|
|
6
8
|
from preparse._items.Option import Option
|
|
7
9
|
from preparse._items.Positional import Positional
|
|
8
10
|
from preparse._items.Special import Special
|
|
9
|
-
from preparse.core.enums import
|
|
10
|
-
from preparse.core.warnings import
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
from preparse.core.enums import Nargs, Tuning
|
|
12
|
+
from preparse.core.warnings import (
|
|
13
|
+
PreparseAmbiguousOptionWarning,
|
|
14
|
+
PreparseInvalidOptionWarning,
|
|
15
|
+
PreparseRequiredArgumentWarning,
|
|
16
|
+
PreparseUnallowedArgumentWarning,
|
|
17
|
+
PreparseWarning,
|
|
18
|
+
)
|
|
13
19
|
|
|
14
20
|
|
|
15
21
|
def digest(
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
__all__: list[str] = ["parse"]
|
|
2
|
+
|
|
3
|
+
from collections.abc import Generator, Iterable
|
|
1
4
|
from types import FunctionType
|
|
2
|
-
from typing import
|
|
5
|
+
from typing import Any
|
|
3
6
|
|
|
4
7
|
from preparse._items.Bundle import Bundle
|
|
5
8
|
from preparse._items.Item import Item
|
|
@@ -8,9 +11,12 @@ from preparse._items.Option import Option
|
|
|
8
11
|
from preparse._items.Positional import Positional
|
|
9
12
|
from preparse._items.Special import Special
|
|
10
13
|
from preparse.core import warnings
|
|
11
|
-
from preparse.core.enums import
|
|
14
|
+
from preparse.core.enums import Nargs, Tuning
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
PAOW: type[Any]
|
|
17
|
+
PIOW: type[Any]
|
|
18
|
+
PRAW: type[Any]
|
|
19
|
+
PUAW: type[Any]
|
|
14
20
|
|
|
15
21
|
PAOW = warnings.PreparseAmbiguousOptionWarning
|
|
16
22
|
PIOW = warnings.PreparseInvalidOptionWarning
|
|
@@ -26,7 +32,7 @@ def parse_bundling(
|
|
|
26
32
|
arg: str,
|
|
27
33
|
*,
|
|
28
34
|
cause: FunctionType,
|
|
29
|
-
optdict: dict,
|
|
35
|
+
optdict: dict[str, Nargs],
|
|
30
36
|
) -> Bundle:
|
|
31
37
|
ans: Bundle
|
|
32
38
|
x: int
|
|
@@ -55,7 +61,7 @@ def parse_cause(
|
|
|
55
61
|
prog: str,
|
|
56
62
|
warn: FunctionType,
|
|
57
63
|
) -> FunctionType:
|
|
58
|
-
def ans(cls: type, **kwargs: Any) -> None:
|
|
64
|
+
def ans(cls: type[Any], **kwargs: Any) -> None:
|
|
59
65
|
warn(cls(prog=prog, **kwargs))
|
|
60
66
|
|
|
61
67
|
return ans
|
|
@@ -68,14 +74,14 @@ def parse_generator(
|
|
|
68
74
|
allowsshort: bool,
|
|
69
75
|
expectsabbr: bool,
|
|
70
76
|
expectsposix: bool,
|
|
71
|
-
optdict: dict,
|
|
77
|
+
optdict: dict[str, Nargs],
|
|
72
78
|
prog: str,
|
|
73
79
|
warn: FunctionType,
|
|
74
80
|
) -> Generator[Any, Any, Any]:
|
|
75
81
|
broken: bool
|
|
76
82
|
cause: FunctionType
|
|
77
|
-
last: Optional[Option]
|
|
78
83
|
item: Positional
|
|
84
|
+
last: Option | None
|
|
79
85
|
broken = not (allowslong or allowsshort)
|
|
80
86
|
cause = parse_cause(prog=prog, warn=warn)
|
|
81
87
|
last = None
|
|
@@ -138,7 +144,7 @@ def parse_long(
|
|
|
138
144
|
*,
|
|
139
145
|
cause: FunctionType,
|
|
140
146
|
expectsabbr: bool,
|
|
141
|
-
optdict: dict,
|
|
147
|
+
optdict: dict[str, Nargs],
|
|
142
148
|
) -> Long:
|
|
143
149
|
ans: Long
|
|
144
150
|
parts: list[str]
|
|
@@ -188,7 +194,7 @@ def parse_option(
|
|
|
188
194
|
*,
|
|
189
195
|
cause: FunctionType,
|
|
190
196
|
expectsabbr: bool,
|
|
191
|
-
optdict: dict,
|
|
197
|
+
optdict: dict[str, Nargs],
|
|
192
198
|
**kwargs: Any,
|
|
193
199
|
) -> Option:
|
|
194
200
|
if parse_islong(arg, **kwargs):
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
__all__: list[str] = ["pull"]
|
|
2
|
+
|
|
1
3
|
import sys
|
|
2
|
-
from
|
|
4
|
+
from collections.abc import Iterable
|
|
5
|
+
from typing import Any
|
|
3
6
|
|
|
4
7
|
from preparse._items.Positional import Positional
|
|
5
8
|
|
|
6
|
-
__all__ = ["pull"]
|
|
7
|
-
|
|
8
9
|
|
|
9
|
-
def pull(args:
|
|
10
|
+
def pull(args: Iterable[Any] | None = None) -> list[Positional]:
|
|
10
11
|
"This method acquires args."
|
|
11
|
-
argiter: Iterable
|
|
12
|
+
argiter: Iterable[Any]
|
|
12
13
|
if args is None:
|
|
13
14
|
argiter = sys.argv[1:]
|
|
14
15
|
else:
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
__all__: list[str] = ["dataprop"]
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
from collections.abc import Callable
|
|
4
|
+
from typing import Any, Self
|
|
4
5
|
|
|
5
6
|
|
|
6
|
-
def dataprop(func: Callable) -> property:
|
|
7
|
+
def dataprop(func: Callable[..., Any]) -> property:
|
|
7
8
|
"This magic method implements calling the current instance."
|
|
8
9
|
|
|
10
|
+
kwargs: dict[str, Any]
|
|
11
|
+
|
|
9
12
|
def fget(self: Self) -> Any:
|
|
10
13
|
return self._data[func.__name__]
|
|
11
14
|
|
|
@@ -13,7 +16,6 @@ def dataprop(func: Callable) -> property:
|
|
|
13
16
|
self._data = getattr(self, "_data", dict())
|
|
14
17
|
self._data[func.__name__] = func(self, value)
|
|
15
18
|
|
|
16
|
-
kwargs: dict[str, Any]
|
|
17
19
|
kwargs = dict()
|
|
18
20
|
kwargs["doc"] = func.__doc__
|
|
19
21
|
kwargs["fget"] = fget
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
__all__: list[str] = ["Click"]
|
|
4
|
+
|
|
3
5
|
import dataclasses
|
|
4
6
|
import functools
|
|
5
7
|
import types
|
|
6
|
-
from
|
|
8
|
+
from collections.abc import Callable
|
|
9
|
+
from typing import TYPE_CHECKING, Any, Self
|
|
7
10
|
|
|
8
11
|
import overloadable
|
|
9
12
|
import setdoc
|
|
@@ -12,8 +15,6 @@ from copyable import Copyable
|
|
|
12
15
|
if TYPE_CHECKING:
|
|
13
16
|
from .PreParser import PreParser
|
|
14
17
|
|
|
15
|
-
__all__ = ["Click"]
|
|
16
|
-
|
|
17
18
|
|
|
18
19
|
@dataclasses.dataclass
|
|
19
20
|
class Click(Copyable):
|
|
@@ -47,7 +48,7 @@ class Click(Copyable):
|
|
|
47
48
|
|
|
48
49
|
@__call__.overload("method")
|
|
49
50
|
def __call__(self: Self, target: types.MethodType) -> types.MethodType:
|
|
50
|
-
func: Callable
|
|
51
|
+
func: Callable[..., Any]
|
|
51
52
|
func = self(target.__func__)
|
|
52
53
|
return types.MethodType(func, target.__self__)
|
|
53
54
|
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
__all__: list[str] = ["Optdict"]
|
|
2
|
+
|
|
3
|
+
from collections.abc import Iterator
|
|
4
|
+
from typing import Any, Self
|
|
2
5
|
|
|
3
6
|
import cmp3
|
|
4
7
|
import datahold
|
|
@@ -6,10 +9,14 @@ import setdoc
|
|
|
6
9
|
from datarepr import datarepr
|
|
7
10
|
from frozendict import frozendict
|
|
8
11
|
|
|
9
|
-
from preparse.core.enums import
|
|
10
|
-
from preparse.core.warnings import
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
from preparse.core.enums import Nargs, Tuning
|
|
13
|
+
from preparse.core.warnings import (
|
|
14
|
+
PreparseAmbiguousOptionWarning,
|
|
15
|
+
PreparseInvalidOptionWarning,
|
|
16
|
+
PreparseRequiredArgumentWarning,
|
|
17
|
+
PreparseUnallowedArgumentWarning,
|
|
18
|
+
PreparseWarning,
|
|
19
|
+
)
|
|
13
20
|
|
|
14
21
|
|
|
15
22
|
class Optdict(cmp3.CmpABC, datahold.HoldDict[str, Nargs]):
|
|
@@ -18,7 +25,7 @@ class Optdict(cmp3.CmpABC, datahold.HoldDict[str, Nargs]):
|
|
|
18
25
|
data: frozendict[str, Nargs]
|
|
19
26
|
|
|
20
27
|
@setdoc.basic
|
|
21
|
-
def __cmp__(self: Self, other: Any, /) ->
|
|
28
|
+
def __cmp__(self: Self, other: Any, /) -> int | None:
|
|
22
29
|
if type(self) is type(other):
|
|
23
30
|
return cmp3.cmp(self._data, other._data, mode="eq_strict")
|
|
24
31
|
else:
|
|
@@ -38,9 +45,9 @@ class Optdict(cmp3.CmpABC, datahold.HoldDict[str, Nargs]):
|
|
|
38
45
|
|
|
39
46
|
@data.setter
|
|
40
47
|
def data(self: Self, value: Any) -> None:
|
|
41
|
-
a: frozendict
|
|
42
|
-
x:
|
|
43
|
-
y:
|
|
48
|
+
a: frozendict[str, Nargs]
|
|
49
|
+
x: Iterator[str]
|
|
50
|
+
y: Iterator[Nargs]
|
|
44
51
|
a = frozendict(value)
|
|
45
52
|
x = map(str, a.keys())
|
|
46
53
|
y = map(Nargs, a.values())
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
__all__: list[str] = ["PreParser"]
|
|
4
|
+
|
|
3
5
|
import os
|
|
4
6
|
import sys
|
|
5
7
|
import types
|
|
6
|
-
from
|
|
8
|
+
from collections.abc import Callable, Iterable
|
|
9
|
+
from typing import Any, Self
|
|
7
10
|
|
|
8
11
|
import click as cl
|
|
9
12
|
import setdoc
|
|
@@ -11,14 +14,18 @@ from copyable import Copyable
|
|
|
11
14
|
from datarepr import datarepr
|
|
12
15
|
from tofunc import tofunc
|
|
13
16
|
|
|
14
|
-
from preparse._processing import
|
|
17
|
+
from preparse._processing import process
|
|
15
18
|
from preparse._utils.dataprop import dataprop
|
|
16
19
|
from preparse.core.Click import Click
|
|
17
|
-
from preparse.core.enums import
|
|
18
|
-
from preparse.core.Optdict import
|
|
19
|
-
from preparse.core.warnings import
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
from preparse.core.enums import Nargs, Tuning
|
|
21
|
+
from preparse.core.Optdict import Optdict
|
|
22
|
+
from preparse.core.warnings import (
|
|
23
|
+
PreparseAmbiguousOptionWarning,
|
|
24
|
+
PreparseInvalidOptionWarning,
|
|
25
|
+
PreparseRequiredArgumentWarning,
|
|
26
|
+
PreparseUnallowedArgumentWarning,
|
|
27
|
+
PreparseWarning,
|
|
28
|
+
)
|
|
22
29
|
|
|
23
30
|
|
|
24
31
|
class PreParser(Copyable):
|
|
@@ -51,7 +58,7 @@ class PreParser(Copyable):
|
|
|
51
58
|
prog: Any = None,
|
|
52
59
|
reconcilesorders: Any = True,
|
|
53
60
|
special: Any = Tuning.MAINTAIN,
|
|
54
|
-
warn: Callable = str,
|
|
61
|
+
warn: Callable[..., Any] = str,
|
|
55
62
|
) -> None:
|
|
56
63
|
self.allowslong = allowslong
|
|
57
64
|
self.allowsshort = allowsshort
|
|
@@ -118,7 +125,7 @@ class PreParser(Copyable):
|
|
|
118
125
|
|
|
119
126
|
def parse_args(
|
|
120
127
|
self: Self,
|
|
121
|
-
args:
|
|
128
|
+
args: Iterable[Any] | None = None,
|
|
122
129
|
) -> list[str]:
|
|
123
130
|
"This method parses args."
|
|
124
131
|
return process(args, **self.todict())
|
|
@@ -137,9 +144,9 @@ class PreParser(Copyable):
|
|
|
137
144
|
|
|
138
145
|
def reflectClickCommand(self: Self, cmd: cl.Command) -> None:
|
|
139
146
|
"This method causes the current instance to reflect a click.Command object."
|
|
140
|
-
optdict: dict[str, Nargs]
|
|
141
147
|
nargs: Nargs
|
|
142
148
|
opt: Any
|
|
149
|
+
optdict: dict[str, Nargs]
|
|
143
150
|
param: Any
|
|
144
151
|
optdict = dict()
|
|
145
152
|
for param in cmd.params:
|
|
@@ -165,9 +172,9 @@ class PreParser(Copyable):
|
|
|
165
172
|
"This Tuning property determines the approach towards the special argument."
|
|
166
173
|
return Tuning(value)
|
|
167
174
|
|
|
168
|
-
def todict(self: Self) -> dict:
|
|
175
|
+
def todict(self: Self) -> dict[str, Any]:
|
|
169
176
|
"This method returns a dict representing the current instance."
|
|
170
|
-
ans: dict
|
|
177
|
+
ans: dict[str, Any]
|
|
171
178
|
try:
|
|
172
179
|
ans = self._data
|
|
173
180
|
except AttributeError:
|
|
@@ -177,6 +184,6 @@ class PreParser(Copyable):
|
|
|
177
184
|
return dict(ans)
|
|
178
185
|
|
|
179
186
|
@dataprop
|
|
180
|
-
def warn(self: Self, value: Callable) -> types.FunctionType:
|
|
187
|
+
def warn(self: Self, value: Callable[..., Any]) -> types.FunctionType:
|
|
181
188
|
"This property gives a function that takes in the warnings."
|
|
182
189
|
return tofunc(value)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
__all__: list[str] = [
|
|
2
|
+
"Click",
|
|
3
|
+
"Nargs",
|
|
4
|
+
"Optdict",
|
|
5
|
+
"PreParser",
|
|
6
|
+
"PreparseAmbiguousOptionWarning",
|
|
7
|
+
"PreparseInvalidOptionWarning",
|
|
8
|
+
"PreparseRequiredArgumentWarning",
|
|
9
|
+
"PreparseUnallowedArgumentWarning",
|
|
10
|
+
"PreparseWarning",
|
|
11
|
+
"Tuning",
|
|
12
|
+
"enums",
|
|
13
|
+
"warnings",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
from preparse.core.Click import Click
|
|
17
|
+
from preparse.core.enums import Nargs, Tuning
|
|
18
|
+
from preparse.core.Optdict import Optdict
|
|
19
|
+
from preparse.core.PreParser import PreParser
|
|
20
|
+
from preparse.core.warnings import (
|
|
21
|
+
PreparseAmbiguousOptionWarning,
|
|
22
|
+
PreparseInvalidOptionWarning,
|
|
23
|
+
PreparseRequiredArgumentWarning,
|
|
24
|
+
PreparseUnallowedArgumentWarning,
|
|
25
|
+
PreparseWarning,
|
|
26
|
+
)
|
|
@@ -3,18 +3,15 @@ Following the precedent of getopt, \
|
|
|
3
3
|
the value of two represents always an intermediary answer \
|
|
4
4
|
between the values zero, meaning no, and one, meaning yes."""
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
from typing import *
|
|
6
|
+
__all__: list[str] = ["Nargs", "Tuning"]
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"Nargs",
|
|
12
|
-
]
|
|
8
|
+
import enum
|
|
9
|
+
from typing import Any, Self
|
|
13
10
|
|
|
14
11
|
|
|
15
12
|
class BaseEnum(enum.IntEnum):
|
|
16
13
|
@classmethod
|
|
17
|
-
def _missing_(cls: type, value: Any) -> Self:
|
|
14
|
+
def _missing_(cls: type[Self], value: Any) -> Self:
|
|
18
15
|
return cls(2)
|
|
19
16
|
|
|
20
17
|
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
from typing import *
|
|
3
|
-
|
|
4
|
-
import setdoc
|
|
5
|
-
from copyable import Copyable
|
|
6
|
-
from datarepr import datarepr
|
|
7
|
-
|
|
8
|
-
from preparse._utils import *
|
|
9
|
-
|
|
10
|
-
__all__ = [
|
|
1
|
+
__all__: list[str] = [
|
|
11
2
|
"PreparseAmbiguousOptionWarning",
|
|
12
3
|
"PreparseInvalidOptionWarning",
|
|
13
4
|
"PreparseRequiredArgumentWarning",
|
|
@@ -15,6 +6,16 @@ __all__ = [
|
|
|
15
6
|
"PreparseWarning",
|
|
16
7
|
]
|
|
17
8
|
|
|
9
|
+
from abc import abstractmethod
|
|
10
|
+
from collections.abc import Iterable
|
|
11
|
+
from typing import Any, Self
|
|
12
|
+
|
|
13
|
+
import setdoc
|
|
14
|
+
from copyable import Copyable
|
|
15
|
+
from datarepr import datarepr
|
|
16
|
+
|
|
17
|
+
from preparse._utils import dataprop
|
|
18
|
+
|
|
18
19
|
|
|
19
20
|
class PreparseWarning(Warning, Copyable):
|
|
20
21
|
args: tuple[str]
|
|
@@ -49,9 +50,9 @@ class PreparseWarning(Warning, Copyable):
|
|
|
49
50
|
def prog(self: Self, value: Any) -> str:
|
|
50
51
|
return str(value)
|
|
51
52
|
|
|
52
|
-
def todict(self: Self) -> dict:
|
|
53
|
+
def todict(self: Self) -> dict[str, Any]:
|
|
53
54
|
"This method returns a dict representing the current instance."
|
|
54
|
-
ans: dict
|
|
55
|
+
ans: dict[str, Any]
|
|
55
56
|
try:
|
|
56
57
|
ans = self._data
|
|
57
58
|
except AttributeError:
|
|
@@ -68,7 +69,7 @@ class PreparseDualWarning(PreparseWarning):
|
|
|
68
69
|
prog: str
|
|
69
70
|
|
|
70
71
|
@setdoc.basic
|
|
71
|
-
def __init__(self: Self, *,
|
|
72
|
+
def __init__(self: Self, *, islong: Any, option: Any, prog: Any) -> None:
|
|
72
73
|
self.prog = prog
|
|
73
74
|
self.option = option
|
|
74
75
|
self.islong = islong
|
|
@@ -116,7 +117,7 @@ class PreparseAmbiguousOptionWarning(PreparseLongonlyWarning):
|
|
|
116
117
|
|
|
117
118
|
@setdoc.basic
|
|
118
119
|
def __init__(
|
|
119
|
-
self: Self, *,
|
|
120
|
+
self: Self, *, option: Any, possibilities: Iterable[Any], prog: Any
|
|
120
121
|
) -> None:
|
|
121
122
|
self.prog = prog
|
|
122
123
|
self.option = option
|
|
@@ -132,7 +133,7 @@ class PreparseAmbiguousOptionWarning(PreparseLongonlyWarning):
|
|
|
132
133
|
return ans
|
|
133
134
|
|
|
134
135
|
@dataprop
|
|
135
|
-
def possibilities(self: Self, value: Iterable) -> tuple[str, ...]:
|
|
136
|
+
def possibilities(self: Self, value: Iterable[Any]) -> tuple[str, ...]:
|
|
136
137
|
return tuple(map(str, value))
|
|
137
138
|
|
|
138
139
|
|
|
@@ -143,7 +144,7 @@ class PreparseUnallowedArgumentWarning(PreparseLongonlyWarning):
|
|
|
143
144
|
# option is always full key without value
|
|
144
145
|
|
|
145
146
|
@setdoc.basic
|
|
146
|
-
def __init__(self: Self, *,
|
|
147
|
+
def __init__(self: Self, *, option: Any, prog: Any) -> None:
|
|
147
148
|
self.prog = prog
|
|
148
149
|
self.option = option
|
|
149
150
|
|
|
File without changes
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
__all__: list[str] = ["test"]
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import unittest
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
def test() -> unittest.TextTestResult:
|
|
7
7
|
"This function runs all the tests."
|
|
8
8
|
loader: unittest.TestLoader
|
|
9
|
-
tests: unittest.TestSuite
|
|
10
9
|
runner: unittest.TextTestRunner
|
|
10
|
+
tests: unittest.TestSuite
|
|
11
11
|
loader = unittest.TestLoader()
|
|
12
12
|
tests = loader.discover(start_dir="preparse.tests")
|
|
13
13
|
runner = unittest.TextTestRunner()
|
|
@@ -1,18 +1,31 @@
|
|
|
1
|
+
__all__: list[str] = ["TestDataToml"]
|
|
2
|
+
|
|
1
3
|
import math
|
|
2
4
|
import tomllib
|
|
3
5
|
import unittest
|
|
4
6
|
from importlib import resources
|
|
5
|
-
from typing import
|
|
6
|
-
|
|
7
|
-
from preparse.core import *
|
|
7
|
+
from typing import Any, Self
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
from preparse.core import (
|
|
10
|
+
Click,
|
|
11
|
+
Nargs,
|
|
12
|
+
Optdict,
|
|
13
|
+
PreparseAmbiguousOptionWarning,
|
|
14
|
+
PreparseInvalidOptionWarning,
|
|
15
|
+
PreParser,
|
|
16
|
+
PreparseRequiredArgumentWarning,
|
|
17
|
+
PreparseUnallowedArgumentWarning,
|
|
18
|
+
PreparseWarning,
|
|
19
|
+
Tuning,
|
|
20
|
+
enums,
|
|
21
|
+
warnings,
|
|
22
|
+
)
|
|
10
23
|
|
|
11
24
|
|
|
12
25
|
class utils:
|
|
13
26
|
def get_data() -> dict[str, Any]:
|
|
14
|
-
text: str
|
|
15
27
|
data: dict[str, Any]
|
|
28
|
+
text: str
|
|
16
29
|
text = resources.read_text("preparse.tests", "data.toml")
|
|
17
30
|
data = tomllib.loads(text)
|
|
18
31
|
return data
|
|
@@ -29,8 +42,8 @@ class TestDataToml(unittest.TestCase):
|
|
|
29
42
|
|
|
30
43
|
def test_0(self: Self) -> None:
|
|
31
44
|
data: dict[str, Any]
|
|
45
|
+
kwargs: dict[str, Any]
|
|
32
46
|
name: str
|
|
33
|
-
kwargs: dict
|
|
34
47
|
data = utils.get_data()
|
|
35
48
|
for name, kwargs in data.items():
|
|
36
49
|
with self.subTest(msg=name, **kwargs):
|
|
@@ -44,13 +57,13 @@ class TestDataToml(unittest.TestCase):
|
|
|
44
57
|
warnings: Any,
|
|
45
58
|
**kwargs: Any,
|
|
46
59
|
) -> None:
|
|
47
|
-
answer: list
|
|
48
|
-
capture: list
|
|
49
|
-
data: dict
|
|
50
|
-
erranswer: list
|
|
60
|
+
answer: list[str]
|
|
61
|
+
capture: list[str]
|
|
62
|
+
data: dict[str, Any]
|
|
63
|
+
erranswer: list[str]
|
|
51
64
|
msg: str
|
|
52
|
-
superanswer: list
|
|
53
65
|
parser: PreParser
|
|
66
|
+
superanswer: list[str]
|
|
54
67
|
capture = list()
|
|
55
68
|
|
|
56
69
|
def warn(value: Any) -> None:
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
from typing import *
|
|
1
|
+
__all__: list[str] = ["TestEnums"]
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
import unittest
|
|
4
|
+
from typing import Self
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
from preparse.core.enums import Nargs, Tuning
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class TestEnums(unittest.TestCase):
|
|
@@ -1,15 +1,28 @@
|
|
|
1
|
+
__all__: list[str] = ["TestMainFunction"]
|
|
2
|
+
|
|
1
3
|
import math
|
|
2
4
|
import tomllib
|
|
3
5
|
import unittest
|
|
4
6
|
from importlib import resources
|
|
5
|
-
from typing import
|
|
7
|
+
from typing import Any, Self
|
|
6
8
|
|
|
7
9
|
import click
|
|
8
10
|
from click.testing import CliRunner
|
|
9
11
|
|
|
10
|
-
from preparse.core import
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
from preparse.core import (
|
|
13
|
+
Click,
|
|
14
|
+
Nargs,
|
|
15
|
+
Optdict,
|
|
16
|
+
PreparseAmbiguousOptionWarning,
|
|
17
|
+
PreparseInvalidOptionWarning,
|
|
18
|
+
PreParser,
|
|
19
|
+
PreparseRequiredArgumentWarning,
|
|
20
|
+
PreparseUnallowedArgumentWarning,
|
|
21
|
+
PreparseWarning,
|
|
22
|
+
Tuning,
|
|
23
|
+
enums,
|
|
24
|
+
warnings,
|
|
25
|
+
)
|
|
13
26
|
|
|
14
27
|
|
|
15
28
|
class expit:
|
|
@@ -33,8 +46,8 @@ class expit:
|
|
|
33
46
|
|
|
34
47
|
|
|
35
48
|
class utils:
|
|
36
|
-
def get_data() -> dict:
|
|
37
|
-
data: dict
|
|
49
|
+
def get_data() -> dict[str, Any]:
|
|
50
|
+
data: dict[str, Any]
|
|
38
51
|
text: str
|
|
39
52
|
text = resources.read_text("preparse.tests", "expit.toml")
|
|
40
53
|
data = tomllib.loads(text)
|
|
@@ -53,14 +66,14 @@ class TestMainFunction(unittest.TestCase):
|
|
|
53
66
|
def parse(
|
|
54
67
|
self: Self,
|
|
55
68
|
*,
|
|
56
|
-
query: Any,
|
|
57
69
|
exit_code: Any,
|
|
58
70
|
output: Any,
|
|
59
71
|
prog: Any,
|
|
60
|
-
|
|
72
|
+
query: Any,
|
|
61
73
|
stderr: Any,
|
|
74
|
+
stdout: Any,
|
|
62
75
|
) -> None:
|
|
63
|
-
extra: dict
|
|
76
|
+
extra: dict[str, Any]
|
|
64
77
|
result: Any
|
|
65
78
|
runner: CliRunner
|
|
66
79
|
runner = CliRunner()
|
|
@@ -80,8 +93,8 @@ class TestMainFunction(unittest.TestCase):
|
|
|
80
93
|
self.assertEqual(stderr, result.stderr)
|
|
81
94
|
|
|
82
95
|
def test_0(self: Self) -> None:
|
|
83
|
-
data: dict
|
|
84
|
-
kwargs: dict
|
|
96
|
+
data: dict[str, Any]
|
|
97
|
+
kwargs: dict[str, Any]
|
|
85
98
|
name: str
|
|
86
99
|
data = utils.get_data()
|
|
87
100
|
for name, kwargs in data.items():
|
|
@@ -1,18 +1,24 @@
|
|
|
1
|
+
__all__: list[str] = ["TestPreparse"]
|
|
2
|
+
|
|
1
3
|
import unittest
|
|
2
|
-
from typing import
|
|
4
|
+
from typing import Self
|
|
3
5
|
|
|
4
|
-
from preparse.core.enums import
|
|
6
|
+
from preparse.core.enums import Nargs, Tuning
|
|
5
7
|
from preparse.core.Optdict import Optdict
|
|
6
|
-
from preparse.core.warnings import
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
from preparse.core.warnings import (
|
|
9
|
+
PreparseAmbiguousOptionWarning,
|
|
10
|
+
PreparseInvalidOptionWarning,
|
|
11
|
+
PreparseRequiredArgumentWarning,
|
|
12
|
+
PreparseUnallowedArgumentWarning,
|
|
13
|
+
PreparseWarning,
|
|
14
|
+
)
|
|
9
15
|
|
|
10
16
|
|
|
11
17
|
class TestPreparse(unittest.TestCase):
|
|
12
18
|
|
|
13
19
|
def test_optdict_copy(self: Self) -> None:
|
|
14
|
-
original: Optdict
|
|
15
20
|
dublicate: Optdict
|
|
21
|
+
original: Optdict
|
|
16
22
|
original = Optdict({"--foo": 0, "-bar": 1})
|
|
17
23
|
dublicate = original.copy()
|
|
18
24
|
self.assertEqual(original, dublicate)
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
__all__: list[str] = ["TestPreparse"]
|
|
2
|
+
|
|
1
3
|
import unittest
|
|
2
|
-
from typing import
|
|
4
|
+
from typing import Any, Self
|
|
3
5
|
|
|
4
6
|
from preparse.core.Click import Click
|
|
5
|
-
from preparse.core.enums import
|
|
7
|
+
from preparse.core.enums import Nargs, Tuning
|
|
6
8
|
from preparse.core.PreParser import PreParser
|
|
7
|
-
from preparse.core.warnings import
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
from preparse.core.warnings import (
|
|
10
|
+
PreparseAmbiguousOptionWarning,
|
|
11
|
+
PreparseInvalidOptionWarning,
|
|
12
|
+
PreparseRequiredArgumentWarning,
|
|
13
|
+
PreparseUnallowedArgumentWarning,
|
|
14
|
+
PreparseWarning,
|
|
15
|
+
)
|
|
10
16
|
|
|
11
17
|
|
|
12
18
|
class TestPreParser(unittest.TestCase):
|
|
@@ -29,7 +35,7 @@ class TestPreParser(unittest.TestCase):
|
|
|
29
35
|
self.assertEqual(parser.optdict, parser_copy.optdict)
|
|
30
36
|
|
|
31
37
|
def test_preparser_todict(self: Self) -> None:
|
|
32
|
-
expected_keys: list
|
|
38
|
+
expected_keys: list[str]
|
|
33
39
|
parser: PreParser
|
|
34
40
|
result: Any
|
|
35
41
|
parser = PreParser()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from preparse._utils.dataprop import *
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{preparse-1.0.13.post0 → preparse-1.0.13.post1.dev0}/src/preparse.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|