preparse 1.0.11__tar.gz → 2.0.0.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.
Files changed (50) hide show
  1. {preparse-1.0.11/src/preparse.egg-info → preparse-2.0.0.dev1}/PKG-INFO +2 -2
  2. {preparse-1.0.11 → preparse-2.0.0.dev1}/docs/v1.0.rst +6 -6
  3. {preparse-1.0.11 → preparse-2.0.0.dev1}/pyproject.toml +2 -2
  4. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/_processing/__init__.py +2 -2
  5. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/_processing/digesting.py +0 -1
  6. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/_processing/parsing.py +16 -18
  7. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/core/Optdict.py +2 -3
  8. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/core/PreParser.py +20 -20
  9. preparse-2.0.0.dev1/src/preparse/core/PreparseWarning.py +6 -0
  10. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/core/__init__.py +1 -2
  11. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/tests/data.toml +35328 -35328
  12. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/tests/test_optdict.py +5 -6
  13. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/tests/test_preparser.py +2 -3
  14. preparse-2.0.0.dev1/src/preparse/warners/AmbiguousOptionWarner.py +38 -0
  15. preparse-2.0.0.dev1/src/preparse/warners/DualWarner.py +33 -0
  16. preparse-2.0.0.dev1/src/preparse/warners/InvalidOptionWarner.py +14 -0
  17. preparse-2.0.0.dev1/src/preparse/warners/LongonlyWarner.py +13 -0
  18. preparse-2.0.0.dev1/src/preparse/warners/RequiredArgumentWarner.py +14 -0
  19. preparse-2.0.0.dev1/src/preparse/warners/UnallowedArgumentWarner.py +25 -0
  20. preparse-2.0.0.dev1/src/preparse/warners/WarnerABC.py +60 -0
  21. preparse-2.0.0.dev1/src/preparse/warners/__init__.py +0 -0
  22. {preparse-1.0.11 → preparse-2.0.0.dev1/src/preparse.egg-info}/PKG-INFO +2 -2
  23. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse.egg-info/SOURCES.txt +10 -2
  24. preparse-1.0.11/src/preparse/core/warnings.py +0 -152
  25. {preparse-1.0.11 → preparse-2.0.0.dev1}/LICENSE.txt +0 -0
  26. {preparse-1.0.11 → preparse-2.0.0.dev1}/MANIFEST.in +0 -0
  27. {preparse-1.0.11 → preparse-2.0.0.dev1}/README.rst +0 -0
  28. {preparse-1.0.11 → preparse-2.0.0.dev1}/setup.cfg +0 -0
  29. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/__init__.py +0 -0
  30. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/_items/Bundle.py +0 -0
  31. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/_items/Item.py +0 -0
  32. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/_items/Long.py +0 -0
  33. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/_items/Option.py +0 -0
  34. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/_items/Positional.py +0 -0
  35. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/_items/Special.py +0 -0
  36. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/_items/__init__.py +0 -0
  37. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/_processing/deparsing.py +0 -0
  38. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/_processing/pulling.py +0 -0
  39. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/_utils/__init__.py +0 -0
  40. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/_utils/dataprop.py +0 -0
  41. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/core/Click.py +0 -0
  42. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/core/enums.py +0 -0
  43. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/tests/__init__.py +0 -0
  44. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/tests/expit.toml +0 -0
  45. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/tests/test_data_toml.py +0 -0
  46. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/tests/test_enums.py +0 -0
  47. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse/tests/test_expit_toml.py +0 -0
  48. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse.egg-info/dependency_links.txt +0 -0
  49. {preparse-1.0.11 → preparse-2.0.0.dev1}/src/preparse.egg-info/requires.txt +0 -0
  50. {preparse-1.0.11 → preparse-2.0.0.dev1}/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: 1.0.11
3
+ Version: 2.0.0.dev1
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 :: 5 - Production/Stable
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 = preparse.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.
@@ -109,7 +109,7 @@ 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: preparse.Optdict``
112
+ ``optDict: preparse.OptDict``
113
113
  """""""""""""""""""""""""""""
114
114
 
115
115
  This property holds a dict-like object.
@@ -143,7 +143,7 @@ POSIX and the interleaving of options with positonal arguments, should be enforc
143
143
  """""""""""""""""""""""""""""""""""""""""""""""""""
144
144
 
145
145
  This method alters the current instance to reflect a ``click.Command`` object.
146
- Concretely the optdict property is changed.
146
+ Concretely the optDict property is changed.
147
147
 
148
148
  ``reflectClickContext(ctx: click.Context) -> None``
149
149
  """""""""""""""""""""""""""""""""""""""""""""""""""
@@ -202,15 +202,15 @@ This property determines if the ``reflectClickContext`` method of parser is to b
202
202
 
203
203
  This property holds the parser to be embedded.
204
204
 
205
- The Optdict class
205
+ The OptDict class
206
206
  ~~~~~~~~~~~~~~~~~
207
207
 
208
- ``class preparse.Optdict``
208
+ ``class preparse.OptDict``
209
209
  ^^^^^^^^^^^^^^^^^^^^^^^^^^
210
210
 
211
211
  This class is a subclass of ``datahold.HoldDict[str, preparse.Nargs]``
212
212
  with strings as keys and with ``preparse.Nargs`` as values.
213
- It is designed for ``preparse.PreParser.optdict``.
213
+ It is designed for ``preparse.PreParser.optDict``.
214
214
 
215
215
  The Enums
216
216
  ~~~~~~~~~
@@ -9,7 +9,7 @@ authors = [
9
9
  { email = "johannes.programming@gmail.com", name = "Johannes" },
10
10
  ]
11
11
  classifiers = [
12
- "Development Status :: 5 - Production/Stable",
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 = "1.0.11"
37
+ version = "2.0.0.dev1"
38
38
 
39
39
  [project.license]
40
40
  file = "LICENSE.txt"
@@ -21,7 +21,7 @@ def process(
21
21
  expandsabbr: bool,
22
22
  expectsabbr: bool,
23
23
  expectsposix: bool,
24
- optdict: dict,
24
+ optDict: dict,
25
25
  prog: str,
26
26
  reconcilesorders: bool,
27
27
  special: Tuning,
@@ -36,7 +36,7 @@ def process(
36
36
  allowsshort=allowsshort,
37
37
  expectsabbr=expectsabbr,
38
38
  expectsposix=expectsposix,
39
- optdict=optdict,
39
+ optDict=optDict,
40
40
  prog=prog,
41
41
  warn=warn,
42
42
  )
@@ -7,7 +7,6 @@ from preparse._items.Option import Option
7
7
  from preparse._items.Positional import Positional
8
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
 
@@ -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))
@@ -26,7 +24,7 @@ def parse_bundling(
26
24
  arg: str,
27
25
  *,
28
26
  cause: FunctionType,
29
- optdict: dict,
27
+ optDict: dict,
30
28
  ) -> Bundle:
31
29
  ans: Bundle
32
30
  x: int
@@ -37,7 +35,7 @@ def parse_bundling(
37
35
  continue
38
36
  ans.chars += y
39
37
  try:
40
- ans.nargs = optdict["-" + y]
38
+ ans.nargs = optDict["-" + y]
41
39
  except KeyError:
42
40
  cause(PIOW, option=y, islong=False)
43
41
  ans.nargs = Nargs.NO_ARGUMENT
@@ -68,7 +66,7 @@ def parse_generator(
68
66
  allowsshort: bool,
69
67
  expectsabbr: bool,
70
68
  expectsposix: bool,
71
- optdict: dict,
69
+ optDict: dict,
72
70
  prog: str,
73
71
  warn: FunctionType,
74
72
  ) -> Generator[Any, Any, Any]:
@@ -106,7 +104,7 @@ def parse_generator(
106
104
  allowsshort=allowsshort,
107
105
  cause=cause,
108
106
  expectsabbr=expectsabbr,
109
- optdict=optdict,
107
+ optDict=optDict,
110
108
  )
111
109
  if not last.ishungry():
112
110
  yield last
@@ -138,7 +136,7 @@ def parse_long(
138
136
  *,
139
137
  cause: FunctionType,
140
138
  expectsabbr: bool,
141
- optdict: dict,
139
+ optDict: dict,
142
140
  ) -> Long:
143
141
  ans: Long
144
142
  parts: list[str]
@@ -148,13 +146,13 @@ def parse_long(
148
146
  ans.joined = True
149
147
  ans.right = parts.pop()
150
148
  ans.abbrlen = len(ans.fullkey)
151
- if ans.fullkey in optdict.keys():
152
- ans.nargs = optdict[ans.fullkey]
149
+ if ans.fullkey in optDict.keys():
150
+ ans.nargs = optDict[ans.fullkey]
153
151
  if (ans.nargs == Nargs.NO_ARGUMENT) and (ans.right is not None):
154
152
  cause(PUAW, option=ans.fullkey)
155
153
  return ans
156
154
  if expectsabbr:
157
- parts = parse_long_startswith(ans.abbr, keys=optdict.keys())
155
+ parts = parse_long_startswith(ans.abbr, keys=optDict.keys())
158
156
  else:
159
157
  parts = list() # can be assumed
160
158
  if len(parts) == 0:
@@ -166,7 +164,7 @@ def parse_long(
166
164
  cause(PAOW, option=arg, possibilities=parts)
167
165
  return ans
168
166
  (ans.fullkey,) = parts
169
- ans.nargs = optdict[ans.fullkey]
167
+ ans.nargs = optDict[ans.fullkey]
170
168
  return ans
171
169
 
172
170
 
@@ -189,7 +187,7 @@ def parse_option(
189
187
  *,
190
188
  cause: FunctionType,
191
189
  expectsabbr: bool,
192
- optdict: dict,
190
+ optDict: dict,
193
191
  **kwargs: Any,
194
192
  ) -> Option:
195
193
  if parse_islong(arg, **kwargs):
@@ -197,11 +195,11 @@ def parse_option(
197
195
  arg,
198
196
  cause=cause,
199
197
  expectsabbr=expectsabbr,
200
- optdict=optdict,
198
+ optDict=optDict,
201
199
  )
202
200
  else:
203
201
  return parse_bundling(
204
202
  arg,
205
203
  cause=cause,
206
- optdict=optdict,
204
+ optDict=optDict,
207
205
  )
@@ -7,12 +7,11 @@ from datarepr import datarepr
7
7
  from frozendict import frozendict
8
8
 
9
9
  from preparse.core.enums import *
10
- from preparse.core.warnings import *
11
10
 
12
- __all__ = ["Optdict"]
11
+ __all__ = ["OptDict"]
13
12
 
14
13
 
15
- class Optdict(cmp3.CmpABC, datahold.HoldDict[str, Nargs]):
14
+ class OptDict(cmp3.CmpABC, datahold.HoldDict[str, Nargs]):
16
15
  __slots__ = ()
17
16
 
18
17
  data: frozendict[str, Nargs]
@@ -15,8 +15,8 @@ from preparse._processing import *
15
15
  from preparse._utils.dataprop import dataprop
16
16
  from preparse.core.Click import Click
17
17
  from preparse.core.enums import *
18
- from preparse.core.Optdict import *
19
- from preparse.core.warnings import *
18
+ from preparse.core.OptDict import OptDict
19
+ from preparse.warners import *
20
20
 
21
21
  __all__ = ["PreParser"]
22
22
 
@@ -29,11 +29,11 @@ class PreParser(Copyable):
29
29
  expandsabbr: bool
30
30
  expectsabbr: bool
31
31
  expectsposix: bool
32
- optdict: Optdict
32
+ optDict: OptDict
33
33
  prog: str
34
34
  reconcilesorders: bool
35
35
  special: Tuning
36
- warn: types.FunctionType
36
+ warn: Callable
37
37
 
38
38
  __slots__ = ("_data",)
39
39
 
@@ -47,11 +47,11 @@ class PreParser(Copyable):
47
47
  expandsabbr: Any = True,
48
48
  expectsabbr: Any = True,
49
49
  expectsposix: Any = False,
50
- optdict: Any = (),
50
+ optDict: Any = (),
51
51
  prog: Any = None,
52
52
  reconcilesorders: Any = True,
53
53
  special: Any = Tuning.MAINTAIN,
54
- warn: Callable = str,
54
+ warn: types.FunctionType = str,
55
55
  ) -> None:
56
56
  self.allowslong = allowslong
57
57
  self.allowsshort = allowsshort
@@ -59,7 +59,7 @@ class PreParser(Copyable):
59
59
  self.expandsabbr = expandsabbr
60
60
  self.expectsabbr = expectsabbr
61
61
  self.expectsposix = expectsposix
62
- self.optdict = optdict
62
+ self.optDict = optDict
63
63
  self.prog = prog
64
64
  self.reconcilesorders = reconcilesorders
65
65
  self.special = special
@@ -106,15 +106,15 @@ class PreParser(Copyable):
106
106
  return bool(value)
107
107
 
108
108
  @dataprop
109
- def optdict(self: Self, value: Any) -> Optdict:
109
+ def optDict(self: Self, value: Any) -> OptDict:
110
110
  "This property gives a dictionary of options."
111
- dataA: Optdict
112
- if "optdict" not in self._data.keys():
113
- self._data["optdict"] = Optdict()
114
- dataA = Optdict(value)
115
- self._data["optdict"].clear()
116
- self._data["optdict"].update(dataA)
117
- return self._data["optdict"]
111
+ dataA: OptDict
112
+ if "optDict" not in self._data.keys():
113
+ self._data["optDict"] = OptDict()
114
+ dataA = OptDict(value)
115
+ self._data["optDict"].clear()
116
+ self._data["optDict"].update(dataA)
117
+ return self._data["optDict"]
118
118
 
119
119
  def parse_args(
120
120
  self: Self,
@@ -137,11 +137,11 @@ class PreParser(Copyable):
137
137
 
138
138
  def reflectClickCommand(self: Self, cmd: cl.Command) -> None:
139
139
  "This method causes the current instance to reflect a click.Command object."
140
- optdict: dict[str, Nargs]
140
+ optDict: dict[str, Nargs]
141
141
  nargs: Nargs
142
142
  opt: Any
143
143
  param: Any
144
- optdict = dict()
144
+ optDict = dict()
145
145
  for param in cmd.params:
146
146
  if not isinstance(param, cl.Option):
147
147
  continue
@@ -152,9 +152,9 @@ class PreParser(Copyable):
152
152
  else:
153
153
  nargs = Nargs.OPTIONAL_ARGUMENT
154
154
  for opt in param.opts:
155
- optdict[str(opt)] = nargs
156
- self.optdict.clear()
157
- self.optdict.update(optdict)
155
+ optDict[str(opt)] = nargs
156
+ self.optDict.clear()
157
+ self.optDict.update(optDict)
158
158
 
159
159
  def reflectClickContext(self: Self, ctx: cl.Context) -> None:
160
160
  "This method causes the current instance to reflect a click.Context object."
@@ -0,0 +1,6 @@
1
+ from typing import *
2
+
3
+ __all__ = ["PreparseWarning"]
4
+
5
+
6
+ class PreparseWarning(Warning): ...
@@ -1,5 +1,4 @@
1
1
  from preparse.core.Click import *
2
2
  from preparse.core.enums import *
3
- from preparse.core.Optdict import *
3
+ from preparse.core.OptDict import *
4
4
  from preparse.core.PreParser import *
5
- from preparse.core.warnings import *