Python tarfile 模块,RECORDSIZE 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用tarfile.RECORDSIZE

项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_stream_padding(self):
        # Test for bug #1543303.
        tar = tarfile.open(tmpname, self.mode)
        tar.close()

        if self.mode.endswith("gz"):
            with gzip.GzipFile(tmpname) as fobj:
                data = fobj.read()
        elif self.mode.endswith("bz2"):
            dec = bz2.BZ2Decompressor()
            with open(tmpname, "rb") as fobj:
                data = fobj.read()
            data = dec.decompress(data)
            self.assertTrue(len(dec.unused_data) == 0,
                    "found trailing data")
        else:
            with open(tmpname, "rb") as fobj:
                data = fobj.read()

        self.assertTrue(data.count(b"\0") == tarfile.RECORDSIZE,
                         "incorrect zero padding")
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_stream_padding(self):
        # Test for bug #1543303.
        tar = tarfile.open(tmpname, self.mode)
        tar.close()

        if self.mode.endswith("gz"):
            with gzip.GzipFile(tmpname) as fobj:
                data = fobj.read()
        elif self.mode.endswith("bz2"):
            dec = bz2.BZ2Decompressor()
            with open(tmpname, "rb") as fobj:
                data = fobj.read()
            data = dec.decompress(data)
            self.assertTrue(len(dec.unused_data) == 0,
                    "found trailing data")
        else:
            with open(tmpname, "rb") as fobj:
                data = fobj.read()

        self.assertTrue(data.count("\0") == tarfile.RECORDSIZE,
                         "incorrect zero padding")
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_stream_padding(self):
        # Test for bug #1543303.
        tar = tarfile.open(tmpname, self.mode)
        tar.close()

        if self.mode.endswith("gz"):
            with gzip.GzipFile(tmpname) as fobj:
                data = fobj.read()
        elif self.mode.endswith("bz2"):
            dec = bz2.BZ2Decompressor()
            with open(tmpname, "rb") as fobj:
                data = fobj.read()
            data = dec.decompress(data)
            self.assertTrue(len(dec.unused_data) == 0,
                    "found trailing data")
        else:
            with open(tmpname, "rb") as fobj:
                data = fobj.read()

        self.assertTrue(data.count("\0") == tarfile.RECORDSIZE,
                         "incorrect zero padding")
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def test_stream_padding(self):
        # Test for bug #1543303.
        tar = tarfile.open(tmpname, self.mode)
        tar.close()

        if self.mode.endswith("gz"):
            fobj = gzip.GzipFile(tmpname)
            data = fobj.read()
            fobj.close()
        elif self.mode.endswith("bz2"):
            dec = bz2.BZ2Decompressor()
            with open(tmpname, "rb") as fobj:
                data = fobj.read()
            data = dec.decompress(data)
            self.assertTrue(len(dec.unused_data) == 0,
                    "found trailing data")
        else:
            fobj = open(tmpname, "rb")
            data = fobj.read()
            fobj.close()

        self.assertTrue(data.count("\0") == tarfile.RECORDSIZE,
                         "incorrect zero padding")
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def test_stream_padding(self):
        # Test for bug #1543303.
        tar = tarfile.open(tmpname, self.mode)
        tar.close()

        if self.mode.endswith("gz"):
            fobj = gzip.GzipFile(tmpname)
            data = fobj.read()
            fobj.close()
        elif self.mode.endswith("bz2"):
            dec = bz2.BZ2Decompressor()
            data = open(tmpname, "rb").read()
            data = dec.decompress(data)
            self.assertTrue(len(dec.unused_data) == 0,
                    "found trailing data")
        else:
            fobj = open(tmpname, "rb")
            data = fobj.read()
            fobj.close()

        self.assertTrue(data.count("\0") == tarfile.RECORDSIZE,
                         "incorrect zero padding")
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_stream_padding(self):
        # Test for bug #1543303.
        tar = tarfile.open(tmpname, self.mode)
        tar.close()
        if self.decompressor:
            dec = self.decompressor()
            with open(tmpname, "rb") as fobj:
                data = fobj.read()
            data = dec.decompress(data)
            self.assertFalse(dec.unused_data, "found trailing data")
        else:
            with self.open(tmpname) as fobj:
                data = fobj.read()
        self.assertEqual(data.count(b"\0"), tarfile.RECORDSIZE,
                        "incorrect zero padding")
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_stream_padding(self):
        # Test for bug #1543303.
        tar = tarfile.open(tmpname, self.mode)
        tar.close()
        if self.decompressor:
            dec = self.decompressor()
            with open(tmpname, "rb") as fobj:
                data = fobj.read()
            data = dec.decompress(data)
            self.assertFalse(dec.unused_data, "found trailing data")
        else:
            with self.open(tmpname) as fobj:
                data = fobj.read()
        self.assertEqual(data.count(b"\0"), tarfile.RECORDSIZE,
                        "incorrect zero padding")
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_stream_padding(self):
        # Test for bug #1543303.
        tar = tarfile.open(tmpname, self.mode)
        tar.close()
        if self.decompressor:
            dec = self.decompressor()
            with open(tmpname, "rb") as fobj:
                data = fobj.read()
            data = dec.decompress(data)
            self.assertFalse(dec.unused_data, "found trailing data")
        else:
            with self.open(tmpname) as fobj:
                data = fobj.read()
        self.assertEqual(data.count(b"\0"), tarfile.RECORDSIZE,
                        "incorrect zero padding")