librsync.py 文件源码

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

项目:alicloud-duplicity 作者: aliyun 项目源码 文件源码
def __init__(self, basis_file, delta_file):
        """PatchedFile initializer - call with basis delta

        Here basis_file must be a true Python file, because we may
        need to seek() around in it a lot, and this is done in C.
        delta_file only needs read() and close() methods.

        """
        LikeFile.__init__(self, delta_file)
        if not isinstance(basis_file, types.FileType):
            """ tempfile.TemporaryFile() only guarantees a true file
            object on posix platforms. on cygwin/windows a file-like
            object whose file attribute is the underlying true file
            object is returned.
            """
            if hasattr(basis_file, 'file') and isinstance(basis_file.file, types.FileType):
                basis_file = basis_file.file
            else:
                raise TypeError(_("basis_file must be a (true) file or an object whose "
                                  "file attribute is the underlying true file object"))
        try:
            self.maker = _librsync.new_patchmaker(basis_file)
        except _librsync.librsyncError as e:
            raise librsyncError(str(e))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号