preparse 1.0.10__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.10/src/preparse.egg-info → preparse-2.0.0.dev0}/PKG-INFO +2 -2
- {preparse-1.0.10 → preparse-2.0.0.dev0}/docs/v1.0.rst +21 -18
- {preparse-1.0.10 → preparse-2.0.0.dev0}/pyproject.toml +2 -2
- {preparse-1.0.10/src/preparse/_processing/items → preparse-2.0.0.dev0/src/preparse/_items}/Bundle.py +2 -2
- {preparse-1.0.10/src/preparse/_processing/items → preparse-2.0.0.dev0/src/preparse/_items}/Long.py +1 -1
- {preparse-1.0.10/src/preparse/_processing/items → preparse-2.0.0.dev0/src/preparse/_items}/Option.py +1 -1
- {preparse-1.0.10/src/preparse/_processing/items → preparse-2.0.0.dev0/src/preparse/_items}/Positional.py +1 -1
- {preparse-1.0.10/src/preparse/_processing/items → preparse-2.0.0.dev0/src/preparse/_items}/Special.py +1 -1
- preparse-2.0.0.dev0/src/preparse/_items/__init__.py +6 -0
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse/_processing/__init__.py +1 -1
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse/_processing/deparsing.py +1 -1
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse/_processing/digesting.py +6 -7
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse/_processing/parsing.py +10 -12
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse/_processing/pulling.py +1 -1
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse/core/Optdict.py +0 -1
- {preparse-1.0.10 → 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.10 → preparse-2.0.0.dev0}/src/preparse/core/__init__.py +0 -1
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse/tests/__init__.py +1 -3
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse/tests/test_optdict.py +0 -3
- {preparse-1.0.10 → 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.10 → preparse-2.0.0.dev0/src/preparse.egg-info}/PKG-INFO +2 -2
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse.egg-info/SOURCES.txt +18 -9
- preparse-1.0.10/src/preparse/_processing/items/__init__.py +0 -6
- preparse-1.0.10/src/preparse/core/warnings.py +0 -152
- {preparse-1.0.10 → preparse-2.0.0.dev0}/LICENSE.txt +0 -0
- {preparse-1.0.10 → preparse-2.0.0.dev0}/MANIFEST.in +0 -0
- {preparse-1.0.10 → preparse-2.0.0.dev0}/README.rst +0 -0
- {preparse-1.0.10 → preparse-2.0.0.dev0}/setup.cfg +0 -0
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse/__init__.py +0 -0
- {preparse-1.0.10/src/preparse/_processing/items → preparse-2.0.0.dev0/src/preparse/_items}/Item.py +0 -0
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse/_utils/__init__.py +0 -0
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse/_utils/dataprop.py +0 -0
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse/core/Click.py +0 -0
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse/core/enums.py +0 -0
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse/tests/data.toml +0 -0
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse/tests/expit.toml +0 -0
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse/tests/test_data_toml.py +0 -0
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse/tests/test_enums.py +0 -0
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse/tests/test_expit_toml.py +0 -0
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse.egg-info/dependency_links.txt +0 -0
- {preparse-1.0.10 → preparse-2.0.0.dev0}/src/preparse.egg-info/requires.txt +0 -0
- {preparse-1.0.10 → 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
|
|
@@ -64,7 +64,7 @@ Features
|
|
|
64
64
|
The PreParser class
|
|
65
65
|
~~~~~~~~~~~~~~~~~~~
|
|
66
66
|
|
|
67
|
-
``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 = Tuning.MAINTAIN, warn: Callable = str)``
|
|
67
|
+
``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)``
|
|
68
68
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
69
69
|
|
|
70
70
|
This class is the centerpiece of the preparse. Its behaviour follows the principles of getopt from C.
|
|
@@ -79,10 +79,10 @@ This boolean property determines whether long options are allowed.
|
|
|
79
79
|
|
|
80
80
|
This boolean property determines whether short options are allowed.
|
|
81
81
|
|
|
82
|
-
``bundling: Tuning``
|
|
83
|
-
""""""""""""""""""""
|
|
82
|
+
``bundling: preparse.Tuning``
|
|
83
|
+
"""""""""""""""""""""""""""""
|
|
84
84
|
|
|
85
|
-
This ``Tuning`` property determines the approach to bundling of short option.
|
|
85
|
+
This ``preparse.Tuning`` property determines the approach to bundling of short option.
|
|
86
86
|
|
|
87
87
|
``click(cmd: Any = True, ctx: Any = True) -> preparse.Click``
|
|
88
88
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
@@ -109,13 +109,15 @@ This boolean property determines whether abbreviations of long options are expec
|
|
|
109
109
|
|
|
110
110
|
This boolean property determines whether the order of arguments to conform to the POSIX standard, i.e. all arguments after the first positional argument also being positonal.
|
|
111
111
|
|
|
112
|
-
``optdict: Optdict``
|
|
113
|
-
""""""""""""""""""""
|
|
112
|
+
``optdict: preparse.Optdict``
|
|
113
|
+
"""""""""""""""""""""""""""""
|
|
114
114
|
|
|
115
|
-
This property holds a
|
|
115
|
+
This property holds a dict-like object.
|
|
116
116
|
Its keys are the options.
|
|
117
|
-
Its values specify ``Nargs``.
|
|
118
|
-
Options not found within the dictionary
|
|
117
|
+
Its values specify ``preparse.Nargs``.
|
|
118
|
+
Options not found within the dictionary
|
|
119
|
+
cause a ``preparse.PreparseInvalidOptionWarning``
|
|
120
|
+
and are then assumed to have no arguments.
|
|
119
121
|
|
|
120
122
|
``parse_args(args: Optional[Iterable] = None) -> list[str]``
|
|
121
123
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
@@ -149,10 +151,10 @@ Concretely the optdict property is changed.
|
|
|
149
151
|
This method alters the current instance to reflect a ``click.Context`` object.
|
|
150
152
|
Concretely the prog property is changed.
|
|
151
153
|
|
|
152
|
-
``special: Tuning``
|
|
153
|
-
"""""""""""""""""""
|
|
154
|
+
``special: preparse.Tuning``
|
|
155
|
+
""""""""""""""""""""""""""""
|
|
154
156
|
|
|
155
|
-
This ``Tuning`` property determines the approach to the special argument ``'--'``.
|
|
157
|
+
This ``preparse.Tuning`` property determines the approach to the special argument ``'--'``.
|
|
156
158
|
|
|
157
159
|
``todict() -> dict``
|
|
158
160
|
""""""""""""""""""""
|
|
@@ -171,8 +173,8 @@ Therefore, ``str`` is used to discard the warnings.
|
|
|
171
173
|
The Click class
|
|
172
174
|
~~~~~~~~~~~~~~~
|
|
173
175
|
|
|
174
|
-
``class preparse.Click(parser:
|
|
175
|
-
|
|
176
|
+
``class preparse.Click(parser: preparse.PreParser, cmd: Any = True, ctx: Any = True)``
|
|
177
|
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
176
178
|
|
|
177
179
|
This dataclass provides decorators for embedding a ``PreParser`` object.
|
|
178
180
|
|
|
@@ -195,8 +197,8 @@ This property determines if the ``reflectClickCommand`` method of parser is to b
|
|
|
195
197
|
|
|
196
198
|
This property determines if the ``reflectClickContext`` method of parser is to be called.
|
|
197
199
|
|
|
198
|
-
``parser:
|
|
199
|
-
"""""""""""""""
|
|
200
|
+
``parser: preparse.PreParser``
|
|
201
|
+
""""""""""""""""""""""""""""""
|
|
200
202
|
|
|
201
203
|
This property holds the parser to be embedded.
|
|
202
204
|
|
|
@@ -206,8 +208,9 @@ The Optdict class
|
|
|
206
208
|
``class preparse.Optdict``
|
|
207
209
|
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
208
210
|
|
|
209
|
-
This class is a subclass of ``datahold.HoldDict
|
|
210
|
-
|
|
211
|
+
This class is a subclass of ``datahold.HoldDict[str, preparse.Nargs]``
|
|
212
|
+
with strings as keys and with ``preparse.Nargs`` as values.
|
|
213
|
+
It is designed for ``preparse.PreParser.optdict``.
|
|
211
214
|
|
|
212
215
|
The Enums
|
|
213
216
|
~~~~~~~~~
|
|
@@ -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"
|
{preparse-1.0.10/src/preparse/_processing/items → preparse-2.0.0.dev0/src/preparse/_items}/Bundle.py
RENAMED
|
@@ -2,8 +2,8 @@ from typing import *
|
|
|
2
2
|
|
|
3
3
|
import setdoc
|
|
4
4
|
|
|
5
|
-
from preparse.
|
|
6
|
-
from preparse.
|
|
5
|
+
from preparse._items.Item import Item
|
|
6
|
+
from preparse._items.Option import Option
|
|
7
7
|
from preparse._utils.dataprop import dataprop
|
|
8
8
|
from preparse.core.enums import *
|
|
9
9
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
from types import FunctionType
|
|
2
2
|
from typing import *
|
|
3
3
|
|
|
4
|
+
from preparse._items import *
|
|
4
5
|
from preparse._processing.deparsing import *
|
|
5
6
|
from preparse._processing.digesting import *
|
|
6
|
-
from preparse._processing.items import *
|
|
7
7
|
from preparse._processing.parsing import *
|
|
8
8
|
from preparse._processing.pulling import *
|
|
9
9
|
from preparse._utils import *
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
from typing import *
|
|
2
2
|
|
|
3
|
-
from preparse.
|
|
4
|
-
from preparse.
|
|
5
|
-
from preparse.
|
|
6
|
-
from preparse.
|
|
7
|
-
from preparse.
|
|
8
|
-
from preparse.
|
|
3
|
+
from preparse._items.Bundle import Bundle
|
|
4
|
+
from preparse._items.Item import Item
|
|
5
|
+
from preparse._items.Long import Long
|
|
6
|
+
from preparse._items.Option import Option
|
|
7
|
+
from preparse._items.Positional import Positional
|
|
8
|
+
from preparse._items.Special import Special
|
|
9
9
|
from preparse.core.enums import *
|
|
10
|
-
from preparse.core.warnings import *
|
|
11
10
|
|
|
12
11
|
__all__ = ["digest"]
|
|
13
12
|
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
from types import FunctionType
|
|
2
2
|
from typing import *
|
|
3
3
|
|
|
4
|
-
from preparse.
|
|
5
|
-
from preparse.
|
|
6
|
-
from preparse.
|
|
7
|
-
from preparse.
|
|
8
|
-
from preparse.
|
|
9
|
-
from preparse.
|
|
10
|
-
from preparse.core import warnings
|
|
4
|
+
from preparse._items.Bundle import Bundle
|
|
5
|
+
from preparse._items.Item import Item
|
|
6
|
+
from preparse._items.Long import Long
|
|
7
|
+
from preparse._items.Option import Option
|
|
8
|
+
from preparse._items.Positional import Positional
|
|
9
|
+
from preparse._items.Special import Special
|
|
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
|
|
@@ -8,9 +8,7 @@ def test() -> unittest.TextTestResult:
|
|
|
8
8
|
loader: unittest.TestLoader
|
|
9
9
|
tests: unittest.TestSuite
|
|
10
10
|
runner: unittest.TextTestRunner
|
|
11
|
-
result: unittest.TextTestResult
|
|
12
11
|
loader = unittest.TestLoader()
|
|
13
12
|
tests = loader.discover(start_dir="preparse.tests")
|
|
14
13
|
runner = unittest.TextTestRunner()
|
|
15
|
-
|
|
16
|
-
return result
|
|
14
|
+
return runner.run(tests)
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import unittest
|
|
2
2
|
from typing import *
|
|
3
3
|
|
|
4
|
-
from preparse.core.Click import Click
|
|
5
4
|
from preparse.core.enums import *
|
|
6
5
|
from preparse.core.Optdict import Optdict
|
|
7
|
-
from preparse.core.PreParser import PreParser
|
|
8
|
-
from preparse.core.warnings import *
|
|
9
6
|
|
|
10
7
|
__all__ = ["TestPreparse"]
|
|
11
8
|
|
|
@@ -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
|
|
@@ -10,26 +10,27 @@ src/preparse.egg-info/SOURCES.txt
|
|
|
10
10
|
src/preparse.egg-info/dependency_links.txt
|
|
11
11
|
src/preparse.egg-info/requires.txt
|
|
12
12
|
src/preparse.egg-info/top_level.txt
|
|
13
|
+
src/preparse/_items/Bundle.py
|
|
14
|
+
src/preparse/_items/Item.py
|
|
15
|
+
src/preparse/_items/Long.py
|
|
16
|
+
src/preparse/_items/Option.py
|
|
17
|
+
src/preparse/_items/Positional.py
|
|
18
|
+
src/preparse/_items/Special.py
|
|
19
|
+
src/preparse/_items/__init__.py
|
|
13
20
|
src/preparse/_processing/__init__.py
|
|
14
21
|
src/preparse/_processing/deparsing.py
|
|
15
22
|
src/preparse/_processing/digesting.py
|
|
16
23
|
src/preparse/_processing/parsing.py
|
|
17
24
|
src/preparse/_processing/pulling.py
|
|
18
|
-
src/preparse/_processing/items/Bundle.py
|
|
19
|
-
src/preparse/_processing/items/Item.py
|
|
20
|
-
src/preparse/_processing/items/Long.py
|
|
21
|
-
src/preparse/_processing/items/Option.py
|
|
22
|
-
src/preparse/_processing/items/Positional.py
|
|
23
|
-
src/preparse/_processing/items/Special.py
|
|
24
|
-
src/preparse/_processing/items/__init__.py
|
|
25
25
|
src/preparse/_utils/__init__.py
|
|
26
26
|
src/preparse/_utils/dataprop.py
|
|
27
27
|
src/preparse/core/Click.py
|
|
28
|
+
src/preparse/core/OptDict.py
|
|
28
29
|
src/preparse/core/Optdict.py
|
|
29
30
|
src/preparse/core/PreParser.py
|
|
31
|
+
src/preparse/core/PreparseWarning.py
|
|
30
32
|
src/preparse/core/__init__.py
|
|
31
33
|
src/preparse/core/enums.py
|
|
32
|
-
src/preparse/core/warnings.py
|
|
33
34
|
src/preparse/tests/__init__.py
|
|
34
35
|
src/preparse/tests/data.toml
|
|
35
36
|
src/preparse/tests/expit.toml
|
|
@@ -37,4 +38,12 @@ src/preparse/tests/test_data_toml.py
|
|
|
37
38
|
src/preparse/tests/test_enums.py
|
|
38
39
|
src/preparse/tests/test_expit_toml.py
|
|
39
40
|
src/preparse/tests/test_optdict.py
|
|
40
|
-
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,6 +0,0 @@
|
|
|
1
|
-
from preparse._processing.items.Bundle import Bundle
|
|
2
|
-
from preparse._processing.items.Item import Item
|
|
3
|
-
from preparse._processing.items.Long import Long
|
|
4
|
-
from preparse._processing.items.Option import Option
|
|
5
|
-
from preparse._processing.items.Positional import Positional
|
|
6
|
-
from preparse._processing.items.Special import Special
|
|
@@ -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
|
{preparse-1.0.10/src/preparse/_processing/items → preparse-2.0.0.dev0/src/preparse/_items}/Item.py
RENAMED
|
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
|