hunterMakesPy 0.3.1__py3-none-any.whl → 0.3.3__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 CHANGED
@@ -8,28 +8,15 @@ This package provides:
8
8
 
9
9
  """
10
10
 
11
- # isort: split
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
- # isort: split
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 as importLogicalPath2Identifier,
24
- importPathFilename2Identifier as importPathFilename2Identifier, makeDirsSafely as makeDirsSafely,
25
- writePython as writePython, writeStringToHere as writeStringToHere)
18
+ importLogicalPath2Identifier, importPathFilename2Identifier, makeDirsSafely, writePython, writeStringToHere)
26
19
 
27
- # isort: split
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, Protocol, TYPE_CHECKING, TypeVar
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
- match KitKat:
191
- case str():
192
- listStrungUp.append(KitKat)
193
- case bool() | bytearray() | bytes() | complex() | float() | int() | memoryview() | None:
194
- listStrungUp.append(str(KitKat))
195
- case dict():
196
- for broken, piece in KitKat.items():
197
- drill(broken)
198
- drill(piece)
199
- case list() | tuple() | set() | frozenset() | range():
200
- for kit in KitKat:
201
- drill(kit)
202
- case _:
203
- if hasattr(KitKat, '__iter__'): # Unpack other iterables
204
- for kat in KitKat:
205
- drill(kat)
206
- else:
207
- try:
208
- sharingIsCaring = KitKat.__str__()
209
- listStrungUp.append(sharingIsCaring)
210
- except AttributeError:
211
- pass
212
- 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."
213
- pass
214
- except:
215
- print(f"\nWoah! I received '{repr(KitKat)}'.\nTheir report card says, 'Plays well with others: Needs improvement.'\n") # noqa: T201
216
- raise
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:
@@ -118,7 +118,6 @@ settings_isortDEFAULT: dict[str, bool | int | str | list[str]] = {
118
118
  "lines_between_types": 0,
119
119
  "multi_line_output": 4,
120
120
  "no_sections": True,
121
- "skip": ["__init__.py"], # TODO think
122
121
  "use_parentheses": True,
123
122
  }
124
123
 
@@ -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
- match limit:
152
- case None | False | 0:
153
- pass
154
- case True:
155
- concurrencyLimit = 1
156
- case _ if limit >= 1:
157
- concurrencyLimit = int(limit)
158
- case _ if 0 < limit < 1:
159
- concurrencyLimit = round(limit * cpuTotal)
160
- case _ if -1 < limit < 0:
161
- concurrencyLimit = cpuTotal - abs(round(limit * cpuTotal))
162
- case _ if limit <= -1:
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, Literal
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,15 @@ 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
+ 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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hunterMakesPy
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: Easy Python functions making making functional Python functions easier.
5
5
  Author-email: Hunter Hogan <HunterHogan@pm.me>
6
6
  License: CC-BY-NC-4.0
@@ -1,20 +1,20 @@
1
- hunterMakesPy/__init__.py,sha256=N2Bvmacvs9z8ITWWjQr6-5LQHZ1FG5KL6v-pR1m6fCY,1547
1
+ hunterMakesPy/__init__.py,sha256=bydhevjZG6_JT2q_v9rfozvjhXVqyyUGCovL6EwxlBk,1168
2
2
  hunterMakesPy/_theSSOT.py,sha256=x9Rdmw0qeAqgmlMFyFYRTRV5kEDYXcN4aBZ4KjlnKEU,170
3
3
  hunterMakesPy/coping.py,sha256=42a_1kB6zHeRpfbpPnjmhrgWTPvUtqE5W9z3tqu-K8w,6068
4
- hunterMakesPy/dataStructures.py,sha256=0-BRFriADFKX9pvjYj03ukj021ZII61wet2Wq2yAEdM,11776
5
- hunterMakesPy/filesystemToolkit.py,sha256=8Yx8SH56w7g9wxpLjsdCaC1RvsW8Ur_cDrxhHaY9cLM,6848
6
- hunterMakesPy/parseParameters.py,sha256=uQXoD89BfWAmRVT2yabyHtW7qITwAuCC9eh0sQFIV5Q,11966
4
+ hunterMakesPy/dataStructures.py,sha256=GbFk5uJskkjL5WNCSJbgn7BKQVh0f792gZ4zgSod9H8,11934
5
+ hunterMakesPy/filesystemToolkit.py,sha256=4zgXrDELBnS2UJ4sGPJVFyyrjDwfF0evnGIWssm--Jk,6809
6
+ hunterMakesPy/parseParameters.py,sha256=k5sGBoCeVRK02lNze59xPb99UiXm2l-HXI5HQPcKHnY,11321
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=C2d0uLn1VIx6_2CK41it3IP7iplSQqe51tzWc-RT320,306
9
+ hunterMakesPy/theTypes.py,sha256=Ce2hGCsBgd_DaUVoWZ6Iq-Lp4qf6053orHq0o52ssgM,734
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=OouddHjN-Km26U92jYwnjYeP6_Y2DrJLgq3qD_8GvGw,16393
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.1.dist-info/licenses/LICENSE,sha256=NxH5Y8BdC-gNU-WSMwim3uMbID2iNDXJz7fHtuTdXhk,19346
17
- huntermakespy-0.3.1.dist-info/METADATA,sha256=_rbA9J-buuKyZvp8vkiYMhSipTCPdLFGdjRsRNtK5oU,6319
18
- huntermakespy-0.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
- huntermakespy-0.3.1.dist-info/top_level.txt,sha256=Uh4bj8EDTdsRpqY1VlK_his_B4HDfZ6Tqrwhoj75P_w,14
20
- huntermakespy-0.3.1.dist-info/RECORD,,
16
+ huntermakespy-0.3.3.dist-info/licenses/LICENSE,sha256=NxH5Y8BdC-gNU-WSMwim3uMbID2iNDXJz7fHtuTdXhk,19346
17
+ huntermakespy-0.3.3.dist-info/METADATA,sha256=VNrznpDWhCCoxUM0nAufsjImFAiVagnHgFbCPPXxnzQ,6319
18
+ huntermakespy-0.3.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
+ huntermakespy-0.3.3.dist-info/top_level.txt,sha256=Uh4bj8EDTdsRpqY1VlK_his_B4HDfZ6Tqrwhoj75P_w,14
20
+ huntermakespy-0.3.3.dist-info/RECORD,,