From 7e38d71b90e13927bea8d56511b8ff809ecde2dd Mon Sep 17 00:00:00 2001 From: Justus Kuhlmann Date: Fri, 28 Nov 2025 16:57:15 +0100 Subject: [PATCH] re-add some tools functions --- corrlib/tools.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/corrlib/tools.py b/corrlib/tools.py index 337912e..e8a9c18 100644 --- a/corrlib/tools.py +++ b/corrlib/tools.py @@ -17,3 +17,20 @@ def m2k(m): def k2m(k): return (1/(2*k))-4 + + +def record2name_key(record_path: str): + file = record_path.split("::")[0] + key = record_path.split("::")[1] + return file, key + + +def name_key2record(name: str, key: str): + return name + "::" + key + + +def make_version_hash(path, record): + file, key = record2name_key(record) + with open(os.path.join(path, file), 'rb') as fp: + file_hash = hashlib.file_digest(fp, 'sha1').hexdigest() + return file_hash