Skip to content

Commit 267daf4

Browse files
author
Alessandro De Maria
committed
Fix datatime issue when inventory key contains a date
1 parent c9aeb04 commit 267daf4

File tree

1 file changed

+2
-34
lines changed

1 file changed

+2
-34
lines changed

kapitan/utils.py

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
import tarfile
2121
import traceback
2222
from collections import Counter, defaultdict
23-
from functools import lru_cache, wraps
23+
from datetime import time
24+
from functools import lru_cache
2425
from hashlib import sha256
2526
from zipfile import ZipFile
2627

@@ -57,38 +58,6 @@ def fatal_error(message):
5758
sys.exit(1)
5859

5960

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-
9261
class termcolor:
9362
HEADER = "\033[95m"
9463
OKBLUE = "\033[94m"
@@ -270,7 +239,6 @@ def flatten_dict(d, parent_key="", sep="."):
270239
return dict(items)
271240

272241

273-
@hashable_lru_cache
274242
def deep_get(dictionary, keys, previousKey=None):
275243
"""Search recursively for 'keys' in 'dictionary' and return value, otherwise return None"""
276244
value = None

0 commit comments

Comments
 (0)