hunterMakesPy 0.3.1__py3-none-any.whl → 0.3.2__py3-none-any.whl
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.
- hunterMakesPy/__init__.py +3 -5
- hunterMakesPy/dataStructures.py +36 -39
- hunterMakesPy/tests/test_dataStructures.py +2 -9
- hunterMakesPy/theTypes.py +9 -1
- {huntermakespy-0.3.1.dist-info → huntermakespy-0.3.2.dist-info}/METADATA +1 -1
- {huntermakespy-0.3.1.dist-info → huntermakespy-0.3.2.dist-info}/RECORD +9 -9
- {huntermakespy-0.3.1.dist-info → huntermakespy-0.3.2.dist-info}/WHEEL +0 -0
- {huntermakespy-0.3.1.dist-info → huntermakespy-0.3.2.dist-info}/licenses/LICENSE +0 -0
- {huntermakespy-0.3.1.dist-info → huntermakespy-0.3.2.dist-info}/top_level.txt +0 -0
hunterMakesPy/__init__.py
CHANGED
|
@@ -9,7 +9,7 @@ This package provides:
|
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
11
|
# isort: split
|
|
12
|
-
from hunterMakesPy.theTypes import identifierDotAttribute as identifierDotAttribute
|
|
12
|
+
from hunterMakesPy.theTypes import identifierDotAttribute as identifierDotAttribute, Ordinals as Ordinals
|
|
13
13
|
|
|
14
14
|
# isort: split
|
|
15
15
|
from hunterMakesPy.coping import PackageSettings as PackageSettings, raiseIfNone as raiseIfNone
|
|
@@ -26,10 +26,8 @@ from hunterMakesPy.filesystemToolkit import (
|
|
|
26
26
|
|
|
27
27
|
# isort: split
|
|
28
28
|
from hunterMakesPy.dataStructures import (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
# isort: split
|
|
32
|
-
from hunterMakesPy.dataStructures import autoDecodingRLE as autoDecodingRLE
|
|
29
|
+
autoDecodingRLE as autoDecodingRLE, stringItUp as stringItUp,
|
|
30
|
+
updateExtendPolishDictionaryLists as updateExtendPolishDictionaryLists)
|
|
33
31
|
|
|
34
32
|
# isort: split
|
|
35
33
|
from hunterMakesPy._theSSOT import settingsPackage # pyright: ignore[reportUnusedImport]
|
hunterMakesPy/dataStructures.py
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"""Provides utilities for string extraction from nested data structures and merges multiple dictionaries containing lists into one dictionary."""
|
|
2
|
-
|
|
2
|
+
from charset_normalizer import CharsetMatch
|
|
3
3
|
from collections.abc import Mapping
|
|
4
|
+
from hunterMakesPy import Ordinals
|
|
4
5
|
from numpy import integer
|
|
5
6
|
from numpy.typing import NDArray
|
|
6
|
-
from typing import Any,
|
|
7
|
+
from typing import Any, cast, TYPE_CHECKING, TypeVar
|
|
8
|
+
import charset_normalizer
|
|
7
9
|
import more_itertools
|
|
8
10
|
import re as regex
|
|
11
|
+
import sys
|
|
9
12
|
|
|
10
13
|
if TYPE_CHECKING:
|
|
11
14
|
from collections.abc import Iterator
|
|
@@ -187,33 +190,37 @@ def stringItUp(*scrapPile: Any) -> list[str]:
|
|
|
187
190
|
listStrungUp: list[str] = []
|
|
188
191
|
|
|
189
192
|
def drill(KitKat: Any) -> None:
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
193
|
+
if isinstance(KitKat, str):
|
|
194
|
+
listStrungUp.append(KitKat)
|
|
195
|
+
elif (KitKat is None) or (isinstance(KitKat, (bool, bytearray, bytes, complex, float, int))):
|
|
196
|
+
listStrungUp.append(str(KitKat))
|
|
197
|
+
elif isinstance(KitKat, memoryview):
|
|
198
|
+
decodedString: CharsetMatch | None = charset_normalizer.from_bytes(KitKat.tobytes()).best()
|
|
199
|
+
if decodedString:
|
|
200
|
+
listStrungUp.append(str(decodedString))
|
|
201
|
+
elif isinstance(KitKat, dict):
|
|
202
|
+
DictDact: dict[Any, Any] = cast(dict[Any, Any], KitKat)
|
|
203
|
+
for broken, piece in DictDact.items():
|
|
204
|
+
drill(broken)
|
|
205
|
+
drill(piece)
|
|
206
|
+
elif isinstance(KitKat, (list, tuple, set, frozenset, range)):
|
|
207
|
+
for kit in KitKat: # pyright: ignore[reportUnknownVariableType]
|
|
208
|
+
drill(kit)
|
|
209
|
+
elif hasattr(KitKat, '__iter__'): # Unpack other iterables
|
|
210
|
+
for kat in KitKat:
|
|
211
|
+
drill(kat)
|
|
212
|
+
else:
|
|
213
|
+
try:
|
|
214
|
+
sharingIsCaring: str = KitKat.__str__()
|
|
215
|
+
listStrungUp.append(sharingIsCaring)
|
|
216
|
+
except AttributeError:
|
|
217
|
+
pass
|
|
218
|
+
except TypeError: # "The error traceback provided indicates that there is an issue when calling the __str__ method on an object that does not have this method properly defined, leading to a TypeError."
|
|
219
|
+
pass
|
|
220
|
+
except:
|
|
221
|
+
message: str = (f"\nWoah! I received '{repr(KitKat)}'.\nTheir report card says, 'Plays well with others: Needs improvement.'\n")
|
|
222
|
+
sys.stderr.write(message)
|
|
223
|
+
raise
|
|
217
224
|
try:
|
|
218
225
|
for scrap in scrapPile:
|
|
219
226
|
drill(scrap)
|
|
@@ -221,16 +228,6 @@ def stringItUp(*scrapPile: Any) -> list[str]:
|
|
|
221
228
|
listStrungUp.append(repr(scrap))
|
|
222
229
|
return listStrungUp
|
|
223
230
|
|
|
224
|
-
class Ordinals(Protocol):
|
|
225
|
-
"""Protocol for types that support ordering comparisons."""
|
|
226
|
-
|
|
227
|
-
def __le__(self, other: "Ordinals", /) -> bool:
|
|
228
|
-
"""Less than or equal to comparison."""
|
|
229
|
-
...
|
|
230
|
-
def __ge__(self, other: "Ordinals", /) -> bool:
|
|
231
|
-
"""Greater than or equal to comparison."""
|
|
232
|
-
...
|
|
233
|
-
|
|
234
231
|
小于 = TypeVar('小于', bound=Ordinals)
|
|
235
232
|
|
|
236
233
|
def updateExtendPolishDictionaryLists(*dictionaryLists: Mapping[str, list[小于] | set[小于] | tuple[小于, ...]], destroyDuplicates: bool = False, reorderLists: bool = False, killErroneousDataTypes: bool = False) -> dict[str, list[小于]]:
|
|
@@ -5,7 +5,7 @@ from fractions import Fraction
|
|
|
5
5
|
from hunterMakesPy import autoDecodingRLE, stringItUp, updateExtendPolishDictionaryLists
|
|
6
6
|
from hunterMakesPy.tests.conftest import standardizedEqualTo
|
|
7
7
|
from numpy.typing import NDArray
|
|
8
|
-
from typing import Any
|
|
8
|
+
from typing import Any
|
|
9
9
|
import datetime
|
|
10
10
|
import numpy
|
|
11
11
|
import pytest
|
|
@@ -35,6 +35,7 @@ class CustomIterable:
|
|
|
35
35
|
# Binary data - accepting either representation
|
|
36
36
|
("Prime bytes", [b'\x0B', b'\x0D', b'\x11'], [repr(b'\x0b'), repr(b'\x0d'), repr(b'\x11')]), # Let Python choose representation
|
|
37
37
|
("Custom bytearray", [bytearray(b"DEADBEEF")], ["bytearray(b'DEADBEEF')"]),
|
|
38
|
+
("Memory view decoded", memoryview(b"DEADBEEF"), ["DEADBEEF"]),
|
|
38
39
|
# Nested structures with unique values
|
|
39
40
|
("Nested dictionary", {'phi': 1.618, 'euler': 2.718}, ['phi', '1.618', 'euler', '2.718']),
|
|
40
41
|
("Mixed nesting", [{'NE': 37}, {'SW': 41}], ['NE', '37', 'SW', '41']),
|
|
@@ -59,14 +60,6 @@ def testStringItUp(description: str, value_scrapPile: list[Any], expected: list[
|
|
|
59
60
|
"""Test stringItUp with various inputs."""
|
|
60
61
|
standardizedEqualTo(expected, stringItUp, value_scrapPile)
|
|
61
62
|
|
|
62
|
-
@pytest.mark.parametrize("description,value_scrapPile,expected", [
|
|
63
|
-
("Memory view", memoryview(b"DEADBEEF"), ["<memory at 0x"]), # Special handling for memoryview
|
|
64
|
-
], ids=lambda x: x if isinstance(x, str) else "")
|
|
65
|
-
def testStringItUpErrorCases(description: Literal['Memory view'], value_scrapPile: memoryview, expected: list[str]) -> None:
|
|
66
|
-
result = stringItUp(value_scrapPile)
|
|
67
|
-
assert len(result) == 1
|
|
68
|
-
assert result[0].startswith(expected[0])
|
|
69
|
-
|
|
70
63
|
@pytest.mark.parametrize("description,value_dictionaryLists,keywordArguments,expected", [
|
|
71
64
|
("Mixed value types", ({'ne': [11, 'prime'], 'sw': [True, None]}, {'ne': [3.141, 'golden'], 'sw': [False, 'void']}), {'destroyDuplicates': False, 'reorderLists': False}, {'ne': [11, 'prime', 3.141, 'golden'], 'sw': [True, None, False, 'void']}),
|
|
72
65
|
("Empty dictionaries", (dict[str, list[Any]](), dict[str, list[Any]]()), dict[str, Any](), dict[str, list[Any]]()),
|
hunterMakesPy/theTypes.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"""I type, you type, we all `type` for `theTypes`."""
|
|
2
|
-
from typing import TypeAlias
|
|
2
|
+
from typing import Protocol, Self, TypeAlias
|
|
3
3
|
|
|
4
4
|
identifierDotAttribute: TypeAlias = str
|
|
5
5
|
"""`str` (***str***ing) representing a dotted attribute identifier.
|
|
@@ -7,3 +7,11 @@ identifierDotAttribute: TypeAlias = str
|
|
|
7
7
|
`TypeAlias` for a `str` `object` using dot notation to access an attribute, such as 'scipy.signal.windows'.
|
|
8
8
|
|
|
9
9
|
"""
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Ordinals(Protocol):
|
|
13
|
+
"""Any Python `object` `type` that may be ordered before or after a comparable `object` `type` using a less-than-or-equal-to comparison."""
|
|
14
|
+
|
|
15
|
+
def __le__(self, not_self_selfButSelfSelf_youKnow: Self, /) -> bool:
|
|
16
|
+
"""Comparison by "***l***ess than or ***e***qual to"."""
|
|
17
|
+
...
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
hunterMakesPy/__init__.py,sha256=
|
|
1
|
+
hunterMakesPy/__init__.py,sha256=oKeYKtnf8Y0oLe7UVlOFFx0BXi4GLEgdwEuJ3MOKc-4,1514
|
|
2
2
|
hunterMakesPy/_theSSOT.py,sha256=x9Rdmw0qeAqgmlMFyFYRTRV5kEDYXcN4aBZ4KjlnKEU,170
|
|
3
3
|
hunterMakesPy/coping.py,sha256=42a_1kB6zHeRpfbpPnjmhrgWTPvUtqE5W9z3tqu-K8w,6068
|
|
4
|
-
hunterMakesPy/dataStructures.py,sha256=
|
|
4
|
+
hunterMakesPy/dataStructures.py,sha256=GMl9AiQPuype67NZD7moLVzxezPVP38Cw3CoN4gRJI4,11920
|
|
5
5
|
hunterMakesPy/filesystemToolkit.py,sha256=8Yx8SH56w7g9wxpLjsdCaC1RvsW8Ur_cDrxhHaY9cLM,6848
|
|
6
6
|
hunterMakesPy/parseParameters.py,sha256=uQXoD89BfWAmRVT2yabyHtW7qITwAuCC9eh0sQFIV5Q,11966
|
|
7
7
|
hunterMakesPy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
hunterMakesPy/pytestForYourUse.py,sha256=GiN1C1gTTM0ZunRPEMnrKlLQLMdH0wF_ZGr_RPgRjjA,500
|
|
9
|
-
hunterMakesPy/theTypes.py,sha256=
|
|
9
|
+
hunterMakesPy/theTypes.py,sha256=gqTGyqrLySOKKXG0NNgixqwePPZ2_hBlzKNYS3jpHtk,627
|
|
10
10
|
hunterMakesPy/tests/__init__.py,sha256=C_FzfKDi_VrGVxlenWHyOYtKShAKlt3KW14jeRx1mQI,224
|
|
11
11
|
hunterMakesPy/tests/conftest.py,sha256=NZQPRiwvGhP16hJ6WGGm9eKLxfQArYV8E9X12YzSpP0,2827
|
|
12
12
|
hunterMakesPy/tests/test_coping.py,sha256=mH89TUAL6fJanBLlhdVlCNNQqm5OpdcQMP_p5W2JJwo,9860
|
|
13
|
-
hunterMakesPy/tests/test_dataStructures.py,sha256=
|
|
13
|
+
hunterMakesPy/tests/test_dataStructures.py,sha256=WQlq98SllAPSUEjvIHZ9Az2pKNWeLNP4dnl3UyP9yuc,16004
|
|
14
14
|
hunterMakesPy/tests/test_filesystemToolkit.py,sha256=_CoSMzstJwWZ_tkNyIqclOIIqTaY2tYfUIgxGFfC0Jk,15335
|
|
15
15
|
hunterMakesPy/tests/test_parseParameters.py,sha256=UKf1hwhLtXYL96VVJNf8NpJOyzRLO204pd-9PdDjufA,13267
|
|
16
|
-
huntermakespy-0.3.
|
|
17
|
-
huntermakespy-0.3.
|
|
18
|
-
huntermakespy-0.3.
|
|
19
|
-
huntermakespy-0.3.
|
|
20
|
-
huntermakespy-0.3.
|
|
16
|
+
huntermakespy-0.3.2.dist-info/licenses/LICENSE,sha256=NxH5Y8BdC-gNU-WSMwim3uMbID2iNDXJz7fHtuTdXhk,19346
|
|
17
|
+
huntermakespy-0.3.2.dist-info/METADATA,sha256=cSkWkEXB8eEXH5StDtTZKsc2x5uTN1IlAC1xJapoHU4,6319
|
|
18
|
+
huntermakespy-0.3.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
19
|
+
huntermakespy-0.3.2.dist-info/top_level.txt,sha256=Uh4bj8EDTdsRpqY1VlK_his_B4HDfZ6Tqrwhoj75P_w,14
|
|
20
|
+
huntermakespy-0.3.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|