Finish first version of cache
This commit is contained in:
parent
da5ae22346
commit
2bf263679d
2 changed files with 8 additions and 9 deletions
|
@ -139,8 +139,8 @@ def load_records(path: str, meas_paths: list[str], preloaded = {}) -> list[Union
|
|||
returned_data: list = []
|
||||
for file in needed_data.keys():
|
||||
for key in list(needed_data[file]):
|
||||
if os.path.exists(cache_path(path, file, key)):
|
||||
returned_data.append(load_object(cache_path(path, file, key)))
|
||||
if os.path.exists(cache_path(path, file, key) + ".p"):
|
||||
returned_data.append(load_object(cache_path(path, file, key) + ".p"))
|
||||
else:
|
||||
if file not in preloaded:
|
||||
preloaded[file] = preload(path, file)
|
||||
|
@ -156,13 +156,13 @@ def cache_dir(path, file):
|
|||
cache_path_list = [path]
|
||||
cache_path_list.append(".cache")
|
||||
cache_path_list.extend(file.split("/")[1:])
|
||||
cache_path = os.path.join(cache_path_list)
|
||||
cache_path = "/".join(cache_path_list)
|
||||
return cache_path
|
||||
|
||||
|
||||
def cache_path(path, file, key):
|
||||
cache_path = os.path.join(cache_dir(path, file), key)
|
||||
return cache_path + ".p"
|
||||
return cache_path
|
||||
|
||||
|
||||
def preload(path: str, file: str):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue