def get_mosfit_hash(salt=u''):
"""Return a unique hash for the MOSFiT code."""
import fnmatch
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
matches = []
for root, dirnames, filenames in os.walk(dir_path):
for filename in fnmatch.filter(filenames, '*.py'):
matches.append(os.path.join(root, filename))
matches = list(sorted(list(matches)))
code_str = salt
for match in matches:
with codecs.open(match, 'r', 'utf-8') as f:
code_str += f.read()
return hashlib.sha512(hash_bytes(code_str)).hexdigest()[:16]
评论列表
文章目录