Lines Matching refs:tarinfo
55 tarinfo = self.tar.getmember("ustar/regtype")
56 fobj = self.tar.extractfile(tarinfo)
58 self.assertTrue((len(data), md5sum(data)) == (tarinfo.size, md5_regtype),
63 tarinfo = self.tar.getmember("ustar/regtype")
67 fobj2 = self.tar.extractfile(tarinfo)
80 tarinfo = self.tar.getmember("ustar/regtype")
83 fobj2 = self.tar.extractfile(tarinfo)
93 tarinfo = self.tar.getmember("ustar/regtype")
94 fobj = self.tar.extractfile(tarinfo)
113 self.assertTrue(tarinfo.size == fobj.tell(),
117 fobj.seek(-tarinfo.size, 2)
288 tarinfo = tarfile.TarInfo("foo")
289 tarinfo.size = len(data)
290 fobj.write(tarinfo.tobuf())
303 t = tarfile.TarInfo("foo")
410 tarinfo = self.tar.getmember("misc/dirtype-old-v7")
411 self.assertTrue(tarinfo.type == tarfile.DIRTYPE,
424 for tarinfo in self.tar:
425 self.assertTrue(int(tarinfo.mtime) == 07606136617,
426 "wrong mtime for %s" % tarinfo.name)
427 if not tarinfo.name.startswith("ustar/"):
429 self.assertTrue(tarinfo.uname == "tarfile",
430 "wrong uname for %s" % tarinfo.name)
461 for tarinfo in directories:
462 path = os.path.join(TEMPDIR, tarinfo.name)
465 self.assertEqual(tarinfo.mode & 0777, os.stat(path).st_mode & 0777)
466 self.assertEqual(tarinfo.mtime, os.path.getmtime(path))
503 tarinfo = self.tar.next() # get "regtype" (can't use getmember)
504 fobj = self.tar.extractfile(tarinfo)
506 self.assertTrue((len(data), md5sum(data)) == (tarinfo.size, md5_regtype),
613 def _test_member(self, tarinfo, chksum=None, **kwargs):
615 self.assertTrue(md5sum(self.tar.extractfile(tarinfo).read()) == chksum,
616 "wrong md5sum for %s" % tarinfo.name)
621 if "old-v7" not in tarinfo.name:
626 self.assertTrue(getattr(tarinfo, k) == v,
627 "wrong value in %s field of %s" % (k, tarinfo.name))
630 tarinfo = self.tar.getmember("ustar/regtype")
631 self._test_member(tarinfo, size=7011, chksum=md5_regtype)
634 tarinfo = self.tar.getmember("ustar/conttype")
635 self._test_member(tarinfo, size=7011, chksum=md5_regtype)
638 tarinfo = self.tar.getmember("ustar/dirtype")
639 self._test_member(tarinfo, size=0)
642 tarinfo = self.tar.getmember("ustar/dirtype-with-size")
643 self._test_member(tarinfo, size=255)
646 tarinfo = self.tar.getmember("ustar/lnktype")
647 self._test_member(tarinfo, size=0, linkname="ustar/regtype")
650 tarinfo = self.tar.getmember("ustar/symtype")
651 self._test_member(tarinfo, size=0, linkname="regtype")
654 tarinfo = self.tar.getmember("ustar/blktype")
655 self._test_member(tarinfo, size=0, devmajor=3, devminor=0)
658 tarinfo = self.tar.getmember("ustar/chrtype")
659 self._test_member(tarinfo, size=0, devmajor=1, devminor=3)
662 tarinfo = self.tar.getmember("ustar/fifotype")
663 self._test_member(tarinfo, size=0)
666 tarinfo = self.tar.getmember("ustar/sparse")
667 self._test_member(tarinfo, size=86016, chksum=md5_sparse)
670 tarinfo = self.tar.getmember("ustar/umlauts-\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
671 self._test_member(tarinfo, size=7011, chksum=md5_regtype)
678 tarinfo = self.tar.getmember("misc/regtype-old-v7")
679 self._test_member(tarinfo, size=7011, chksum=md5_regtype)
683 tarinfo = self.tar.getmember("pax/umlauts-\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
684 self._test_member(tarinfo, size=7011, chksum=md5_regtype)
693 tarinfo = self.tar.getmember(longname)
696 self.assertTrue(tarinfo.type != tarfile.DIRTYPE, "read longname as dirtype")
702 tarinfo = self.tar.getmember(longlink)
705 self.assertTrue(tarinfo.linkname == longname, "linkname wrong")
709 tarinfo = self.tar.getmember(longname)
710 offset = tarinfo.offset
716 # Test if the start offset of the TarInfo object includes
722 tarinfo = tarfile.TarInfo.frombuf(fobj.read(512))
723 self.assertEqual(tarinfo.type, self.longnametype)
749 tarinfo = tar.getmember("pax/regtype1")
750 self.assertEqual(tarinfo.uname, "foo")
751 self.assertEqual(tarinfo.gname, "bar")
752 self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), u"\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
754 tarinfo = tar.getmember("pax/regtype2")
755 self.assertEqual(tarinfo.uname, "")
756 self.assertEqual(tarinfo.gname, "bar")
757 self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), u"\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
759 tarinfo = tar.getmember("pax/regtype3")
760 self.assertEqual(tarinfo.uname, "tarfile")
761 self.assertEqual(tarinfo.gname, "tarfile")
762 self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), u"\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
770 tarinfo = tar.getmember("pax/regtype4")
771 self.assertEqual(tarinfo.size, 7011)
772 self.assertEqual(tarinfo.uid, 123)
773 self.assertEqual(tarinfo.gid, 123)
774 self.assertEqual(tarinfo.mtime, 1041808783.0)
775 self.assertEqual(type(tarinfo.mtime), float)
776 self.assertEqual(float(tarinfo.pax_headers["atime"]), 1041808783.0)
777 self.assertEqual(float(tarinfo.pax_headers["ctime"]), 1041808783.0)
789 tar.addfile(tarfile.TarInfo("foo"))
812 t = tarfile.TarInfo(name)
845 tarinfo = tar.gettarinfo(path)
846 self.assertEqual(tarinfo.size, 0)
850 tarinfo = tar.gettarinfo(path)
851 self.assertEqual(tarinfo.size, 3)
861 tarinfo = tar.gettarinfo(path)
862 self.assertEqual(tarinfo.size, 0)
880 tarinfo = tar.gettarinfo(link)
881 self.assertEqual(tarinfo.size, 0)
895 tarinfo = tar.gettarinfo(path)
896 self.assertEqual(tarinfo.size, 0)
954 def filter(tarinfo):
955 if os.path.basename(tarinfo.name) == "bar":
957 tarinfo.uid = 123
958 tarinfo.uname = "foo"
959 return tarinfo
969 for tarinfo in tar:
970 self.assertEqual(tarinfo.uid, 123)
971 self.assertEqual(tarinfo.uname, "foo")
1231 tarinfo = tarfile.TarInfo(name)
1233 tarinfo.linkname = link
1234 tarinfo.type = tarfile.LNKTYPE
1239 tar.addfile(tarinfo)
1252 self.assertEqual(tarinfo.name, member.name,
1254 self.assertEqual(tarinfo.linkname, member.linkname,
1313 tarinfo = self.tar.gettarinfo(self.foo)
1314 self.assertTrue(tarinfo.type == tarfile.REGTYPE,
1318 tarinfo = self.tar.gettarinfo(self.bar)
1319 self.assertTrue(tarinfo.type == tarfile.LNKTYPE,
1324 tarinfo = self.tar.gettarinfo(self.bar)
1325 self.assertTrue(tarinfo.type == tarfile.REGTYPE,
1333 tarinfo = tarfile.TarInfo(name)
1335 tarinfo.linkname = link
1336 tarinfo.type = tarfile.LNKTYPE
1340 tar.addfile(tarinfo)
1366 tar.addfile(tarfile.TarInfo("test"))
1390 # TarInfo.
1395 t = tarfile.TarInfo()
1431 tar.addfile(tarfile.TarInfo(name))
1445 tarinfo = tarfile.TarInfo()
1447 tarinfo.name = "\xe4\xf6\xfc"
1449 self.assertRaises(UnicodeError, tar.addfile, tarinfo)
1451 tar.addfile(tarinfo)
1453 tarinfo.name = u"\xe4\xf6\xfc"
1454 self.assertRaises(UnicodeError, tar.addfile, tarinfo)
1456 tarinfo.name = "foo"
1457 tarinfo.uname = u"\xe4\xf6\xfc"
1458 self.assertRaises(UnicodeError, tar.addfile, tarinfo)
1475 t = tarfile.TarInfo("foo")
1504 t = tarfile.TarInfo()
1543 tar.addfile(tarfile.TarInfo("bar"))
1610 data = tarfile.TarInfo("foo").tobuf()
1614 data = tarfile.TarInfo("foo").tobuf()
1625 tarinfo = tarfile.TarInfo("0123456789" * 10)
1626 tarinfo.tobuf(tarfile.USTAR_FORMAT)
1629 tarinfo = tarfile.TarInfo("0123456789" * 10 + "0")
1630 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
1633 tarinfo = tarfile.TarInfo("123/" * 62 + "longname")
1634 tarinfo.tobuf(tarfile.USTAR_FORMAT)
1637 tarinfo = tarfile.TarInfo("1234567/" * 31 + "longname")
1638 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
1641 tarinfo = tarfile.TarInfo("123/" * 126 + "longname")
1642 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
1645 tarinfo = tarfile.TarInfo("longlink")
1646 tarinfo.linkname = "123/" * 126 + "longname"
1647 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
1650 tarinfo = tarfile.TarInfo("name")
1651 tarinfo.uid = 010000000
1652 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
1655 tarinfo = tarfile.TarInfo("123/" * 126 + "longname")
1656 tarinfo.tobuf(tarfile.GNU_FORMAT)
1658 tarinfo = tarfile.TarInfo("longlink")
1659 tarinfo.linkname = "123/" * 126 + "longname"
1660 tarinfo.tobuf(tarfile.GNU_FORMAT)
1663 tarinfo = tarfile.TarInfo("name")
1664 tarinfo.uid = 04000000000000000000L
1665 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.GNU_FORMAT)
1668 tarinfo = tarfile.TarInfo("123/" * 126 + "longname")
1669 tarinfo.tobuf(tarfile.PAX_FORMAT)
1671 tarinfo = tarfile.TarInfo("longlink")
1672 tarinfo.linkname = "123/" * 126 + "longname"
1673 tarinfo.tobuf(tarfile.PAX_FORMAT)
1675 tarinfo = tarfile.TarInfo("name")
1676 tarinfo.uid = 04000000000000000000L
1677 tarinfo.tobuf(tarfile.PAX_FORMAT)
1816 TarInfo("foo").tobuf())