zhmiscellany 6.1.8__py3-none-any.whl → 6.2.0__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.
- zhmiscellany/fileio.py +11 -3
- {zhmiscellany-6.1.8.dist-info → zhmiscellany-6.2.0.dist-info}/METADATA +1 -1
- {zhmiscellany-6.1.8.dist-info → zhmiscellany-6.2.0.dist-info}/RECORD +5 -5
- {zhmiscellany-6.1.8.dist-info → zhmiscellany-6.2.0.dist-info}/WHEEL +0 -0
- {zhmiscellany-6.1.8.dist-info → zhmiscellany-6.2.0.dist-info}/top_level.txt +0 -0
zhmiscellany/fileio.py
CHANGED
|
@@ -10,6 +10,7 @@ import random
|
|
|
10
10
|
import string
|
|
11
11
|
import orjson
|
|
12
12
|
from datetime import datetime
|
|
13
|
+
import inspect
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
def read_json_file(file_path):
|
|
@@ -214,6 +215,12 @@ def cache(function, *args, **kwargs):
|
|
|
214
215
|
|
|
215
216
|
def get_hash_orjson(data):
|
|
216
217
|
def default_converter(obj):
|
|
218
|
+
if callable(obj):
|
|
219
|
+
try:
|
|
220
|
+
return inspect.getsource(obj)
|
|
221
|
+
except (OSError, TypeError):
|
|
222
|
+
return str(obj) # Fallback for lambdas/partials
|
|
223
|
+
|
|
217
224
|
# SETS: Must be sorted to ensure determinism!
|
|
218
225
|
# JSON doesn't support sets, so we turn them into sorted lists.
|
|
219
226
|
if isinstance(obj, set):
|
|
@@ -230,7 +237,7 @@ def cache(function, *args, **kwargs):
|
|
|
230
237
|
# CUSTOM OBJECTS: Try to return their __dict__ or string rep
|
|
231
238
|
if hasattr(obj, '__dict__'):
|
|
232
239
|
return obj.__dict__
|
|
233
|
-
|
|
240
|
+
|
|
234
241
|
# Fallback: String representation (risky if str() format changes)
|
|
235
242
|
return str(obj)
|
|
236
243
|
json_bytes = orjson.dumps(
|
|
@@ -241,8 +248,9 @@ def cache(function, *args, **kwargs):
|
|
|
241
248
|
return hashlib.md5(json_bytes).hexdigest()
|
|
242
249
|
|
|
243
250
|
seed = {
|
|
244
|
-
'
|
|
245
|
-
'
|
|
251
|
+
'function': function,
|
|
252
|
+
'args': args,
|
|
253
|
+
'kwargs': kwargs
|
|
246
254
|
}
|
|
247
255
|
|
|
248
256
|
seed_hash = get_hash_orjson(seed)
|
|
@@ -8,7 +8,7 @@ zhmiscellany/_resource_files_lookup.py,sha256=hsgPW0dngokgqWrAVAv5rUo-eobzJPjvWH
|
|
|
8
8
|
zhmiscellany/cpp.py,sha256=XEUEoIKCDCdY5VgwNWE5oXrGjtsmGdz_MnaVwQmi2dk,179
|
|
9
9
|
zhmiscellany/dict.py,sha256=0BZJ5eK-MurAHYV1OPa0jdGTr-QEWos7ZM0npb-tN9I,81
|
|
10
10
|
zhmiscellany/discord.py,sha256=nzXjRnJbuYbuH4hScqqdsF61VeXx8xiYrwp_AKTWt9o,19774
|
|
11
|
-
zhmiscellany/fileio.py,sha256=
|
|
11
|
+
zhmiscellany/fileio.py,sha256=YqIfdit0TQr4VYmpCftoqwtddqo1OZz6duI7BKg7Dy4,19532
|
|
12
12
|
zhmiscellany/gui.py,sha256=BDmM7e5ITKQuzxSzaYvPapQuPbQjCMTOq-GyMcLCIgg,10198
|
|
13
13
|
zhmiscellany/image.py,sha256=qUjxiYpc2VVZp2vwr1vN36O2PVQ7YlMKzhegQ1u4c0M,8198
|
|
14
14
|
zhmiscellany/list.py,sha256=S8Z85bLJEP9lk2JkGpzUcG6kpRB7a-NWDIHMPiF5bKo,1473
|
|
@@ -21,7 +21,7 @@ zhmiscellany/pipes.py,sha256=zETvWP4PF-PuSzYwR1UCodY4ftNAgmCChb9DUMofXok,4657
|
|
|
21
21
|
zhmiscellany/processing.py,sha256=sDKIbzG9TNFyT6yJ4TJL59taG-59_v3CBLekVSLrwgE,10899
|
|
22
22
|
zhmiscellany/rust.py,sha256=znN6DYNoa_p-braTuDZKvUnXX8reWLFu_dG4fv2vLR0,442
|
|
23
23
|
zhmiscellany/string.py,sha256=xyqE6V5YF2nieZDcg5ZrXTIrH2D9oDRbZ5vQGz8rPys,4787
|
|
24
|
-
zhmiscellany-6.
|
|
25
|
-
zhmiscellany-6.
|
|
26
|
-
zhmiscellany-6.
|
|
27
|
-
zhmiscellany-6.
|
|
24
|
+
zhmiscellany-6.2.0.dist-info/METADATA,sha256=DTek7AuyuDVVPMuJHunsnv3oD5CPsHgJYLXaRFJaC78,43897
|
|
25
|
+
zhmiscellany-6.2.0.dist-info/WHEEL,sha256=hPN0AlP2dZM_3ZJZWP4WooepkmU9wzjGgCLCeFjkHLA,92
|
|
26
|
+
zhmiscellany-6.2.0.dist-info/top_level.txt,sha256=ioDtsrevCI52rTxZntMPljRIBsZs73tD0hI00HektiE,13
|
|
27
|
+
zhmiscellany-6.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|