preparse 2.0.0.dev16__tar.gz → 2.0.0.dev18__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 (59) hide show
  1. preparse-2.0.0.dev18/PKG-INFO +37 -0
  2. preparse-2.0.0.dev18/README.rst +7 -0
  3. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/pyproject.toml +9 -10
  4. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/_items/Bundle.py +5 -5
  5. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/_items/Item.py +7 -8
  6. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/_items/Long.py +4 -17
  7. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/_items/Option.py +1 -1
  8. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/_items/Positional.py +0 -1
  9. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/_items/Special.py +1 -2
  10. preparse-2.0.0.dev18/src/preparse/_processing/__init__.py +51 -0
  11. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/_processing/digesting.py +20 -21
  12. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/_processing/parsing.py +46 -43
  13. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/_utils/dataprop.py +5 -3
  14. preparse-2.0.0.dev18/src/preparse/core/OptNaming.py +45 -0
  15. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/core/PreParser.py +43 -45
  16. preparse-2.0.0.dev18/src/preparse/core/PreparseWarning.py +8 -0
  17. preparse-2.0.0.dev18/src/preparse/core/__init__.py +0 -0
  18. preparse-2.0.0.dev18/src/preparse/enums/BaseEnum.py +15 -0
  19. preparse-2.0.0.dev18/src/preparse/enums/Nargs.py +16 -0
  20. preparse-2.0.0.dev16/src/preparse/core/enums.py → preparse-2.0.0.dev18/src/preparse/enums/Tuning.py +2 -10
  21. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/tests/data.toml +176691 -176691
  22. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/tests/test_data_toml.py +1 -1
  23. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/tests/test_enums.py +1 -1
  24. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/tests/test_expit_toml.py +2 -2
  25. preparse-2.0.0.dev18/src/preparse/tests/test_optNaming.py +20 -0
  26. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/tests/test_preparser.py +11 -9
  27. preparse-2.0.0.dev18/src/preparse/warners/AmbiguousOptionWarner.py +36 -0
  28. preparse-2.0.0.dev18/src/preparse/warners/DualWarner.py +31 -0
  29. preparse-2.0.0.dev18/src/preparse/warners/InvalidOptionWarner.py +14 -0
  30. preparse-2.0.0.dev18/src/preparse/warners/LongonlyWarner.py +13 -0
  31. preparse-2.0.0.dev18/src/preparse/warners/RequiredArgumentWarner.py +14 -0
  32. preparse-2.0.0.dev18/src/preparse/warners/UnallowedArgumentWarner.py +25 -0
  33. preparse-2.0.0.dev18/src/preparse/warners/Warner.py +55 -0
  34. preparse-2.0.0.dev18/src/preparse/warners/__init__.py +0 -0
  35. preparse-2.0.0.dev18/src/preparse.egg-info/PKG-INFO +37 -0
  36. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse.egg-info/SOURCES.txt +15 -6
  37. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse.egg-info/requires.txt +3 -3
  38. preparse-2.0.0.dev16/PKG-INFO +0 -57
  39. preparse-2.0.0.dev16/README.rst +0 -5
  40. preparse-2.0.0.dev16/docs/v1.0.rst +0 -303
  41. preparse-2.0.0.dev16/src/preparse/_processing/__init__.py +0 -50
  42. preparse-2.0.0.dev16/src/preparse/core/Optdict.py +0 -47
  43. preparse-2.0.0.dev16/src/preparse/core/__init__.py +0 -5
  44. preparse-2.0.0.dev16/src/preparse/core/warnings.py +0 -152
  45. preparse-2.0.0.dev16/src/preparse/tests/test_optdict.py +0 -22
  46. preparse-2.0.0.dev16/src/preparse.egg-info/PKG-INFO +0 -57
  47. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/LICENSE.txt +0 -0
  48. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/MANIFEST.in +0 -0
  49. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/setup.cfg +0 -0
  50. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/__init__.py +0 -0
  51. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/_items/__init__.py +0 -0
  52. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/_processing/deparsing.py +0 -0
  53. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/_processing/pulling.py +0 -0
  54. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/_utils/__init__.py +0 -0
  55. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/core/Click.py +0 -0
  56. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/tests/__init__.py +0 -0
  57. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse/tests/expit.toml +0 -0
  58. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse.egg-info/dependency_links.txt +0 -0
  59. {preparse-2.0.0.dev16 → preparse-2.0.0.dev18}/src/preparse.egg-info/top_level.txt +0 -0
@@ -0,0 +1,37 @@
1
+ Metadata-Version: 2.4
2
+ Name: preparse
3
+ Version: 2.0.0.dev18
4
+ Summary: This project preparses args for further parsing later on.
5
+ Author-email: Johannes <johannes.programming@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Download, https://pypi.org/project/preparse/#files
8
+ Project-URL: Index, https://pypi.org/project/preparse/
9
+ Project-URL: Source, https://github.com/johannes-programming/preparse/
10
+ Project-URL: Website, https://preparse.johannes-programming.online/
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Natural Language :: English
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/x-rst
19
+ License-File: LICENSE.txt
20
+ Requires-Dist: click<9,>=8.2
21
+ Requires-Dist: cmp3<2,>=1.0
22
+ Requires-Dist: copyable<2,>=1.0
23
+ Requires-Dist: datahold<4,>=3.1.dev3
24
+ Requires-Dist: datarepr<2,>=1.1
25
+ Requires-Dist: namings<2,>=1.0.dev0
26
+ Requires-Dist: overloadable<2,>=1.1
27
+ Requires-Dist: setdoc<2,>=1.2.20
28
+ Requires-Dist: tofunc<2,>=1.0
29
+ Dynamic: license-file
30
+
31
+ ========
32
+ preparse
33
+ ========
34
+
35
+ Each minor version has its own documentation.
36
+ These docs can be found as rst-files in the ``docs/`` directory of this project.
37
+ They can also be viewed on the website `https://preparse.johannes-programming.online/ <https://preparse.johannes-programming.online/>`_.
@@ -0,0 +1,7 @@
1
+ ========
2
+ preparse
3
+ ========
4
+
5
+ Each minor version has its own documentation.
6
+ These docs can be found as rst-files in the ``docs/`` directory of this project.
7
+ They can also be viewed on the website `https://preparse.johannes-programming.online/ <https://preparse.johannes-programming.online/>`_.
@@ -1,7 +1,7 @@
1
1
  [build-system]
2
2
  build-backend = "setuptools.build_meta"
3
3
  requires = [
4
- "setuptools>=64.0",
4
+ "setuptools>=77.0",
5
5
  ]
6
6
 
7
7
  [project]
@@ -10,34 +10,33 @@ authors = [
10
10
  ]
11
11
  classifiers = [
12
12
  "Development Status :: 3 - Alpha",
13
- "License :: OSI Approved :: MIT License",
14
13
  "Natural Language :: English",
15
14
  "Operating System :: OS Independent",
16
15
  "Programming Language :: Python",
17
16
  "Programming Language :: Python :: 3",
18
17
  "Programming Language :: Python :: 3 :: Only",
19
- "Typing :: Typed",
20
18
  ]
21
19
  dependencies = [
22
20
  "click>=8.2,<9",
23
21
  "cmp3>=1.0,<2",
24
22
  "copyable>=1.0,<2",
25
- "datahold>=3.0,<4",
23
+ "datahold>=3.1.dev3,<4",
26
24
  "datarepr>=1.1,<2",
27
- "frozendict>=2.4.7,<3",
25
+ "namings>=1.0.dev0,<2",
28
26
  "overloadable>=1.1,<2",
29
- "setdoc>=1.2.10,<2",
27
+ "setdoc>=1.2.20,<2",
30
28
  "tofunc>=1.0,<2",
31
29
  ]
32
30
  description = "This project preparses args for further parsing later on."
33
31
  keywords = []
32
+ license = "MIT"
33
+ license-files = [
34
+ "LICENSE.txt",
35
+ ]
34
36
  name = "preparse"
35
37
  readme = "README.rst"
36
38
  requires-python = ">=3.11"
37
- version = "2.0.0.dev16"
38
-
39
- [project.license]
40
- file = "LICENSE.txt"
39
+ version = "2.0.0.dev18"
41
40
 
42
41
  [project.urls]
43
42
  Download = "https://pypi.org/project/preparse/#files"
@@ -5,7 +5,7 @@ import setdoc
5
5
  from preparse._items.Item import Item
6
6
  from preparse._items.Option import Option
7
7
  from preparse._utils.dataprop import dataprop
8
- from preparse.core.enums import *
8
+ from preparse.enums.Nargs import Nargs
9
9
 
10
10
  __all__ = ["Bundle"]
11
11
 
@@ -32,7 +32,7 @@ class Bundle(Option):
32
32
  self.right = right
33
33
 
34
34
  @classmethod
35
- def _split_allowslong(cls: type, chars: str) -> list[str]:
35
+ def _split_allowsLong(cls: type, chars: str) -> list[str]:
36
36
  ans: list[str]
37
37
  x: str
38
38
  ans = list()
@@ -73,12 +73,12 @@ class Bundle(Option):
73
73
  else:
74
74
  return ["-" + self.chars, self.right]
75
75
 
76
- def split(self: Self, *, allowslong: bool) -> list[Item]:
76
+ def split(self: Self, *, allowsLong: bool) -> list[Item]:
77
77
  ans: list[Self]
78
78
  parts: list[str]
79
79
  x: str
80
- if allowslong:
81
- parts = self._split_allowslong(self.chars)
80
+ if allowsLong:
81
+ parts = self._split_allowsLong(self.chars)
82
82
  else:
83
83
  parts = self._split_shortonly(self.chars)
84
84
  ans = list()
@@ -1,11 +1,10 @@
1
1
  import abc
2
2
  from typing import *
3
3
 
4
+ import namings
4
5
  import setdoc
5
6
  from copyable import Copyable
6
7
 
7
- from preparse.core.enums import *
8
-
9
8
  __all__ = ["Item"]
10
9
 
11
10
 
@@ -14,7 +13,7 @@ class Item(Copyable):
14
13
 
15
14
  @setdoc.basic
16
15
  def copy(self: Self) -> Self:
17
- return type(self)(**self.todict())
16
+ return type(self)(**self.toNaming())
18
17
 
19
18
  @abc.abstractmethod
20
19
  def deparse(self: Self) -> list[str]: ...
@@ -23,14 +22,14 @@ class Item(Copyable):
23
22
  @abc.abstractmethod
24
23
  def sortkey(cls: type) -> int: ...
25
24
 
26
- def todict(self: Self) -> dict:
25
+ def toNaming(self: Self) -> namings.Naming:
27
26
  "This method returns a dict representing the current instance."
28
- ans: dict
27
+ ans: namings.Naming
29
28
  try:
30
29
  ans = self._data
31
30
  except AttributeError:
32
- self._data = dict()
33
- ans = dict()
31
+ self._data = namings.Naming()
32
+ ans = namings.Naming()
34
33
  else:
35
- ans = dict(ans)
34
+ ans = namings.Naming(ans)
36
35
  return ans
@@ -1,11 +1,10 @@
1
- import operator
2
1
  from typing import *
3
2
 
4
3
  import setdoc
5
4
 
6
5
  from preparse._items.Option import Option
7
6
  from preparse._utils.dataprop import dataprop
8
- from preparse.core.enums import *
7
+ from preparse.enums.Nargs import Nargs
9
8
 
10
9
  __all__ = ["Long"]
11
10
 
@@ -13,7 +12,6 @@ __all__ = ["Long"]
13
12
  class Long(Option):
14
13
 
15
14
  abbr: str
16
- abbrlen: Optional[int]
17
15
  fullkey: str
18
16
  joined: bool
19
17
  nargs: Nargs
@@ -26,31 +24,20 @@ class Long(Option):
26
24
  self: Self,
27
25
  *,
28
26
  fullkey: str,
29
- abbrlen: Optional[int] = None,
30
27
  joined: bool | str = False,
31
28
  right: Optional[str] = None,
32
29
  ) -> None:
33
30
  self.fullkey = fullkey
34
- self.abbrlen = abbrlen
35
31
  self.joined = joined
36
32
  self.right = right
37
33
 
38
- @property
39
- def abbr(self: Self) -> str:
40
- return self.fullkey[: self.abbrlen]
41
-
42
- @dataprop
43
- def abbrlen(self: Self, x: Optional[SupportsIndex]) -> Optional[int]:
44
- if x is not None:
45
- return operator.index(x)
46
-
47
34
  def deparse(self: Self) -> list[str]:
48
35
  if self.right is None:
49
- return [self.abbr]
36
+ return [self.fullkey]
50
37
  elif self.joined:
51
- return [self.abbr + "=" + self.right]
38
+ return [self.fullkey + "=" + self.right]
52
39
  else:
53
- return [self.abbr, self.right]
40
+ return [self.fullkey, self.right]
54
41
 
55
42
  @dataprop
56
43
  def fullkey(self: Self, x: Any) -> str:
@@ -3,7 +3,7 @@ from typing import *
3
3
 
4
4
  from preparse._items.Item import Item
5
5
  from preparse._utils.dataprop import dataprop
6
- from preparse.core.enums import *
6
+ from preparse.enums.Nargs import Nargs
7
7
 
8
8
  __all__ = ["Option"]
9
9
 
@@ -4,7 +4,6 @@ import setdoc
4
4
 
5
5
  from preparse._items.Item import Item
6
6
  from preparse._utils.dataprop import dataprop
7
- from preparse.core.enums import *
8
7
 
9
8
  __all__ = ["Positional"]
10
9
 
@@ -1,7 +1,6 @@
1
1
  from typing import *
2
2
 
3
3
  from preparse._items.Item import Item
4
- from preparse.core.enums import *
5
4
 
6
5
  __all__ = ["Special"]
7
6
 
@@ -14,5 +13,5 @@ class Special(Item):
14
13
  return ["--"]
15
14
 
16
15
  @classmethod
17
- def sortkey(cls: type) -> int:
16
+ def sortkey(cls: type[Self]) -> int:
18
17
  return 1
@@ -0,0 +1,51 @@
1
+ from types import FunctionType
2
+ from typing import *
3
+
4
+ import datahold
5
+
6
+ from preparse._items import Item
7
+ from preparse._processing.deparsing import deparse
8
+ from preparse._processing.digesting import digest
9
+ from preparse._processing.parsing import parse
10
+ from preparse._processing.pulling import pull
11
+ from preparse.enums.Tuning import Tuning
12
+
13
+ __all__ = ["process"]
14
+
15
+
16
+ def process(
17
+ args: Optional[Iterable] = None,
18
+ *,
19
+ abbr: Optional[Tuning],
20
+ allowsLong: bool,
21
+ allowsShort: bool,
22
+ bundling: Tuning,
23
+ expectsPOSIX: bool,
24
+ optNaming: datahold.DataNaming,
25
+ prog: str,
26
+ reconcilesOrders: bool,
27
+ special: Tuning,
28
+ warn: FunctionType,
29
+ ) -> list[str]:
30
+ "This method parses args."
31
+ items: list[Item]
32
+ items = pull(args)
33
+ items = parse(
34
+ items,
35
+ abbr=abbr,
36
+ allowsLong=allowsLong,
37
+ allowsShort=allowsShort,
38
+ expectsPOSIX=expectsPOSIX,
39
+ optNaming=optNaming,
40
+ prog=prog,
41
+ warn=warn,
42
+ )
43
+ items = digest(
44
+ items,
45
+ allowsLong=allowsLong,
46
+ bundling=bundling,
47
+ expectsPOSIX=expectsPOSIX,
48
+ reconcilesOrders=reconcilesOrders,
49
+ special=special,
50
+ )
51
+ return deparse(items)
@@ -5,8 +5,7 @@ from preparse._items.Item import Item
5
5
  from preparse._items.Option import Option
6
6
  from preparse._items.Positional import Positional
7
7
  from preparse._items.Special import Special
8
- from preparse.core.enums import *
9
- from preparse.core.warnings import *
8
+ from preparse.enums.Tuning import Tuning
10
9
 
11
10
  __all__ = ["digest"]
12
11
 
@@ -14,10 +13,10 @@ __all__ = ["digest"]
14
13
  def digest(
15
14
  items: list[Item],
16
15
  *,
17
- allowslong: bool,
16
+ allowsLong: bool,
18
17
  bundling: Tuning,
19
- expectsposix: bool,
20
- reconcilesorders: bool,
18
+ expectsPOSIX: bool,
19
+ reconcilesOrders: bool,
21
20
  special: Tuning,
22
21
  ) -> list[Item]:
23
22
  ans: list[Item]
@@ -25,19 +24,19 @@ def digest(
25
24
 
26
25
  ans = digest_special(
27
26
  ans,
28
- expectsposix=expectsposix,
29
- reconcilesorders=reconcilesorders,
27
+ expectsPOSIX=expectsPOSIX,
28
+ reconcilesOrders=reconcilesOrders,
30
29
  special=special,
31
30
  )
32
31
  ans = digest_order(
33
32
  ans,
34
- expectsposix=expectsposix,
35
- reconcilesorders=reconcilesorders,
33
+ expectsPOSIX=expectsPOSIX,
34
+ reconcilesOrders=reconcilesOrders,
36
35
  )
37
36
  ans = digest_bundling(
38
37
  ans,
39
38
  bundling=bundling,
40
- allowslong=allowslong,
39
+ allowsLong=allowsLong,
41
40
  )
42
41
  return ans
43
42
 
@@ -45,11 +44,11 @@ def digest(
45
44
  def digest_bundling(
46
45
  items: list[Item],
47
46
  *,
48
- allowslong: bool,
47
+ allowsLong: bool,
49
48
  bundling: Tuning,
50
49
  ) -> list[Item]:
51
50
  if bundling == Tuning.MINIMIZE:
52
- return digest_bundling_min(items, allowslong=allowslong)
51
+ return digest_bundling_min(items, allowsLong=allowsLong)
53
52
  if bundling == Tuning.MAXIMIZE:
54
53
  return digest_bundling_max(items)
55
54
  return items
@@ -58,14 +57,14 @@ def digest_bundling(
58
57
  def digest_bundling_min(
59
58
  items: list[Item],
60
59
  *,
61
- allowslong: bool,
60
+ allowsLong: bool,
62
61
  ) -> list[Item]:
63
62
  ans: list[Item]
64
63
  item: Item
65
64
  ans = list()
66
65
  for item in items:
67
66
  if isinstance(item, Bundle):
68
- ans += item.split(allowslong=allowslong)
67
+ ans += item.split(allowsLong=allowsLong)
69
68
  else:
70
69
  ans.append(item)
71
70
  return ans
@@ -96,16 +95,16 @@ def digest_bundling_max(items: list[Item]) -> list[Item]:
96
95
  def digest_order(
97
96
  items: list[Item],
98
97
  *,
99
- expectsposix: bool,
100
- reconcilesorders: bool,
98
+ expectsPOSIX: bool,
99
+ reconcilesOrders: bool,
101
100
  ) -> list[Item]:
102
101
  ans: list[Item]
103
102
  comp: bool
104
103
  index: int
105
104
  ans = list(items)
106
- if not reconcilesorders:
105
+ if not reconcilesOrders:
107
106
  return ans
108
- if not expectsposix:
107
+ if not expectsPOSIX:
109
108
  ans.sort(key=digest_order_key)
110
109
  return ans
111
110
  index = len(ans)
@@ -167,8 +166,8 @@ def digest_special_max(items: list[Item]) -> list[Item]:
167
166
  def digest_special_min(
168
167
  items: list[Item],
169
168
  *,
170
- expectsposix: bool,
171
- reconcilesorders: bool,
169
+ expectsPOSIX: bool,
170
+ reconcilesOrders: bool,
172
171
  ) -> list[Item]:
173
172
  ans: list[Item]
174
173
  index: int
@@ -176,7 +175,7 @@ def digest_special_min(
176
175
  isposix: bool
177
176
  ans = list(items)
178
177
  isdel = True
179
- isposix = expectsposix and not reconcilesorders
178
+ isposix = expectsPOSIX and not reconcilesOrders
180
179
  index = len(items)
181
180
  while True:
182
181
  index -= 1
@@ -1,22 +1,23 @@
1
1
  from types import FunctionType
2
2
  from typing import *
3
3
 
4
+ import datahold
5
+
4
6
  from preparse._items.Bundle import Bundle
5
7
  from preparse._items.Item import Item
6
8
  from preparse._items.Long import Long
7
9
  from preparse._items.Option import Option
8
10
  from preparse._items.Positional import Positional
9
11
  from preparse._items.Special import Special
10
- from preparse.core import warnings
11
- from preparse.core.enums import *
12
+ from preparse.enums.Nargs import Nargs
13
+ from preparse.enums.Tuning import Tuning
14
+ from preparse.warners.AmbiguousOptionWarner import AmbiguousOptionWarner as PAOW
15
+ from preparse.warners.InvalidOptionWarner import InvalidOptionWarner as PIOW
16
+ from preparse.warners.RequiredArgumentWarner import RequiredArgumentWarner as PRAW
17
+ from preparse.warners.UnallowedArgumentWarner import UnallowedArgumentWarner as PUAW
12
18
 
13
19
  __all__ = ["parse"]
14
20
 
15
- PAOW = warnings.PreparseAmbiguousOptionWarning
16
- PIOW = warnings.PreparseInvalidOptionWarning
17
- PUAW = warnings.PreparseUnallowedArgumentWarning
18
- PRAW = warnings.PreparseRequiredArgumentWarning
19
-
20
21
 
21
22
  def parse(
22
23
  args: list[str],
@@ -29,7 +30,7 @@ def parse_bundling(
29
30
  arg: str,
30
31
  *,
31
32
  cause: FunctionType,
32
- optdict: dict,
33
+ optNaming: datahold.DataNaming,
33
34
  ) -> Bundle:
34
35
  ans: Bundle
35
36
  x: int
@@ -40,7 +41,7 @@ def parse_bundling(
40
41
  continue
41
42
  ans.chars += y
42
43
  try:
43
- ans.nargs = optdict["-" + y]
44
+ ans.nargs = optNaming["-" + y]
44
45
  except KeyError:
45
46
  cause(PIOW, option=y, islong=False)
46
47
  ans.nargs = Nargs.NO_ARGUMENT
@@ -68,10 +69,10 @@ def parse_generator(
68
69
  items: list[Positional],
69
70
  *,
70
71
  abbr: Optional[Tuning],
71
- allowslong: bool,
72
- allowsshort: bool,
73
- expectsposix: bool,
74
- optdict: dict,
72
+ allowsLong: bool,
73
+ allowsShort: bool,
74
+ expectsPOSIX: bool,
75
+ optNaming: datahold.DataNaming,
75
76
  prog: str,
76
77
  warn: FunctionType,
77
78
  ) -> Generator[Any, Any, Any]:
@@ -79,7 +80,7 @@ def parse_generator(
79
80
  cause: FunctionType
80
81
  last: Optional[Option]
81
82
  item: Positional
82
- broken = not (allowslong or allowsshort)
83
+ broken = not (allowsLong or allowsShort)
83
84
  cause = parse_cause(prog=prog, warn=warn)
84
85
  last = None
85
86
  for item in items:
@@ -101,15 +102,15 @@ def parse_generator(
101
102
  if item.isobvious():
102
103
  # if the item is positional
103
104
  yield item
104
- broken = expectsposix
105
+ broken = expectsPOSIX
105
106
  continue
106
107
  last = parse_option(
107
108
  item.value,
108
109
  abbr=abbr,
109
- allowslong=allowslong,
110
- allowsshort=allowsshort,
110
+ allowsLong=allowsLong,
111
+ allowsShort=allowsShort,
111
112
  cause=cause,
112
- optdict=optdict,
113
+ optNaming=optNaming,
113
114
  )
114
115
  if not last.ishungry():
115
116
  yield last
@@ -128,24 +129,25 @@ def parse_long(
128
129
  arg: str,
129
130
  *,
130
131
  abbr: Optional[Tuning],
131
- allowsshort: bool,
132
+ allowsShort: bool,
132
133
  cause: FunctionType,
133
- optdict: dict,
134
+ optNaming: datahold.DataNaming,
134
135
  ) -> Long:
135
136
  ans: Long
137
+ fullkey_: str
138
+ minlen: int
136
139
  parts: list[str]
137
140
  parts = arg.split("=", 1)
138
141
  ans = Long(fullkey=parts.pop(0))
139
142
  if len(parts):
140
143
  ans.joined = True
141
144
  ans.right = parts.pop()
142
- ans.abbrlen = len(ans.fullkey)
143
- if ans.fullkey in optdict.keys():
145
+ if ans.fullkey in optNaming.keys():
144
146
  parts = [ans.fullkey]
145
- elif abbr is not None:
146
- parts = parse_long_startswith(ans.abbr, keys=optdict.keys())
147
+ elif abbr is None:
148
+ parts = [] # can be assumed
147
149
  else:
148
- parts = list() # can be assumed
150
+ parts = parse_long_startswith(ans.fullkey, keys=optNaming.keys())
149
151
  if len(parts) == 0:
150
152
  ans.nargs = Nargs.OPTIONAL_ARGUMENT
151
153
  cause(PIOW, option=arg, islong=True)
@@ -154,21 +156,22 @@ def parse_long(
154
156
  ans.nargs = Nargs.OPTIONAL_ARGUMENT
155
157
  cause(PAOW, option=arg, possibilities=parts)
156
158
  return ans
157
- (ans.fullkey,) = parts
159
+ (fullkey_,) = parts
158
160
  if abbr == Tuning.MINIMIZE:
159
- ans.abbrlen = len(ans.fullkey)
161
+ ans.fullkey = fullkey_
160
162
  if abbr == Tuning.MAXIMIZE:
161
- parts = list(optdict.keys())
162
- parts.remove(ans.fullkey)
163
- ans.abbrlen = parse_minlen(
164
- abbr=ans.abbr,
165
- allowsshort=allowsshort,
163
+ parts = list(optNaming.keys())
164
+ parts.remove(fullkey_)
165
+ minlen = parse_minlen(
166
+ abbr=ans.fullkey,
167
+ allowsShort=allowsShort,
166
168
  joined=ans.joined,
167
169
  keys=tuple(parts),
168
170
  )
169
- ans.nargs = optdict[ans.fullkey]
171
+ ans.fullkey = fullkey_[:minlen]
172
+ ans.nargs = optNaming[fullkey_]
170
173
  if (ans.nargs == Nargs.NO_ARGUMENT) and (ans.right is not None):
171
- cause(PUAW, option=ans.fullkey)
174
+ cause(PUAW, option=fullkey_)
172
175
  return ans
173
176
 
174
177
 
@@ -189,13 +192,13 @@ def parse_long_startswith(
189
192
  def parse_minlen(
190
193
  *,
191
194
  abbr: str,
192
- allowsshort: bool,
195
+ allowsShort: bool,
193
196
  joined: bool,
194
197
  keys: tuple[str, ...],
195
198
  ) -> int:
196
199
  m: int
197
200
  n: int
198
- m = 2 + allowsshort - joined
201
+ m = 2 + allowsShort - joined
199
202
  n = len(abbr)
200
203
  while n >= m and not any(z.startswith(abbr[:n]) for z in keys):
201
204
  n -= 1
@@ -206,22 +209,22 @@ def parse_option(
206
209
  arg: str,
207
210
  *,
208
211
  abbr: Optional[Tuning],
209
- allowslong: bool,
210
- allowsshort: bool,
212
+ allowsLong: bool,
213
+ allowsShort: bool,
211
214
  cause: FunctionType,
212
- optdict: dict,
215
+ optNaming: datahold.DataNaming,
213
216
  ) -> Option:
214
- if (allowslong and arg.startswith("--")) or not allowsshort:
217
+ if (allowsLong and arg.startswith("--")) or not allowsShort:
215
218
  return parse_long(
216
219
  arg,
217
220
  abbr=abbr,
218
- allowsshort=allowsshort,
221
+ allowsShort=allowsShort,
219
222
  cause=cause,
220
- optdict=optdict,
223
+ optNaming=optNaming,
221
224
  )
222
225
  else:
223
226
  return parse_bundling(
224
227
  arg,
225
228
  cause=cause,
226
- optdict=optdict,
229
+ optNaming=optNaming,
227
230
  )
@@ -1,5 +1,7 @@
1
1
  from typing import *
2
2
 
3
+ import namings
4
+
3
5
  __all__ = ["dataprop"]
4
6
 
5
7
 
@@ -10,11 +12,11 @@ def dataprop(func: Callable) -> property:
10
12
  return self._data[func.__name__]
11
13
 
12
14
  def fset(self: Self, value: Any) -> None:
13
- self._data = getattr(self, "_data", dict())
15
+ self._data = getattr(self, "_data", namings.Naming())
14
16
  self._data[func.__name__] = func(self, value)
15
17
 
16
- kwargs: dict[str, Any]
17
- kwargs = dict()
18
+ kwargs: namings.Naming
19
+ kwargs = namings.Naming()
18
20
  kwargs["doc"] = func.__doc__
19
21
  kwargs["fget"] = fget
20
22
  kwargs["fset"] = fset