|
20 | 20 | import tarfile
|
21 | 21 | import traceback
|
22 | 22 | from collections import Counter, defaultdict
|
23 |
| -from functools import lru_cache, wraps |
| 23 | +from datetime import time |
| 24 | +from functools import lru_cache |
24 | 25 | from hashlib import sha256
|
25 | 26 | from zipfile import ZipFile
|
26 | 27 |
|
@@ -57,38 +58,6 @@ def fatal_error(message):
|
57 | 58 | sys.exit(1)
|
58 | 59 |
|
59 | 60 |
|
60 |
| -def hashable_lru_cache(func): |
61 |
| - """Usable instead of lru_cache for functions using unhashable objects""" |
62 |
| - |
63 |
| - cache = lru_cache(maxsize=256) |
64 |
| - |
65 |
| - def deserialise(value): |
66 |
| - try: |
67 |
| - return json.loads(value) |
68 |
| - except Exception: |
69 |
| - logger.debug("hashable_lru_cache: %s not serialiseable, using generic lru_cache instead", value) |
70 |
| - return value |
71 |
| - |
72 |
| - def func_with_serialized_params(*args, **kwargs): |
73 |
| - _args = tuple([deserialise(arg) for arg in args]) |
74 |
| - _kwargs = {k: deserialise(v) for k, v in kwargs.items()} |
75 |
| - return func(*_args, **_kwargs) |
76 |
| - |
77 |
| - cached_function = cache(func_with_serialized_params) |
78 |
| - |
79 |
| - @wraps(func) |
80 |
| - def lru_decorator(*args, **kwargs): |
81 |
| - _args = tuple([json.dumps(arg, sort_keys=True) if type(arg) in (list, dict) else arg for arg in args]) |
82 |
| - _kwargs = { |
83 |
| - k: json.dumps(v, sort_keys=True) if type(v) in (list, dict) else v for k, v in kwargs.items() |
84 |
| - } |
85 |
| - return cached_function(*_args, **_kwargs) |
86 |
| - |
87 |
| - lru_decorator.cache_info = cached_function.cache_info |
88 |
| - lru_decorator.cache_clear = cached_function.cache_clear |
89 |
| - return lru_decorator |
90 |
| - |
91 |
| - |
92 | 61 | class termcolor:
|
93 | 62 | HEADER = "\033[95m"
|
94 | 63 | OKBLUE = "\033[94m"
|
@@ -270,7 +239,6 @@ def flatten_dict(d, parent_key="", sep="."):
|
270 | 239 | return dict(items)
|
271 | 240 |
|
272 | 241 |
|
273 |
| -@hashable_lru_cache |
274 | 242 | def deep_get(dictionary, keys, previousKey=None):
|
275 | 243 | """Search recursively for 'keys' in 'dictionary' and return value, otherwise return None"""
|
276 | 244 | value = None
|
|
0 commit comments