custom_tags.py 文件源码

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

项目:Server 作者: malaonline 项目源码 文件源码
def file_hash(filename):
    if not filename:
        return None

    def _get_full_path(path):
        rel_source_path = path.lstrip("/")
        if settings.STATIC_ROOT:
            full_path = os.path.join(settings.STATIC_ROOT, rel_source_path)
            if os.path.exists(full_path):
                return full_path
        try:
            full_path = finders.find(rel_source_path)
        except Exception:
            full_path = None
        return full_path

    full_path = _get_full_path(filename)
    return None if full_path is None \
        else hashlib.md5(open(full_path, 'rb').read()).hexdigest()[:7]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号