当前位置: 首页>>代码示例>>Python>>正文


Python tarfile.RECORDSIZE属性代码示例

本文整理汇总了Python中tarfile.RECORDSIZE属性的典型用法代码示例。如果您正苦于以下问题:Python tarfile.RECORDSIZE属性的具体用法?Python tarfile.RECORDSIZE怎么用?Python tarfile.RECORDSIZE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在tarfile的用法示例。


在下文中一共展示了tarfile.RECORDSIZE属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_stream_padding

# 需要导入模块: import tarfile [as 别名]
# 或者: from tarfile import RECORDSIZE [as 别名]
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") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:23,代码来源:test_tarfile.py

示例2: test_stream_padding

# 需要导入模块: import tarfile [as 别名]
# 或者: from tarfile import RECORDSIZE [as 别名]
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") 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:24,代码来源:test_tarfile.py

示例3: test_padding

# 需要导入模块: import tarfile [as 别名]
# 或者: from tarfile import RECORDSIZE [as 别名]
def test_padding(self):
        self.dst.close()

        if self.comp == "gz":
            f = gzip.GzipFile(self.dstname)
            s = f.read()
            f.close()
        elif self.comp == "bz2":
            b = bz2.BZ2Decompressor()
            f = file(self.dstname)
            s = f.read()
            f.close()
            s = b.decompress(s)
            self.assertEqual(len(f.unused_data), 0, "trailing data")
        else:
            f = file(self.dstname)
            s = f.read()
            f.close()

        self.assertEqual(s.count("\0"), tarfile.RECORDSIZE,
                         "incorrect zero padding") 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:23,代码来源:test_tarfile.py

示例4: test_eof_marker

# 需要导入模块: import tarfile [as 别名]
# 或者: from tarfile import RECORDSIZE [as 别名]
def test_eof_marker(self):
        # Make sure an end of archive marker is written (two zero blocks).
        # tarfile insists on aligning archives to a 20 * 512 byte recordsize.
        # So, we create an archive that has exactly 10240 bytes without the
        # marker, and has 20480 bytes once the marker is written.
        with tarfile.open(tmpname, self.mode) as tar:
            t = tarfile.TarInfo("foo")
            t.size = tarfile.RECORDSIZE - tarfile.BLOCKSIZE
            tar.addfile(t, io.BytesIO(b"a" * t.size))

        with self.open(tmpname, "rb") as fobj:
            self.assertEqual(len(fobj.read()), tarfile.RECORDSIZE * 2) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:14,代码来源:test_tarfile.py

示例5: test_stream_padding

# 需要导入模块: import tarfile [as 别名]
# 或者: from tarfile import RECORDSIZE [as 别名]
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") 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:17,代码来源:test_tarfile.py


注:本文中的tarfile.RECORDSIZE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。