tarfs.py 文件源码

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

项目:pyfilesystem2 作者: PyFilesystem 项目源码 文件源码
def openbin(self, path, mode="r", buffering=-1, **options):
        self.check()
        path = relpath(normpath(path))

        if 'w' in mode or '+' in mode or 'a' in mode:
            raise errors.ResourceReadOnly(path)

        try:
            member = self._tar.getmember(path)
        except KeyError:
            six.raise_from(errors.ResourceNotFound(path), None)

        if not member.isfile():
            raise errors.FileExpected(path)

        rw = RawWrapper(self._tar.extractfile(member))

        if six.PY2: # Patch nonexistent file.flush in Python2
            def _flush():
                pass
            rw.flush = _flush

        return rw
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号