當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。