document.py 文件源码

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

项目:gransk 作者: pcbje 项目源码 文件源码
def set_id(self, data):
    """
    Set ID of document. To allow multiple files with the same path, the
    digest of supplied data (e.g. first 4KB) is appended to the doc ID.

    :param data: Data to append to docuemnt path.
    :type data: Anything digestable by hashlib.
    """
    digest = hashlib.md5()
    digest.update(self.path.encode('utf-8'))

    if isinstance(data, unicode):
      data = data.encode('utf-8')

    digest.update(data)
    self.docid = digest.hexdigest()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号