36 lines
676 B
Python
36 lines
676 B
Python
import os
|
|
import datalad.api as dl
|
|
import hashlib
|
|
|
|
def str2list(string):
|
|
return string.split(",")
|
|
|
|
def list2str(mylist):
|
|
s = ",".join(mylist)
|
|
return s
|
|
|
|
cached = True
|
|
|
|
def m2k(m):
|
|
return 1/(2*m+8)
|
|
|
|
|
|
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
|