preparse 1.0.13.post0__tar.gz → 1.0.13.post1.dev1__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.dev1}/PKG-INFO +1 -1
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/docs/v1.0.rst +6 -6
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/pyproject.toml +1 -1
- preparse-1.0.13.post1.dev1/src/preparse/__init__.py +33 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/_items/Bundle.py +16 -12
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/_items/Item.py +7 -7
- preparse-1.0.13.post1.dev1/src/preparse/_items/Long.py +68 -0
- preparse-1.0.13.post1.dev1/src/preparse/_items/Option.py +53 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/_items/Positional.py +13 -9
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/_items/Special.py +5 -5
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/_items/__init__.py +9 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/_processing/__init__.py +12 -12
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/_processing/deparsing.py +1 -3
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/_processing/digesting.py +11 -5
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/_processing/parsing.py +15 -9
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/_processing/pulling.py +6 -5
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/core/Click.py +5 -4
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/core/Optdict.py +16 -9
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/core/PreParser.py +111 -48
- preparse-1.0.13.post1.dev1/src/preparse/core/__init__.py +26 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/core/enums.py +4 -7
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/core/warnings.py +46 -27
- preparse-1.0.13.post1.dev1/src/preparse/py.typed +0 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/tests/__init__.py +3 -3
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/tests/test_data_toml.py +24 -11
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/tests/test_enums.py +4 -4
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/tests/test_expit_toml.py +24 -11
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/tests/test_optdict.py +12 -6
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/tests/test_preparser.py +12 -6
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse.egg-info/PKG-INFO +1 -1
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse.egg-info/SOURCES.txt +1 -2
- preparse-1.0.13.post0/src/preparse/__init__.py +0 -2
- preparse-1.0.13.post0/src/preparse/_items/Long.py +0 -57
- preparse-1.0.13.post0/src/preparse/_items/Option.py +0 -37
- preparse-1.0.13.post0/src/preparse/_utils/__init__.py +0 -1
- preparse-1.0.13.post0/src/preparse/_utils/dataprop.py +0 -21
- preparse-1.0.13.post0/src/preparse/core/__init__.py +0 -5
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/LICENSE.txt +0 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/MANIFEST.in +0 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/README.rst +0 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/setup.cfg +0 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/tests/data.toml +0 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse/tests/expit.toml +0 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse.egg-info/dependency_links.txt +0 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/src/preparse.egg-info/requires.txt +0 -0
- {preparse-1.0.13.post0 → preparse-1.0.13.post1.dev1}/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,12 @@
|
|
|
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
|
-
from preparse.
|
|
8
|
-
from preparse.core.enums import *
|
|
9
|
-
|
|
10
|
-
__all__ = ["Bundle"]
|
|
9
|
+
from preparse.core.enums import Nargs, Tuning
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
class Bundle(Option):
|
|
@@ -15,7 +14,7 @@ class Bundle(Option):
|
|
|
15
14
|
chars: str
|
|
16
15
|
joined: bool
|
|
17
16
|
nargs: Nargs
|
|
18
|
-
right:
|
|
17
|
+
right: str | None
|
|
19
18
|
|
|
20
19
|
__slots__ = ()
|
|
21
20
|
|
|
@@ -25,14 +24,14 @@ class Bundle(Option):
|
|
|
25
24
|
*,
|
|
26
25
|
chars: str,
|
|
27
26
|
joined: bool = False,
|
|
28
|
-
right:
|
|
27
|
+
right: str | None = None,
|
|
29
28
|
) -> None:
|
|
30
29
|
self.chars = chars
|
|
31
30
|
self.joined = joined
|
|
32
31
|
self.right = right
|
|
33
32
|
|
|
34
33
|
@classmethod
|
|
35
|
-
def _split_allowslong(cls: type, chars: str) -> list[str]:
|
|
34
|
+
def _split_allowslong(cls: type[Self], chars: str) -> list[str]:
|
|
36
35
|
ans: list[str]
|
|
37
36
|
x: str
|
|
38
37
|
ans = list()
|
|
@@ -44,7 +43,7 @@ class Bundle(Option):
|
|
|
44
43
|
return ans
|
|
45
44
|
|
|
46
45
|
@classmethod
|
|
47
|
-
def _split_shortonly(cls: type, chars: str) -> list[str]:
|
|
46
|
+
def _split_shortonly(cls: type[Self], chars: str) -> list[str]:
|
|
48
47
|
ans: list[str]
|
|
49
48
|
x: str
|
|
50
49
|
ans = list()
|
|
@@ -61,9 +60,14 @@ class Bundle(Option):
|
|
|
61
60
|
x = x[:-1]
|
|
62
61
|
return ans
|
|
63
62
|
|
|
64
|
-
@
|
|
65
|
-
def chars(self: Self
|
|
66
|
-
return
|
|
63
|
+
@property
|
|
64
|
+
def chars(self: Self) -> str:
|
|
65
|
+
return self._data["chars"]
|
|
66
|
+
|
|
67
|
+
@chars.setter
|
|
68
|
+
def chars(self: Self, x: Any) -> None:
|
|
69
|
+
self._data = getattr(self, "_data", dict())
|
|
70
|
+
self._data["chars"] = str(x)
|
|
67
71
|
|
|
68
72
|
def deparse(self: Self) -> list[str]:
|
|
69
73
|
if self.right is None:
|
|
@@ -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:
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
__all__: list[str] = ["Long"]
|
|
2
|
+
|
|
3
|
+
import operator
|
|
4
|
+
from typing import Any, Self, SupportsIndex
|
|
5
|
+
|
|
6
|
+
import setdoc
|
|
7
|
+
|
|
8
|
+
from preparse._items.Option import Option
|
|
9
|
+
from preparse.core.enums import Nargs, Tuning
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Long(Option):
|
|
13
|
+
|
|
14
|
+
abbr: str
|
|
15
|
+
abbrlen: int | None
|
|
16
|
+
fullkey: str
|
|
17
|
+
joined: bool
|
|
18
|
+
nargs: Nargs
|
|
19
|
+
right: str | None
|
|
20
|
+
|
|
21
|
+
__slots__ = ()
|
|
22
|
+
|
|
23
|
+
@setdoc.basic
|
|
24
|
+
def __init__(
|
|
25
|
+
self: Self,
|
|
26
|
+
*,
|
|
27
|
+
abbrlen: int | None = None,
|
|
28
|
+
fullkey: str,
|
|
29
|
+
joined: bool | str = False,
|
|
30
|
+
right: str | None = None,
|
|
31
|
+
) -> None:
|
|
32
|
+
self.fullkey = fullkey
|
|
33
|
+
self.abbrlen = abbrlen
|
|
34
|
+
self.joined = joined
|
|
35
|
+
self.right = right
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def abbr(self: Self) -> str:
|
|
39
|
+
return self.fullkey[: self.abbrlen]
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
def abbrlen(self: Self) -> int | None:
|
|
43
|
+
return self._data["abbrlen"]
|
|
44
|
+
|
|
45
|
+
@abbrlen.setter
|
|
46
|
+
def abbrlen(self: Self, x: SupportsIndex | None) -> None:
|
|
47
|
+
self._data = getattr(self, "_data", dict())
|
|
48
|
+
if x is not None:
|
|
49
|
+
self._data["abbrlen"] = operator.index(x)
|
|
50
|
+
else:
|
|
51
|
+
self._data["abbrlen"] = None
|
|
52
|
+
|
|
53
|
+
def deparse(self: Self) -> list[str]:
|
|
54
|
+
if self.right is None:
|
|
55
|
+
return [self.abbr]
|
|
56
|
+
elif self.joined:
|
|
57
|
+
return [self.abbr + "=" + self.right]
|
|
58
|
+
else:
|
|
59
|
+
return [self.abbr, self.right]
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def fullkey(self: Self) -> str:
|
|
63
|
+
return self._data["fullkey"]
|
|
64
|
+
|
|
65
|
+
@fullkey.setter
|
|
66
|
+
def fullkey(self: Self, x: Any) -> None:
|
|
67
|
+
self._data = getattr(self, "_data", dict())
|
|
68
|
+
self._data["fullkey"] = str(x)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
__all__: list[str] = ["Option"]
|
|
2
|
+
|
|
3
|
+
import operator
|
|
4
|
+
from typing import Any, Self, SupportsIndex
|
|
5
|
+
|
|
6
|
+
from preparse._items.Item import Item
|
|
7
|
+
from preparse.core.enums import Nargs, Tuning
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Option(Item):
|
|
11
|
+
|
|
12
|
+
joined: bool
|
|
13
|
+
nargs: Nargs
|
|
14
|
+
right: str | None
|
|
15
|
+
|
|
16
|
+
__slots__ = ()
|
|
17
|
+
|
|
18
|
+
def ishungry(self: Self) -> bool:
|
|
19
|
+
return (self.right is None) and (self.nargs == Nargs.REQUIRED_ARGUMENT)
|
|
20
|
+
|
|
21
|
+
@property
|
|
22
|
+
def joined(self: Self) -> bool:
|
|
23
|
+
return self._data["joined"]
|
|
24
|
+
|
|
25
|
+
@joined.setter
|
|
26
|
+
def joined(self: Self, x: SupportsIndex) -> None:
|
|
27
|
+
self._data = getattr(self, "_data", dict())
|
|
28
|
+
self._data["joined"] = bool(operator.index(x))
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def nargs(self: Self) -> Nargs:
|
|
32
|
+
return self._data["nargs"]
|
|
33
|
+
|
|
34
|
+
@nargs.setter
|
|
35
|
+
def nargs(self: Self, x: Any) -> None:
|
|
36
|
+
self._data = getattr(self, "_data", dict())
|
|
37
|
+
self._data["nargs"] = Nargs(x)
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def right(self: Self) -> str | None:
|
|
41
|
+
return self._data["right"]
|
|
42
|
+
|
|
43
|
+
@right.setter
|
|
44
|
+
def right(self: Self, x: Any) -> None:
|
|
45
|
+
self._data = getattr(self, "_data", dict())
|
|
46
|
+
if x is not None:
|
|
47
|
+
self._data["right"] = str(x)
|
|
48
|
+
else:
|
|
49
|
+
self._data["right"] = None
|
|
50
|
+
|
|
51
|
+
@classmethod
|
|
52
|
+
def sortkey(cls: type[Self]) -> int:
|
|
53
|
+
return 0
|
|
@@ -1,12 +1,11 @@
|
|
|
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
|
-
from preparse.
|
|
7
|
-
from preparse.core.enums import *
|
|
8
|
-
|
|
9
|
-
__all__ = ["Positional"]
|
|
8
|
+
from preparse.core.enums import Nargs, Tuning
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
class Positional(Item):
|
|
@@ -26,9 +25,14 @@ class Positional(Item):
|
|
|
26
25
|
return self.value == "-" or not self.value.startswith("-")
|
|
27
26
|
|
|
28
27
|
@classmethod
|
|
29
|
-
def sortkey(cls: type) -> int:
|
|
28
|
+
def sortkey(cls: type[Self]) -> int:
|
|
30
29
|
return 2
|
|
31
30
|
|
|
32
|
-
@
|
|
33
|
-
def value(self: Self
|
|
34
|
-
return
|
|
31
|
+
@property
|
|
32
|
+
def value(self: Self) -> str:
|
|
33
|
+
return self._data["value"]
|
|
34
|
+
|
|
35
|
+
@value.setter
|
|
36
|
+
def value(self: Self, x: Any) -> None:
|
|
37
|
+
self._data = getattr(self, "_data", dict())
|
|
38
|
+
self._data["value"] = str(x)
|
|
@@ -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,19 @@
|
|
|
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.core.enums import Nargs, Tuning
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
def process(
|
|
16
|
-
args:
|
|
16
|
+
args: Iterable[Any] | None = None,
|
|
17
17
|
*,
|
|
18
18
|
allowslong: bool,
|
|
19
19
|
allowsshort: bool,
|
|
@@ -21,7 +21,7 @@ def process(
|
|
|
21
21
|
expandsabbr: bool,
|
|
22
22
|
expectsabbr: bool,
|
|
23
23
|
expectsposix: bool,
|
|
24
|
-
optdict: dict,
|
|
24
|
+
optdict: dict[str, Nargs],
|
|
25
25
|
prog: str,
|
|
26
26
|
reconcilesorders: bool,
|
|
27
27
|
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,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())
|