Lines Matching refs:tarinfo
97 tarinfo = self.tar.getmember("ustar/regtype")
98 with self.tar.extractfile(tarinfo) as fobj:
100 self.assertEqual(len(data), tarinfo.size,
107 tarinfo = self.tar.getmember("ustar/regtype")
111 with self.tar.extractfile(tarinfo) as fobj:
125 tarinfo = self.tar.getmember("ustar/regtype")
128 with self.tar.extractfile(tarinfo) as fobj2:
138 tarinfo = self.tar.getmember("ustar/regtype")
139 with self.tar.extractfile(tarinfo) as fobj:
157 self.assertEqual(tarinfo.size, fobj.tell(),
161 fobj.seek(-tarinfo.size, 2)
298 for tarinfo in tar.getmembers():
299 if 'reg' in tarinfo.name:
300 yield tarinfo
395 tarinfo = tarfile.TarInfo("foo")
396 tarinfo.size = len(data)
397 fobj.write(tarinfo.tobuf())
550 tarinfo = self.tar.getmember("misc/dirtype-old-v7")
551 self.assertEqual(tarinfo.type, tarfile.DIRTYPE,
564 for tarinfo in self.tar:
565 self.assertEqual(int(tarinfo.mtime), 0o7606136617,
566 "wrong mtime for %s" % tarinfo.name)
567 if not tarinfo.name.startswith("ustar/"):
569 self.assertEqual(tarinfo.uname, "tarfile",
570 "wrong uname for %s" % tarinfo.name)
606 for tarinfo in directories:
607 path = os.path.join(DIR, tarinfo.name)
610 self.assertEqual(tarinfo.mode & 0o777,
619 format_mtime(tarinfo.mtime),
622 self.assertEqual(tarinfo.mtime, file_mtime, errmsg)
633 tarinfo = tar.getmember(dirtype)
634 tar.extract(tarinfo, path=DIR)
636 self.assertEqual(os.path.getmtime(extracted), tarinfo.mtime)
648 for tarinfo in directories:
649 path = DIR / tarinfo.name
650 self.assertEqual(os.path.getmtime(path), tarinfo.mtime)
657 tarinfo = tar.getmember(dirtype)
658 tar.extract(tarinfo, path=DIR)
660 self.assertEqual(os.path.getmtime(extracted), tarinfo.mtime)
711 for tarinfo in self.tar:
712 if not tarinfo.isreg():
714 with self.tar.extractfile(tarinfo) as fobj:
725 tarinfo = self.tar.next() # get "regtype" (can't use getmember)
726 with self.tar.extractfile(tarinfo) as fobj:
728 self.assertEqual(len(data), tarinfo.size,
839 def _test_member(self, tarinfo, chksum=None, **kwargs): argument
841 with self.tar.extractfile(tarinfo) as f:
843 "wrong sha256sum for %s" % tarinfo.name)
848 if "old-v7" not in tarinfo.name:
853 self.assertEqual(getattr(tarinfo, k), v,
854 "wrong value in %s field of %s" % (k, tarinfo.name))
857 tarinfo = self.tar.getmember("ustar/regtype")
858 self._test_member(tarinfo, size=7011, chksum=sha256_regtype)
861 tarinfo = self.tar.getmember("ustar/conttype")
862 self._test_member(tarinfo, size=7011, chksum=sha256_regtype)
865 tarinfo = self.tar.getmember("ustar/dirtype")
866 self._test_member(tarinfo, size=0)
869 tarinfo = self.tar.getmember("ustar/dirtype-with-size")
870 self._test_member(tarinfo, size=255)
873 tarinfo = self.tar.getmember("ustar/lnktype")
874 self._test_member(tarinfo, size=0, linkname="ustar/regtype")
877 tarinfo = self.tar.getmember("ustar/symtype")
878 self._test_member(tarinfo, size=0, linkname="regtype")
881 tarinfo = self.tar.getmember("ustar/blktype")
882 self._test_member(tarinfo, size=0, devmajor=3, devminor=0)
885 tarinfo = self.tar.getmember("ustar/chrtype")
886 self._test_member(tarinfo, size=0, devmajor=1, devminor=3)
889 tarinfo = self.tar.getmember("ustar/fifotype")
890 self._test_member(tarinfo, size=0)
893 tarinfo = self.tar.getmember("ustar/sparse")
894 self._test_member(tarinfo, size=86016, chksum=sha256_sparse)
897 tarinfo = self.tar.getmember("gnu/sparse")
898 self._test_member(tarinfo, size=86016, chksum=sha256_sparse)
901 tarinfo = self.tar.getmember("gnu/sparse-0.0")
902 self._test_member(tarinfo, size=86016, chksum=sha256_sparse)
905 tarinfo = self.tar.getmember("gnu/sparse-0.1")
906 self._test_member(tarinfo, size=86016, chksum=sha256_sparse)
909 tarinfo = self.tar.getmember("gnu/sparse-1.0")
910 self._test_member(tarinfo, size=86016, chksum=sha256_sparse)
913 tarinfo = self.tar.getmember("ustar/umlauts-"
915 self._test_member(tarinfo, size=7011, chksum=sha256_regtype)
922 tarinfo = self.tar.getmember("misc/regtype-old-v7")
923 self._test_member(tarinfo, size=7011, chksum=sha256_regtype)
929 tarinfo = self.tar.getmember("pax/umlauts-"
931 self._test_member(tarinfo, size=7011, chksum=sha256_regtype)
940 tarinfo = self.tar.getmember(longname)
943 self.assertNotEqual(tarinfo.type, tarfile.DIRTYPE,
950 tarinfo = self.tar.getmember(longlink)
953 self.assertEqual(tarinfo.linkname, longname, "linkname wrong")
957 tarinfo = self.tar.getmember(longname)
958 offset = tarinfo.offset
971 tarinfo = tarfile.TarInfo.frombuf(fobj.read(512),
973 self.assertEqual(tarinfo.type, self.longnametype)
1043 tarinfo = tar.getmember("pax/regtype1")
1044 self.assertEqual(tarinfo.uname, "foo")
1045 self.assertEqual(tarinfo.gname, "bar")
1046 self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"),
1049 tarinfo = tar.getmember("pax/regtype2")
1050 self.assertEqual(tarinfo.uname, "")
1051 self.assertEqual(tarinfo.gname, "bar")
1052 self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"),
1055 tarinfo = tar.getmember("pax/regtype3")
1056 self.assertEqual(tarinfo.uname, "tarfile")
1057 self.assertEqual(tarinfo.gname, "tarfile")
1058 self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"),
1067 tarinfo = tar.getmember("pax/regtype4")
1068 self.assertEqual(tarinfo.size, 7011)
1069 self.assertEqual(tarinfo.uid, 123)
1070 self.assertEqual(tarinfo.gid, 123)
1071 self.assertEqual(tarinfo.mtime, 1041808783.0)
1072 self.assertEqual(type(tarinfo.mtime), float)
1073 self.assertEqual(float(tarinfo.pax_headers["atime"]), 1041808783.0)
1074 self.assertEqual(float(tarinfo.pax_headers["ctime"]), 1041808783.0)
1153 tarinfo = tar.gettarinfo(path)
1154 self.assertEqual(tarinfo.size, 0)
1158 tarinfo = tar.gettarinfo(path)
1159 self.assertEqual(tarinfo.size, 3)
1169 tarinfo = tar.gettarinfo(path)
1170 self.assertEqual(tarinfo.size, 0)
1205 tarinfo = tar.gettarinfo(path)
1207 self.assertIsInstance(tarinfo.name, str)
1208 self.assertEqual(tarinfo.name, tarinfo2.name)
1209 self.assertEqual(tarinfo.size, 3)
1227 tarinfo = tar.gettarinfo(link)
1228 self.assertEqual(tarinfo.size, 0)
1242 tarinfo = tar.gettarinfo(path)
1243 self.assertEqual(tarinfo.size, 0)
1275 def filter(tarinfo): argument
1276 if os.path.basename(tarinfo.name) == "bar":
1278 tarinfo.uid = 123
1279 tarinfo.uname = "foo"
1280 return tarinfo
1294 for tarinfo in tar:
1295 self.assertEqual(tarinfo.uid, 123)
1296 self.assertEqual(tarinfo.uname, "foo")
1512 tarinfo = tarfile.TarInfo(name)
1514 tarinfo.linkname = link
1515 tarinfo.type = tarfile.LNKTYPE
1520 tar.addfile(tarinfo)
1533 self.assertEqual(tarinfo.name, member.name,
1535 self.assertEqual(tarinfo.linkname, member.linkname,
1754 tarinfo = self.tar.gettarinfo(self.foo)
1755 self.assertEqual(tarinfo.type, tarfile.REGTYPE,
1759 tarinfo = self.tar.gettarinfo(self.bar)
1760 self.assertEqual(tarinfo.type, tarfile.LNKTYPE,
1765 tarinfo = self.tar.gettarinfo(self.bar)
1766 self.assertEqual(tarinfo.type, tarfile.REGTYPE,
1774 tarinfo = tarfile.TarInfo(name)
1776 tarinfo.linkname = link
1777 tarinfo.type = tarfile.LNKTYPE
1781 tar.addfile(tarinfo)
1884 tarinfo = tarfile.TarInfo()
1886 tarinfo.name = "\xe4\xf6\xfc"
1887 self.assertRaises(UnicodeError, tar.addfile, tarinfo)
1889 tarinfo.name = "foo"
1890 tarinfo.uname = "\xe4\xf6\xfc"
1891 self.assertRaises(UnicodeError, tar.addfile, tarinfo)
2150 tarinfo = tarfile.TarInfo("0123456789" * 10)
2151 tarinfo.tobuf(tarfile.USTAR_FORMAT)
2154 tarinfo = tarfile.TarInfo("0123456789" * 10 + "0")
2155 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
2158 tarinfo = tarfile.TarInfo("123/" * 62 + "longname")
2159 tarinfo.tobuf(tarfile.USTAR_FORMAT)
2162 tarinfo = tarfile.TarInfo("1234567/" * 31 + "longname")
2163 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
2166 tarinfo = tarfile.TarInfo("123/" * 126 + "longname")
2167 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
2170 tarinfo = tarfile.TarInfo("longlink")
2171 tarinfo.linkname = "123/" * 126 + "longname"
2172 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
2175 tarinfo = tarfile.TarInfo("name")
2176 tarinfo.uid = 0o10000000
2177 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
2180 tarinfo = tarfile.TarInfo("123/" * 126 + "longname")
2181 tarinfo.tobuf(tarfile.GNU_FORMAT)
2183 tarinfo = tarfile.TarInfo("longlink")
2184 tarinfo.linkname = "123/" * 126 + "longname"
2185 tarinfo.tobuf(tarfile.GNU_FORMAT)
2188 tarinfo = tarfile.TarInfo("name")
2189 tarinfo.uid = 0o4000000000000000000
2190 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.GNU_FORMAT)
2193 tarinfo = tarfile.TarInfo("123/" * 126 + "longname")
2194 tarinfo.tobuf(tarfile.PAX_FORMAT)
2196 tarinfo = tarfile.TarInfo("longlink")
2197 tarinfo.linkname = "123/" * 126 + "longname"
2198 tarinfo.tobuf(tarfile.PAX_FORMAT)
2200 tarinfo = tarfile.TarInfo("name")
2201 tarinfo.uid = 0o4000000000000000000
2202 tarinfo.tobuf(tarfile.PAX_FORMAT)