utils.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:MOSFiT 作者: guillochon 项目源码 文件源码
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]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号