hunterMakesPy 0.3.1__tar.gz → 0.3.3__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.
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/PKG-INFO +1 -1
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/hunterMakesPy/__init__.py +4 -17
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/hunterMakesPy/dataStructures.py +37 -40
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/hunterMakesPy/filesystemToolkit.py +0 -1
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/hunterMakesPy/parseParameters.py +13 -24
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/hunterMakesPy/tests/test_dataStructures.py +2 -9
- huntermakespy-0.3.3/hunterMakesPy/theTypes.py +21 -0
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/hunterMakesPy.egg-info/PKG-INFO +1 -1
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/pyproject.toml +1 -1
- huntermakespy-0.3.1/hunterMakesPy/theTypes.py +0 -9
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/LICENSE +0 -0
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/README.md +0 -0
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/hunterMakesPy/_theSSOT.py +0 -0
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/hunterMakesPy/coping.py +0 -0
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/hunterMakesPy/py.typed +0 -0
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/hunterMakesPy/pytestForYourUse.py +0 -0
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/hunterMakesPy/tests/__init__.py +0 -0
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/hunterMakesPy/tests/conftest.py +0 -0
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/hunterMakesPy/tests/test_coping.py +0 -0
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/hunterMakesPy/tests/test_filesystemToolkit.py +0 -0
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/hunterMakesPy/tests/test_parseParameters.py +0 -0
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/hunterMakesPy.egg-info/SOURCES.txt +0 -0
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/hunterMakesPy.egg-info/dependency_links.txt +0 -0
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/hunterMakesPy.egg-info/requires.txt +0 -0
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/hunterMakesPy.egg-info/top_level.txt +0 -0
- {huntermakespy-0.3.1 → huntermakespy-0.3.3}/setup.cfg +0 -0
|
@@ -8,28 +8,15 @@ This package provides:
|
|
|
8
8
|
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
from hunterMakesPy.theTypes import identifierDotAttribute as identifierDotAttribute
|
|
11
|
+
from hunterMakesPy.theTypes import identifierDotAttribute as identifierDotAttribute, Ordinals as Ordinals
|
|
13
12
|
|
|
14
|
-
# isort: split
|
|
15
13
|
from hunterMakesPy.coping import PackageSettings as PackageSettings, raiseIfNone as raiseIfNone
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
from hunterMakesPy.parseParameters import (
|
|
19
|
-
defineConcurrencyLimit as defineConcurrencyLimit, intInnit as intInnit, oopsieKwargsie as oopsieKwargsie)
|
|
15
|
+
from hunterMakesPy.parseParameters import defineConcurrencyLimit, intInnit, oopsieKwargsie
|
|
20
16
|
|
|
21
|
-
# isort: split
|
|
22
17
|
from hunterMakesPy.filesystemToolkit import (
|
|
23
|
-
importLogicalPath2Identifier
|
|
24
|
-
importPathFilename2Identifier as importPathFilename2Identifier, makeDirsSafely as makeDirsSafely,
|
|
25
|
-
writePython as writePython, writeStringToHere as writeStringToHere)
|
|
18
|
+
importLogicalPath2Identifier, importPathFilename2Identifier, makeDirsSafely, writePython, writeStringToHere)
|
|
26
19
|
|
|
27
|
-
|
|
28
|
-
from hunterMakesPy.dataStructures import (
|
|
29
|
-
stringItUp as stringItUp, updateExtendPolishDictionaryLists as updateExtendPolishDictionaryLists)
|
|
20
|
+
from hunterMakesPy.dataStructures import autoDecodingRLE, stringItUp, updateExtendPolishDictionaryLists
|
|
30
21
|
|
|
31
|
-
# isort: split
|
|
32
|
-
from hunterMakesPy.dataStructures import autoDecodingRLE as autoDecodingRLE
|
|
33
|
-
|
|
34
|
-
# isort: split
|
|
35
22
|
from hunterMakesPy._theSSOT import settingsPackage # pyright: ignore[reportUnusedImport]
|
|
@@ -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[小于]]:
|
|
@@ -270,7 +267,7 @@ def updateExtendPolishDictionaryLists(*dictionaryLists: Mapping[str, list[小于
|
|
|
270
267
|
for keyName, keyValue in dictionaryListTarget.items():
|
|
271
268
|
try:
|
|
272
269
|
ImaStr = str(keyName)
|
|
273
|
-
ImaList = list(keyValue)
|
|
270
|
+
ImaList: list[小于] = list(keyValue)
|
|
274
271
|
ePluribusUnum.setdefault(ImaStr, []).extend(ImaList)
|
|
275
272
|
except TypeError:
|
|
276
273
|
if killErroneousDataTypes:
|
|
@@ -148,21 +148,18 @@ def defineConcurrencyLimit(*, limit: bool | float | int | None, cpuTotal: int =
|
|
|
148
148
|
limit = limitFromString
|
|
149
149
|
if isinstance(limit, float) and abs(limit) >= 1:
|
|
150
150
|
limit = round(limit)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
concurrencyLimit = cpuTotal - abs(int(limit))
|
|
164
|
-
case _:
|
|
165
|
-
pass
|
|
151
|
+
if limit is None or limit is False or limit == 0:
|
|
152
|
+
pass
|
|
153
|
+
elif limit is True:
|
|
154
|
+
concurrencyLimit = 1
|
|
155
|
+
elif limit >= 1:
|
|
156
|
+
concurrencyLimit = int(limit)
|
|
157
|
+
elif 0 < limit < 1:
|
|
158
|
+
concurrencyLimit = round(limit * cpuTotal)
|
|
159
|
+
elif -1 < limit < 0:
|
|
160
|
+
concurrencyLimit = cpuTotal - abs(round(limit * cpuTotal))
|
|
161
|
+
elif limit <= -1:
|
|
162
|
+
concurrencyLimit = cpuTotal - abs(int(limit))
|
|
166
163
|
|
|
167
164
|
return max(int(concurrencyLimit), 1)
|
|
168
165
|
|
|
@@ -208,7 +205,7 @@ def intInnit(listInt_Allegedly: Iterable[Any], parameterName: str | None = None,
|
|
|
208
205
|
parameterType = parameterType or list
|
|
209
206
|
|
|
210
207
|
if not listInt_Allegedly:
|
|
211
|
-
message = f"I did not receive a value for {parameterName}, but it is required."
|
|
208
|
+
message: str = f"I did not receive a value for {parameterName}, but it is required."
|
|
212
209
|
raise ValueError(message)
|
|
213
210
|
|
|
214
211
|
# Be nice, and assume the input container is valid and every element is valid.
|
|
@@ -319,11 +316,3 @@ def oopsieKwargsie(huh: Any) -> bool | None | str:
|
|
|
319
316
|
if formatted == str(None):
|
|
320
317
|
return None
|
|
321
318
|
return huh
|
|
322
|
-
|
|
323
|
-
if __name__ == '__main__':
|
|
324
|
-
# Frankly, I cannot remember the precise reason I put this in some modules. It solved a concurrency problem I was having at the time,
|
|
325
|
-
# but it felt like a hack at the time and it feels even more like a hack now. I suspect I will eventually learn enough so that I can
|
|
326
|
-
# come full circle: know why I added it, know how I already fixed the real issue, and know that I can safely remove this. # noqa: ERA001
|
|
327
|
-
multiprocessing.set_start_method('spawn')
|
|
328
|
-
|
|
329
|
-
# Well, actually, I don't want to be programming for so long that I learn that much. I want to heal and do things in my areas of competency.
|
|
@@ -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]]()),
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""I type, you type, we all `type` for `theTypes`."""
|
|
2
|
+
from typing import Protocol, Self, TypeAlias
|
|
3
|
+
|
|
4
|
+
identifierDotAttribute: TypeAlias = str
|
|
5
|
+
"""`str` (***str***ing) representing a dotted attribute identifier.
|
|
6
|
+
|
|
7
|
+
`TypeAlias` for a `str` `object` using dot notation to access an attribute, such as 'scipy.signal.windows'.
|
|
8
|
+
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
class Ordinals(Protocol):
|
|
12
|
+
"""Any Python `object` `type` that may be ordered before or after a comparable `object` `type` by comparison operators."""
|
|
13
|
+
|
|
14
|
+
def __le__(self, not_self_selfButSelfSelf_youKnow: Self, /) -> bool:
|
|
15
|
+
"""Comparison by "***l***ess than or ***e***qual to"."""
|
|
16
|
+
...
|
|
17
|
+
|
|
18
|
+
def __lt__(self, not_self_selfButSelfSelf_youKnow: Self, /) -> bool:
|
|
19
|
+
"""Comparison by "***l***ess ***t***han"."""
|
|
20
|
+
...
|
|
21
|
+
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"""I type, you type, we all `type` for `theTypes`."""
|
|
2
|
-
from typing import TypeAlias
|
|
3
|
-
|
|
4
|
-
identifierDotAttribute: TypeAlias = str
|
|
5
|
-
"""`str` (***str***ing) representing a dotted attribute identifier.
|
|
6
|
-
|
|
7
|
-
`TypeAlias` for a `str` `object` using dot notation to access an attribute, such as 'scipy.signal.windows'.
|
|
8
|
-
|
|
9
|
-
"""
|
|
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
|