zhmiscellany 6.1.6__py3-none-any.whl → 6.1.8__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/_processing_supportfuncs.py +1 -1
- zhmiscellany/fileio.py +39 -8
- {zhmiscellany-6.1.6.dist-info → zhmiscellany-6.1.8.dist-info}/METADATA +4 -1
- {zhmiscellany-6.1.6.dist-info → zhmiscellany-6.1.8.dist-info}/RECORD +6 -6
- {zhmiscellany-6.1.6.dist-info → zhmiscellany-6.1.8.dist-info}/WHEEL +1 -1
- {zhmiscellany-6.1.6.dist-info → zhmiscellany-6.1.8.dist-info}/top_level.txt +0 -0
|
@@ -217,7 +217,7 @@ from zhmiscellany._processing_supportfuncs import _ray_init_thread; _ray_init_th
|
|
|
217
217
|
_ray_init_thread.join()
|
|
218
218
|
|
|
219
219
|
if not expect_crashes:
|
|
220
|
-
@ray.remote(max_retries=max_retries)
|
|
220
|
+
@ray.remote(max_retries=max_retries, num_cpus=0)
|
|
221
221
|
def worker(func, *args):
|
|
222
222
|
return func(*args)
|
|
223
223
|
|
zhmiscellany/fileio.py
CHANGED
|
@@ -8,6 +8,8 @@ from itertools import chain
|
|
|
8
8
|
import tempfile
|
|
9
9
|
import random
|
|
10
10
|
import string
|
|
11
|
+
import orjson
|
|
12
|
+
from datetime import datetime
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
def read_json_file(file_path):
|
|
@@ -207,22 +209,51 @@ def chdir_to_script_dir():
|
|
|
207
209
|
os.chdir(os.path.dirname(get_script_path()))
|
|
208
210
|
|
|
209
211
|
|
|
210
|
-
def cache(
|
|
212
|
+
def cache(function, *args, **kwargs):
|
|
211
213
|
cache_folder = 'zhmiscellany_cache'
|
|
212
|
-
zhmiscellany.fileio.create_folder(cache_folder)
|
|
213
214
|
|
|
214
|
-
def
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
def get_hash_orjson(data):
|
|
216
|
+
def default_converter(obj):
|
|
217
|
+
# SETS: Must be sorted to ensure determinism!
|
|
218
|
+
# JSON doesn't support sets, so we turn them into sorted lists.
|
|
219
|
+
if isinstance(obj, set):
|
|
220
|
+
return sorted(list(obj))
|
|
217
221
|
|
|
218
|
-
|
|
222
|
+
# BYTES: Decode to string (if utf-8) or hex
|
|
223
|
+
if isinstance(obj, bytes):
|
|
224
|
+
return obj.hex()
|
|
219
225
|
|
|
220
|
-
|
|
226
|
+
# DATETIMES: Convert to ISO format string
|
|
227
|
+
if isinstance(obj, datetime):
|
|
228
|
+
return obj.isoformat()
|
|
229
|
+
|
|
230
|
+
# CUSTOM OBJECTS: Try to return their __dict__ or string rep
|
|
231
|
+
if hasattr(obj, '__dict__'):
|
|
232
|
+
return obj.__dict__
|
|
233
|
+
|
|
234
|
+
# Fallback: String representation (risky if str() format changes)
|
|
235
|
+
return str(obj)
|
|
236
|
+
json_bytes = orjson.dumps(
|
|
237
|
+
data,
|
|
238
|
+
default=default_converter,
|
|
239
|
+
option=orjson.OPT_SORT_KEYS
|
|
240
|
+
)
|
|
241
|
+
return hashlib.md5(json_bytes).hexdigest()
|
|
242
|
+
|
|
243
|
+
seed = {
|
|
244
|
+
'args': fast_dill_dumps(args),
|
|
245
|
+
'kwargs': fast_dill_dumps(kwargs)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
seed_hash = get_hash_orjson(seed)
|
|
249
|
+
|
|
250
|
+
cache_file = f'{cache_folder}/cache_{function.__name__}_{seed_hash}.pkl'
|
|
221
251
|
|
|
222
252
|
if os.path.exists(cache_file):
|
|
223
253
|
return load_object_from_file(cache_file)
|
|
224
254
|
else:
|
|
225
|
-
result = function(
|
|
255
|
+
result = function(*args, **kwargs)
|
|
256
|
+
zhmiscellany.fileio.create_folder(cache_folder)
|
|
226
257
|
save_object_to_file(result, cache_file)
|
|
227
258
|
return result
|
|
228
259
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: zhmiscellany
|
|
3
|
-
Version: 6.1.
|
|
3
|
+
Version: 6.1.8
|
|
4
4
|
Summary: A collection of useful/interesting python libraries made by zh.
|
|
5
5
|
Home-page: https://discord.gg/ThBBAuueVJ
|
|
6
6
|
Author: zh
|
|
@@ -20,6 +20,7 @@ Requires-Dist: psutil>=0
|
|
|
20
20
|
Requires-Dist: kthread>=0
|
|
21
21
|
Requires-Dist: pillow>=0
|
|
22
22
|
Requires-Dist: fuzzywuzzy>=0
|
|
23
|
+
Requires-Dist: orjson>=0
|
|
23
24
|
Requires-Dist: pyautogui>=0; sys_platform == "linux"
|
|
24
25
|
Requires-Dist: ray>=0; sys_platform == "win32"
|
|
25
26
|
Requires-Dist: pywin32>=0; sys_platform == "win32"
|
|
@@ -43,6 +44,8 @@ Introduction
|
|
|
43
44
|
|
|
44
45
|
Can be installed with `pip install zhmiscellany`
|
|
45
46
|
|
|
47
|
+
Supports Linux! (Some functionality reduced)
|
|
48
|
+
|
|
46
49
|
Currently, the package stands at 149 functions/classes/bindings across 15 modules.
|
|
47
50
|
|
|
48
51
|
The git repository for this package can be found [here](https://github.com/zen-ham/zhmiscellany). The docs also look nicer on github.
|
|
@@ -2,13 +2,13 @@ zhmiscellany/__init__.py,sha256=Oh3gAJRWq2aUEgkolmQyiZOQ3iey5OC4NA2XaTHuVv4,1139
|
|
|
2
2
|
zhmiscellany/_discord_supportfuncs.py,sha256=RotSpurqFtL5q6v_ST1e2Y_1qJMaHp1CDsF5i-gR4ec,6524
|
|
3
3
|
zhmiscellany/_fileio_supportfuncs.py,sha256=soibLv9nOR79sHQ2MGQH2O6MhnqdXqI7ybxHSN2Tfac,434
|
|
4
4
|
zhmiscellany/_misc_supportfuncs.py,sha256=RH1keGtoVjJOFh7MWOTJ2BJijLLeEvsMy9tNumdd6Uk,9944
|
|
5
|
-
zhmiscellany/_processing_supportfuncs.py,sha256=
|
|
5
|
+
zhmiscellany/_processing_supportfuncs.py,sha256=XWyH6VNQLhHqnYLL9LJwU0hJ6PGzZNJXT8Gfmb-GRw8,11083
|
|
6
6
|
zhmiscellany/_py_resources.py,sha256=HqJs5aRLymLZ2J5Io8g6bY58pGWhN9b8vCktC2DW4KQ,229009
|
|
7
7
|
zhmiscellany/_resource_files_lookup.py,sha256=hsgPW0dngokgqWrAVAv5rUo-eobzJPjvWHt4xrOG5l0,856
|
|
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=VZY6kFEaHUHVFVYPDFiXqFVhogP_8dZJI9lITRVlVO4,19273
|
|
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.1.
|
|
25
|
-
zhmiscellany-6.1.
|
|
26
|
-
zhmiscellany-6.1.
|
|
27
|
-
zhmiscellany-6.1.
|
|
24
|
+
zhmiscellany-6.1.8.dist-info/METADATA,sha256=gBTbEel5SULO595eMgWhvWfm3LvTfxOYFFfg-w6qR44,43897
|
|
25
|
+
zhmiscellany-6.1.8.dist-info/WHEEL,sha256=hPN0AlP2dZM_3ZJZWP4WooepkmU9wzjGgCLCeFjkHLA,92
|
|
26
|
+
zhmiscellany-6.1.8.dist-info/top_level.txt,sha256=ioDtsrevCI52rTxZntMPljRIBsZs73tD0hI00HektiE,13
|
|
27
|
+
zhmiscellany-6.1.8.dist-info/RECORD,,
|
|
File without changes
|