cache.py 文件源码

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

项目:conda-tools 作者: groutr 项目源码 文件源码
def _decompress_bz2(filename, blocksize=900*1024):
    """
    Decompress .tar.bz2 to .tar on disk (for faster access)

    Use TemporaryFile to guarentee write access.
    """
    if not filename.endswith('.tar.bz2'):
        return filename

    fd, path = mkstemp()
    with os.fdopen(fd, 'wb') as fo:
        with open(filename, 'rb') as fi:
            z = bz2.BZ2Decompressor()

            for block in iter(lambda: fi.read(blocksize), b''):
                fo.write(z.decompress(block))
    return path
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号