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


Python tarfile.LNKTYPE属性代码示例

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


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

示例1: _test

# 需要导入模块: import tarfile [as 别名]
# 或者: from tarfile import LNKTYPE [as 别名]
def _test(self, name, link=None):
        # See GNUWriteTest.
        tarinfo = tarfile.TarInfo(name)
        if link:
            tarinfo.linkname = link
            tarinfo.type = tarfile.LNKTYPE

        tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT)
        try:
            tar.addfile(tarinfo)
        finally:
            tar.close()

        tar = tarfile.open(tmpname)
        try:
            if link:
                l = tar.getmembers()[0].linkname
                self.assertTrue(link == l, "PAX longlink creation failed")
            else:
                n = tar.getmembers()[0].name
                self.assertTrue(name == n, "PAX longname creation failed")
        finally:
            tar.close() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:test_tarfile.py

示例2: _test

# 需要导入模块: import tarfile [as 别名]
# 或者: from tarfile import LNKTYPE [as 别名]
def _test(self, name, link=None):
        tarinfo = tarfile.TarInfo(name)
        if link:
            tarinfo.linkname = link
            tarinfo.type = tarfile.LNKTYPE

        tar = tarfile.open(tmpname, "w")
        tar.format = tarfile.GNU_FORMAT
        tar.addfile(tarinfo)

        v1 = self._calc_size(name, link)
        v2 = tar.offset
        self.assertTrue(v1 == v2, "GNU longname/longlink creation failed")

        tar.close()

        tar = tarfile.open(tmpname)
        member = tar.next()
        self.assertIsNotNone(member,
                "unable to read longname member")
        self.assertEqual(tarinfo.name, member.name,
                "unable to read longname member")
        self.assertEqual(tarinfo.linkname, member.linkname,
                "unable to read longname member") 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:26,代码来源:test_tarfile.py

示例3: _test

# 需要导入模块: import tarfile [as 别名]
# 或者: from tarfile import LNKTYPE [as 别名]
def _test(self, name, link=None):
        # See GNUWriteTest.
        tarinfo = tarfile.TarInfo(name)
        if link:
            tarinfo.linkname = link
            tarinfo.type = tarfile.LNKTYPE

        tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT)
        try:
            tar.addfile(tarinfo)
        finally:
            tar.close()

        tar = tarfile.open(tmpname)
        try:
            if link:
                l = tar.getmembers()[0].linkname
                self.assertEqual(link, l, "PAX longlink creation failed")
            else:
                n = tar.getmembers()[0].name
                self.assertEqual(name, n, "PAX longname creation failed")
        finally:
            tar.close() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:25,代码来源:test_tarfile.py

示例4: _test

# 需要导入模块: import tarfile [as 别名]
# 或者: from tarfile import LNKTYPE [as 别名]
def _test(self, name, link=None):
        tarinfo = tarfile.TarInfo(name)
        if link:
            tarinfo.linkname = link
            tarinfo.type = tarfile.LNKTYPE

        tar = tarfile.open(tmpname(), "w")
        tar.posix = False
        tar.addfile(tarinfo)

        v1 = self._calc_size(name, link)
        v2 = tar.offset
        self.assertEqual(v1, v2, "GNU longname/longlink creation failed")

        tar.close()

        tar = tarfile.open(tmpname())
        member = tar.next()
        self.failIf(member is None, "unable to read longname member")
        self.assert_(tarinfo.name == member.name and \
                     tarinfo.linkname == member.linkname, \
                     "unable to read longname member")
        tar.close() 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:25,代码来源:test_tarfile.py

示例5: test_add_hardlink

# 需要导入模块: import tarfile [as 别名]
# 或者: from tarfile import LNKTYPE [as 别名]
def test_add_hardlink(self):
        tarinfo = self.tar.gettarinfo(self.bar)
        self.assertTrue(tarinfo.type == tarfile.LNKTYPE,
                "add file as hardlink failed") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_tarfile.py

示例6: test_add_hardlink

# 需要导入模块: import tarfile [as 别名]
# 或者: from tarfile import LNKTYPE [as 别名]
def test_add_hardlink(self):
        tarinfo = self.tar.gettarinfo(self.bar)
        self.assertEqual(tarinfo.type, tarfile.LNKTYPE,
                "add file as hardlink failed") 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:6,代码来源:test_tarfile.py

示例7: create_layer

# 需要导入模块: import tarfile [as 别名]
# 或者: from tarfile import LNKTYPE [as 别名]
def create_layer(*file_pairs):
    output = BytesIO()
    with tarfile.open(fileobj=output, mode="w:gz") as tar:
        for current_filename, current_contents in file_pairs:
            if current_contents is None:
                # This is a deleted file.
                if current_filename.endswith("/"):
                    current_filename = current_filename[:-1]

                parts = current_filename.split("/")
                if len(parts) > 1:
                    current_filename = "/".join(parts[:-1]) + "/" + AUFS_WHITEOUT + parts[-1]
                else:
                    current_filename = AUFS_WHITEOUT + parts[-1]

                current_contents = b""

            if current_contents.startswith(b"linkto:"):
                info = tarfile.TarInfo(name=current_filename)
                info.linkname = current_contents[len(b"linkto:") :].decode("utf-8")
                info.type = tarfile.LNKTYPE
                tar.addfile(info)
            else:
                info = tarfile.TarInfo(name=current_filename)
                info.size = len(current_contents)
                tar.addfile(info, fileobj=BytesIO(current_contents))

    return output.getvalue() 
开发者ID:quay,项目名称:quay,代码行数:30,代码来源:test_streamlayerformat.py

示例8: _convertFileType

# 需要导入模块: import tarfile [as 别名]
# 或者: from tarfile import LNKTYPE [as 别名]
def _convertFileType(type):
 return {
  tarfile.REGTYPE: S_IFREG,
  tarfile.LNKTYPE: S_IFLNK,
  tarfile.SYMTYPE: S_IFLNK,
  tarfile.CHRTYPE: S_IFCHR,
  tarfile.BLKTYPE: S_IFBLK,
  tarfile.DIRTYPE: S_IFDIR,
  tarfile.FIFOTYPE: S_IFIFO,
 }.get(type, S_IFREG) 
开发者ID:ma1co,项目名称:fwtool.py,代码行数:12,代码来源:tar.py

示例9: test_hardlink

# 需要导入模块: import tarfile [as 别名]
# 或者: from tarfile import LNKTYPE [as 别名]
def test_hardlink(self):
        """Test hardlink extraction (bug #857297)
        """
        # Prevent errors from being caught
        self.tar.errorlevel = 1

        self.tar.extract("0-REGTYPE", dirname())
        try:
            # Extract 1-LNKTYPE which is a hardlink to 0-REGTYPE
            self.tar.extract("1-LNKTYPE", dirname())
        except EnvironmentError, e:
            import errno
            if e.errno == errno.ENOENT:
                self.fail("hardlink not extracted properly") 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:16,代码来源:test_tarfile.py

示例10: test_add_hardlink

# 需要导入模块: import tarfile [as 别名]
# 或者: from tarfile import LNKTYPE [as 别名]
def test_add_hardlink(self):
        # If st_nlink > 1 then the same file will be added as
        # LNKTYPE.
        os.link(self.foo, self.bar)
        tarinfo = self.tar.gettarinfo(self.foo)
        self.assertEqual(tarinfo.type, tarfile.LNKTYPE,
                "add file as hardlink failed")

        tarinfo = self.tar.gettarinfo(self.bar)
        self.assertEqual(tarinfo.type, tarfile.LNKTYPE,
                "add file as hardlink failed") 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:13,代码来源:test_tarfile.py


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