preparse 1.0.11__tar.gz → 2.0.0.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.11/src/preparse.egg-info → preparse-2.0.0.dev0}/PKG-INFO +2 -2
- {preparse-1.0.11 → preparse-2.0.0.dev0}/pyproject.toml +2 -2
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/_processing/digesting.py +0 -1
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/_processing/parsing.py +4 -6
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/core/Optdict.py +0 -1
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/core/PreParser.py +3 -3
- preparse-2.0.0.dev0/src/preparse/core/PreparseWarning.py +6 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/core/__init__.py +0 -1
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/tests/test_optdict.py +0 -1
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/tests/test_preparser.py +0 -1
- preparse-2.0.0.dev0/src/preparse/warners/AmbiguousOptionWarner.py +38 -0
- preparse-2.0.0.dev0/src/preparse/warners/DualWarner.py +33 -0
- preparse-2.0.0.dev0/src/preparse/warners/InvalidOptionWarner.py +14 -0
- preparse-2.0.0.dev0/src/preparse/warners/LongonlyWarner.py +13 -0
- preparse-2.0.0.dev0/src/preparse/warners/RequiredArgumentWarner.py +14 -0
- preparse-2.0.0.dev0/src/preparse/warners/UnallowedArgumentWarner.py +25 -0
- preparse-2.0.0.dev0/src/preparse/warners/WarnerABC.py +60 -0
- preparse-2.0.0.dev0/src/preparse/warners/__init__.py +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0/src/preparse.egg-info}/PKG-INFO +2 -2
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse.egg-info/SOURCES.txt +10 -2
- preparse-1.0.11/src/preparse/core/warnings.py +0 -152
- {preparse-1.0.11 → preparse-2.0.0.dev0}/LICENSE.txt +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/MANIFEST.in +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/README.rst +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/docs/v1.0.rst +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/setup.cfg +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/__init__.py +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/_items/Bundle.py +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/_items/Item.py +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/_items/Long.py +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/_items/Option.py +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/_items/Positional.py +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/_items/Special.py +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/_items/__init__.py +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/_processing/__init__.py +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/_processing/deparsing.py +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/_processing/pulling.py +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/_utils/__init__.py +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/_utils/dataprop.py +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/core/Click.py +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/core/enums.py +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/tests/__init__.py +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/tests/data.toml +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/tests/expit.toml +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/tests/test_data_toml.py +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/tests/test_enums.py +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse/tests/test_expit_toml.py +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse.egg-info/dependency_links.txt +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse.egg-info/requires.txt +0 -0
- {preparse-1.0.11 → preparse-2.0.0.dev0}/src/preparse.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: preparse
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0.dev0
|
|
4
4
|
Summary: This project preparses args for further parsing later on.
|
|
5
5
|
Author-email: Johannes <johannes.programming@gmail.com>
|
|
6
6
|
License: The MIT License (MIT)
|
|
@@ -28,7 +28,7 @@ Project-URL: Download, https://pypi.org/project/preparse/#files
|
|
|
28
28
|
Project-URL: Index, https://pypi.org/project/preparse/
|
|
29
29
|
Project-URL: Source, https://github.com/johannes-programming/preparse/
|
|
30
30
|
Project-URL: Website, https://preparse.johannes-programming.online/
|
|
31
|
-
Classifier: Development Status ::
|
|
31
|
+
Classifier: Development Status :: 3 - Alpha
|
|
32
32
|
Classifier: License :: OSI Approved :: MIT License
|
|
33
33
|
Classifier: Natural Language :: English
|
|
34
34
|
Classifier: Operating System :: OS Independent
|
|
@@ -9,7 +9,7 @@ authors = [
|
|
|
9
9
|
{ email = "johannes.programming@gmail.com", name = "Johannes" },
|
|
10
10
|
]
|
|
11
11
|
classifiers = [
|
|
12
|
-
"Development Status ::
|
|
12
|
+
"Development Status :: 3 - Alpha",
|
|
13
13
|
"License :: OSI Approved :: MIT License",
|
|
14
14
|
"Natural Language :: English",
|
|
15
15
|
"Operating System :: OS Independent",
|
|
@@ -34,7 +34,7 @@ keywords = []
|
|
|
34
34
|
name = "preparse"
|
|
35
35
|
readme = "README.rst"
|
|
36
36
|
requires-python = ">=3.11"
|
|
37
|
-
version = "
|
|
37
|
+
version = "2.0.0.dev0"
|
|
38
38
|
|
|
39
39
|
[project.license]
|
|
40
40
|
file = "LICENSE.txt"
|
|
@@ -7,16 +7,14 @@ 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.core import warnings
|
|
11
10
|
from preparse.core.enums import *
|
|
11
|
+
from preparse.warners.AmbiguousOptionWarner import AmbiguousOptionWarner as PAOW
|
|
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
|
|
12
15
|
|
|
13
16
|
__all__ = ["parse"]
|
|
14
17
|
|
|
15
|
-
PAOW = warnings.PreparseAmbiguousOptionWarning
|
|
16
|
-
PIOW = warnings.PreparseInvalidOptionWarning
|
|
17
|
-
PUAW = warnings.PreparseUnallowedArgumentWarning
|
|
18
|
-
PRAW = warnings.PreparseRequiredArgumentWarning
|
|
19
|
-
|
|
20
18
|
|
|
21
19
|
def parse(args: list[str], **kwargs: Any) -> list[Item]:
|
|
22
20
|
return list(parse_generator(args, **kwargs))
|
|
@@ -16,7 +16,7 @@ from preparse._utils.dataprop import dataprop
|
|
|
16
16
|
from preparse.core.Click import Click
|
|
17
17
|
from preparse.core.enums import *
|
|
18
18
|
from preparse.core.Optdict import *
|
|
19
|
-
from preparse.
|
|
19
|
+
from preparse.warners import *
|
|
20
20
|
|
|
21
21
|
__all__ = ["PreParser"]
|
|
22
22
|
|
|
@@ -33,7 +33,7 @@ class PreParser(Copyable):
|
|
|
33
33
|
prog: str
|
|
34
34
|
reconcilesorders: bool
|
|
35
35
|
special: Tuning
|
|
36
|
-
warn:
|
|
36
|
+
warn: Callable
|
|
37
37
|
|
|
38
38
|
__slots__ = ("_data",)
|
|
39
39
|
|
|
@@ -51,7 +51,7 @@ class PreParser(Copyable):
|
|
|
51
51
|
prog: Any = None,
|
|
52
52
|
reconcilesorders: Any = True,
|
|
53
53
|
special: Any = Tuning.MAINTAIN,
|
|
54
|
-
warn:
|
|
54
|
+
warn: types.FunctionType = str,
|
|
55
55
|
) -> None:
|
|
56
56
|
self.allowslong = allowslong
|
|
57
57
|
self.allowsshort = allowsshort
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from abc import abstractmethod
|
|
2
|
+
from typing import *
|
|
3
|
+
|
|
4
|
+
import setdoc
|
|
5
|
+
|
|
6
|
+
from preparse._utils import *
|
|
7
|
+
from preparse.warners.LongonlyWarner import LongonlyWarner
|
|
8
|
+
|
|
9
|
+
__all__ = ["AmbiguousOptionWarner"]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class AmbiguousOptionWarner(LongonlyWarner):
|
|
13
|
+
__slots__ = ()
|
|
14
|
+
args: tuple[str]
|
|
15
|
+
option: str
|
|
16
|
+
possibilities: tuple[str, ...]
|
|
17
|
+
prog: str
|
|
18
|
+
|
|
19
|
+
@setdoc.basic
|
|
20
|
+
def __init__(
|
|
21
|
+
self: Self, *, prog: Any, option: Any, possibilities: Iterable
|
|
22
|
+
) -> None:
|
|
23
|
+
self.prog = prog
|
|
24
|
+
self.option = option
|
|
25
|
+
self.possibilities = possibilities
|
|
26
|
+
|
|
27
|
+
def getmsg(self: Self) -> str:
|
|
28
|
+
"This method returns the core message."
|
|
29
|
+
ans: str
|
|
30
|
+
x: Any
|
|
31
|
+
ans = "option '%s' is ambiguous; possibilities:" % self.option
|
|
32
|
+
for x in self.possibilities:
|
|
33
|
+
ans += " '%s'" % x
|
|
34
|
+
return ans
|
|
35
|
+
|
|
36
|
+
@dataprop
|
|
37
|
+
def possibilities(self: Self, value: Iterable) -> tuple[str, ...]:
|
|
38
|
+
return tuple(map(str, value))
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from typing import *
|
|
2
|
+
|
|
3
|
+
import setdoc
|
|
4
|
+
|
|
5
|
+
from preparse._utils import *
|
|
6
|
+
from preparse.warners.WarnerABC import WarnerABC
|
|
7
|
+
|
|
8
|
+
__all__ = ["DualWarner"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class DualWarner(WarnerABC):
|
|
12
|
+
__slots__ = ()
|
|
13
|
+
|
|
14
|
+
args: tuple[str]
|
|
15
|
+
option: str
|
|
16
|
+
prog: str
|
|
17
|
+
|
|
18
|
+
@setdoc.basic
|
|
19
|
+
def __init__(self: Self, *, prog: Any, option: Any, islong: Any) -> None:
|
|
20
|
+
self.prog = prog
|
|
21
|
+
self.option = option
|
|
22
|
+
self.islong = islong
|
|
23
|
+
|
|
24
|
+
def getmsg(self: Self) -> str:
|
|
25
|
+
"This method returns the core message."
|
|
26
|
+
if self.islong:
|
|
27
|
+
return type(self)._longmsg % self.option
|
|
28
|
+
else:
|
|
29
|
+
return type(self)._shortmsg % self.option
|
|
30
|
+
|
|
31
|
+
@dataprop
|
|
32
|
+
def islong(self: Self, value: Any) -> bool:
|
|
33
|
+
return bool(value)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from typing import *
|
|
2
|
+
|
|
3
|
+
from preparse.warners.DualWarner import DualWarner
|
|
4
|
+
|
|
5
|
+
__all__ = ["InvalidOptionWarner"]
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class InvalidOptionWarner(DualWarner):
|
|
9
|
+
__slots__ = ()
|
|
10
|
+
args: tuple[str]
|
|
11
|
+
option: str
|
|
12
|
+
prog: str
|
|
13
|
+
_longmsg = "unrecognized option '%s'"
|
|
14
|
+
_shortmsg = "invalid option -- '%s'"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from typing import *
|
|
2
|
+
|
|
3
|
+
from preparse.warners.DualWarner import DualWarner
|
|
4
|
+
|
|
5
|
+
__all__ = ["RequiredArgumentWarner"]
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class RequiredArgumentWarner(DualWarner):
|
|
9
|
+
__slots__ = ()
|
|
10
|
+
args: tuple[str]
|
|
11
|
+
option: str
|
|
12
|
+
prog: str
|
|
13
|
+
_longmsg = "option '%s' requires an argument"
|
|
14
|
+
_shortmsg = "option requires an argument -- '%s'"
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from typing import *
|
|
2
|
+
|
|
3
|
+
import setdoc
|
|
4
|
+
|
|
5
|
+
from preparse._utils import *
|
|
6
|
+
from preparse.warners.LongonlyWarner import LongonlyWarner
|
|
7
|
+
|
|
8
|
+
__all__ = ["UnallowedArgumentWarner"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class UnallowedArgumentWarner(LongonlyWarner):
|
|
12
|
+
__slots__ = ()
|
|
13
|
+
args: tuple[str]
|
|
14
|
+
option: str
|
|
15
|
+
prog: str
|
|
16
|
+
# option is always full key without value
|
|
17
|
+
|
|
18
|
+
@setdoc.basic
|
|
19
|
+
def __init__(self: Self, *, prog: Any, option: Any) -> None:
|
|
20
|
+
self.prog = prog
|
|
21
|
+
self.option = option
|
|
22
|
+
|
|
23
|
+
def getmsg(self: Self) -> str:
|
|
24
|
+
"This method returns the core message."
|
|
25
|
+
return "option '%s' doesn't allow an argument" % self.option
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
from abc import abstractmethod
|
|
2
|
+
from typing import *
|
|
3
|
+
|
|
4
|
+
import setdoc
|
|
5
|
+
from copyable import Copyable
|
|
6
|
+
from datarepr import datarepr
|
|
7
|
+
|
|
8
|
+
from preparse._utils import dataprop
|
|
9
|
+
from preparse.core.PreparseWarning import PreparseWarning
|
|
10
|
+
|
|
11
|
+
__all__ = ["WarnerABC"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class WarnerABC(Copyable):
|
|
15
|
+
__slots__ = ("_data",)
|
|
16
|
+
args: tuple[str]
|
|
17
|
+
option: str
|
|
18
|
+
prog: str
|
|
19
|
+
|
|
20
|
+
@setdoc.basic
|
|
21
|
+
def __repr__(self: Self) -> str:
|
|
22
|
+
return datarepr(type(self).__name__, **self.todict())
|
|
23
|
+
|
|
24
|
+
@setdoc.basic
|
|
25
|
+
def __str__(self: Self) -> str:
|
|
26
|
+
return f"{self.prog}: {self.getmsg()}"
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def args(self: Self) -> tuple[str]:
|
|
30
|
+
"This property returns (str(self),)."
|
|
31
|
+
return (str(self),)
|
|
32
|
+
|
|
33
|
+
@setdoc.basic
|
|
34
|
+
def copy(self: Self) -> Self:
|
|
35
|
+
return type(self)(**self.todict())
|
|
36
|
+
|
|
37
|
+
@abstractmethod
|
|
38
|
+
def getmsg(self: Self) -> str: ...
|
|
39
|
+
|
|
40
|
+
@dataprop
|
|
41
|
+
def option(self: Self, value: Any) -> str:
|
|
42
|
+
return str(value)
|
|
43
|
+
|
|
44
|
+
@dataprop
|
|
45
|
+
def prog(self: Self, value: Any) -> str:
|
|
46
|
+
return str(value)
|
|
47
|
+
|
|
48
|
+
def todict(self: Self) -> dict[str, Any]:
|
|
49
|
+
"This method returns a dict representing the current instance."
|
|
50
|
+
ans: dict
|
|
51
|
+
try:
|
|
52
|
+
ans = self._data
|
|
53
|
+
except AttributeError:
|
|
54
|
+
self._data = dict()
|
|
55
|
+
return dict()
|
|
56
|
+
else:
|
|
57
|
+
return dict(ans)
|
|
58
|
+
|
|
59
|
+
def warning(self: Self) -> PreparseWarning:
|
|
60
|
+
return PreparseWarning(str(self))
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: preparse
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0.dev0
|
|
4
4
|
Summary: This project preparses args for further parsing later on.
|
|
5
5
|
Author-email: Johannes <johannes.programming@gmail.com>
|
|
6
6
|
License: The MIT License (MIT)
|
|
@@ -28,7 +28,7 @@ Project-URL: Download, https://pypi.org/project/preparse/#files
|
|
|
28
28
|
Project-URL: Index, https://pypi.org/project/preparse/
|
|
29
29
|
Project-URL: Source, https://github.com/johannes-programming/preparse/
|
|
30
30
|
Project-URL: Website, https://preparse.johannes-programming.online/
|
|
31
|
-
Classifier: Development Status ::
|
|
31
|
+
Classifier: Development Status :: 3 - Alpha
|
|
32
32
|
Classifier: License :: OSI Approved :: MIT License
|
|
33
33
|
Classifier: Natural Language :: English
|
|
34
34
|
Classifier: Operating System :: OS Independent
|
|
@@ -28,9 +28,9 @@ src/preparse/core/Click.py
|
|
|
28
28
|
src/preparse/core/OptDict.py
|
|
29
29
|
src/preparse/core/Optdict.py
|
|
30
30
|
src/preparse/core/PreParser.py
|
|
31
|
+
src/preparse/core/PreparseWarning.py
|
|
31
32
|
src/preparse/core/__init__.py
|
|
32
33
|
src/preparse/core/enums.py
|
|
33
|
-
src/preparse/core/warnings.py
|
|
34
34
|
src/preparse/tests/__init__.py
|
|
35
35
|
src/preparse/tests/data.toml
|
|
36
36
|
src/preparse/tests/expit.toml
|
|
@@ -38,4 +38,12 @@ src/preparse/tests/test_data_toml.py
|
|
|
38
38
|
src/preparse/tests/test_enums.py
|
|
39
39
|
src/preparse/tests/test_expit_toml.py
|
|
40
40
|
src/preparse/tests/test_optdict.py
|
|
41
|
-
src/preparse/tests/test_preparser.py
|
|
41
|
+
src/preparse/tests/test_preparser.py
|
|
42
|
+
src/preparse/warners/AmbiguousOptionWarner.py
|
|
43
|
+
src/preparse/warners/DualWarner.py
|
|
44
|
+
src/preparse/warners/InvalidOptionWarner.py
|
|
45
|
+
src/preparse/warners/LongonlyWarner.py
|
|
46
|
+
src/preparse/warners/RequiredArgumentWarner.py
|
|
47
|
+
src/preparse/warners/UnallowedArgumentWarner.py
|
|
48
|
+
src/preparse/warners/WarnerABC.py
|
|
49
|
+
src/preparse/warners/__init__.py
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
from abc import abstractmethod
|
|
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__ = [
|
|
11
|
-
"PreparseAmbiguousOptionWarning",
|
|
12
|
-
"PreparseInvalidOptionWarning",
|
|
13
|
-
"PreparseRequiredArgumentWarning",
|
|
14
|
-
"PreparseUnallowedArgumentWarning",
|
|
15
|
-
"PreparseWarning",
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class PreparseWarning(Warning, Copyable):
|
|
20
|
-
args: tuple[str]
|
|
21
|
-
option: str
|
|
22
|
-
prog: str
|
|
23
|
-
|
|
24
|
-
@setdoc.basic
|
|
25
|
-
def __repr__(self: Self) -> str:
|
|
26
|
-
return datarepr(type(self).__name__, **self.todict())
|
|
27
|
-
|
|
28
|
-
@setdoc.basic
|
|
29
|
-
def __str__(self: Self) -> str:
|
|
30
|
-
return f"{self.prog}: {self.getmsg()}"
|
|
31
|
-
|
|
32
|
-
@property
|
|
33
|
-
def args(self: Self) -> tuple[str]:
|
|
34
|
-
"This property returns (str(self),)."
|
|
35
|
-
return (str(self),)
|
|
36
|
-
|
|
37
|
-
@setdoc.basic
|
|
38
|
-
def copy(self: Self) -> Self:
|
|
39
|
-
return type(self)(**self.todict())
|
|
40
|
-
|
|
41
|
-
@abstractmethod
|
|
42
|
-
def getmsg(self: Self) -> str: ...
|
|
43
|
-
|
|
44
|
-
@dataprop
|
|
45
|
-
def option(self: Self, value: Any) -> str:
|
|
46
|
-
return str(value)
|
|
47
|
-
|
|
48
|
-
@dataprop
|
|
49
|
-
def prog(self: Self, value: Any) -> str:
|
|
50
|
-
return str(value)
|
|
51
|
-
|
|
52
|
-
def todict(self: Self) -> dict:
|
|
53
|
-
"This method returns a dict representing the current instance."
|
|
54
|
-
ans: dict
|
|
55
|
-
try:
|
|
56
|
-
ans = self._data
|
|
57
|
-
except AttributeError:
|
|
58
|
-
self._data = dict()
|
|
59
|
-
return dict()
|
|
60
|
-
else:
|
|
61
|
-
return dict(ans)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
class PreparseDualWarning(PreparseWarning):
|
|
65
|
-
|
|
66
|
-
args: tuple[str]
|
|
67
|
-
option: str
|
|
68
|
-
prog: str
|
|
69
|
-
|
|
70
|
-
@setdoc.basic
|
|
71
|
-
def __init__(self: Self, *, prog: Any, option: Any, islong: Any) -> None:
|
|
72
|
-
self.prog = prog
|
|
73
|
-
self.option = option
|
|
74
|
-
self.islong = islong
|
|
75
|
-
|
|
76
|
-
def getmsg(self: Self) -> str:
|
|
77
|
-
"This method returns the core message."
|
|
78
|
-
if self.islong:
|
|
79
|
-
return type(self)._longmsg % self.option
|
|
80
|
-
else:
|
|
81
|
-
return type(self)._shortmsg % self.option
|
|
82
|
-
|
|
83
|
-
@dataprop
|
|
84
|
-
def islong(self: Self, value: Any) -> bool:
|
|
85
|
-
return bool(value)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
class PreparseInvalidOptionWarning(PreparseDualWarning):
|
|
89
|
-
args: tuple[str]
|
|
90
|
-
option: str
|
|
91
|
-
prog: str
|
|
92
|
-
_longmsg = "unrecognized option '%s'"
|
|
93
|
-
_shortmsg = "invalid option -- '%s'"
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
class PreparseRequiredArgumentWarning(PreparseDualWarning):
|
|
97
|
-
args: tuple[str]
|
|
98
|
-
option: str
|
|
99
|
-
prog: str
|
|
100
|
-
_longmsg = "option '%s' requires an argument"
|
|
101
|
-
_shortmsg = "option requires an argument -- '%s'"
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
class PreparseLongonlyWarning(PreparseWarning):
|
|
105
|
-
args: tuple[str]
|
|
106
|
-
option: str
|
|
107
|
-
prog: str
|
|
108
|
-
# only possible for long options
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
class PreparseAmbiguousOptionWarning(PreparseLongonlyWarning):
|
|
112
|
-
args: tuple[str]
|
|
113
|
-
option: str
|
|
114
|
-
possibilities: tuple[str, ...]
|
|
115
|
-
prog: str
|
|
116
|
-
|
|
117
|
-
@setdoc.basic
|
|
118
|
-
def __init__(
|
|
119
|
-
self: Self, *, prog: Any, option: Any, possibilities: Iterable
|
|
120
|
-
) -> None:
|
|
121
|
-
self.prog = prog
|
|
122
|
-
self.option = option
|
|
123
|
-
self.possibilities = possibilities
|
|
124
|
-
|
|
125
|
-
def getmsg(self: Self) -> str:
|
|
126
|
-
"This method returns the core message."
|
|
127
|
-
ans: str
|
|
128
|
-
x: Any
|
|
129
|
-
ans = "option '%s' is ambiguous; possibilities:" % self.option
|
|
130
|
-
for x in self.possibilities:
|
|
131
|
-
ans += " '%s'" % x
|
|
132
|
-
return ans
|
|
133
|
-
|
|
134
|
-
@dataprop
|
|
135
|
-
def possibilities(self: Self, value: Iterable) -> tuple[str, ...]:
|
|
136
|
-
return tuple(map(str, value))
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
class PreparseUnallowedArgumentWarning(PreparseLongonlyWarning):
|
|
140
|
-
args: tuple[str]
|
|
141
|
-
option: str
|
|
142
|
-
prog: str
|
|
143
|
-
# option is always full key without value
|
|
144
|
-
|
|
145
|
-
@setdoc.basic
|
|
146
|
-
def __init__(self: Self, *, prog: Any, option: Any) -> None:
|
|
147
|
-
self.prog = prog
|
|
148
|
-
self.option = option
|
|
149
|
-
|
|
150
|
-
def getmsg(self: Self) -> str:
|
|
151
|
-
"This method returns the core message."
|
|
152
|
-
return "option '%s' doesn't allow an argument" % self.option
|
|
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
|