Lines Matching refs:tarinfo
54 tarinfo = self.tar.getmember("ustar/regtype")
55 fobj = self.tar.extractfile(tarinfo)
57 self.assertTrue((len(data), md5sum(data)) == (tarinfo.size, md5_regtype),
62 tarinfo = self.tar.getmember("ustar/regtype")
64 fobj2 = self.tar.extractfile(tarinfo)
78 tarinfo = self.tar.getmember("ustar/regtype")
80 fobj2 = self.tar.extractfile(tarinfo)
92 tarinfo = self.tar.getmember("ustar/regtype")
93 fobj = self.tar.extractfile(tarinfo)
112 self.assertTrue(tarinfo.size == fobj.tell(),
116 fobj.seek(-tarinfo.size, 2)
198 fobj.write(tarfile.TarInfo("foo").tobuf())
272 tarinfo = self.tar.getmember("misc/dirtype-old-v7")
273 self.assertTrue(tarinfo.type == tarfile.DIRTYPE,
286 for tarinfo in self.tar:
287 self.assertTrue(int(tarinfo.mtime) == 07606136617,
288 "wrong mtime for %s" % tarinfo.name)
289 if not tarinfo.name.startswith("ustar/"):
291 self.assertTrue(tarinfo.uname == "tarfile",
292 "wrong uname for %s" % tarinfo.name)
322 for tarinfo in directories:
323 path = os.path.join(TEMPDIR, tarinfo.name)
326 self.assertEqual(tarinfo.mode & 0777, os.stat(path).st_mode & 0777)
327 self.assertEqual(tarinfo.mtime, os.path.getmtime(path))
362 tarinfo = self.tar.next() # get "regtype" (can't use getmember)
363 fobj = self.tar.extractfile(tarinfo)
365 self.assertTrue((len(data), md5sum(data)) == (tarinfo.size, md5_regtype),
469 def _test_member(self, tarinfo, chksum=None, **kwargs):
471 self.assertTrue(md5sum(self.tar.extractfile(tarinfo).read()) == chksum,
472 "wrong md5sum for %s" % tarinfo.name)
477 if "old-v7" not in tarinfo.name:
482 self.assertTrue(getattr(tarinfo, k) == v,
483 "wrong value in %s field of %s" % (k, tarinfo.name))
486 tarinfo = self.tar.getmember("ustar/regtype")
487 self._test_member(tarinfo, size=7011, chksum=md5_regtype)
490 tarinfo = self.tar.getmember("ustar/conttype")
491 self._test_member(tarinfo, size=7011, chksum=md5_regtype)
494 tarinfo = self.tar.getmember("ustar/dirtype")
495 self._test_member(tarinfo, size=0)
498 tarinfo = self.tar.getmember("ustar/dirtype-with-size")
499 self._test_member(tarinfo, size=255)
502 tarinfo = self.tar.getmember("ustar/lnktype")
503 self._test_member(tarinfo, size=0, linkname="ustar/regtype")
506 tarinfo = self.tar.getmember("ustar/symtype")
507 self._test_member(tarinfo, size=0, linkname="regtype")
510 tarinfo = self.tar.getmember("ustar/blktype")
511 self._test_member(tarinfo, size=0, devmajor=3, devminor=0)
514 tarinfo = self.tar.getmember("ustar/chrtype")
515 self._test_member(tarinfo, size=0, devmajor=1, devminor=3)
518 tarinfo = self.tar.getmember("ustar/fifotype")
519 self._test_member(tarinfo, size=0)
522 tarinfo = self.tar.getmember("ustar/sparse")
523 self._test_member(tarinfo, size=86016, chksum=md5_sparse)
526 tarinfo = self.tar.getmember("ustar/umlauts-???????")
527 self._test_member(tarinfo, size=7011, chksum=md5_regtype)
534 tarinfo = self.tar.getmember("misc/regtype-old-v7")
535 self._test_member(tarinfo, size=7011, chksum=md5_regtype)
539 tarinfo = self.tar.getmember("pax/umlauts-???????")
540 self._test_member(tarinfo, size=7011, chksum=md5_regtype)
549 tarinfo = self.tar.getmember(longname)
552 self.assertTrue(tarinfo.type != tarfile.DIRTYPE, "read longname as dirtype")
558 tarinfo = self.tar.getmember(longlink)
561 self.assertTrue(tarinfo.linkname == longname, "linkname wrong")
565 tarinfo = self.tar.getmember(longname)
566 offset = tarinfo.offset
572 # Test if the start offset of the TarInfo object includes
578 tarinfo = tarfile.TarInfo.frombuf(fobj.read(512))
579 self.assertEqual(tarinfo.type, self.longnametype)
604 tarinfo = tar.getmember("pax/regtype1")
605 self.assertEqual(tarinfo.uname, "foo")
606 self.assertEqual(tarinfo.gname, "bar")
607 self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), u"???????")
609 tarinfo = tar.getmember("pax/regtype2")
610 self.assertEqual(tarinfo.uname, "")
611 self.assertEqual(tarinfo.gname, "bar")
612 self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), u"???????")
614 tarinfo = tar.getmember("pax/regtype3")
615 self.assertEqual(tarinfo.uname, "tarfile")
616 self.assertEqual(tarinfo.gname, "tarfile")
617 self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), u"???????")
622 tarinfo = tar.getmember("pax/regtype4")
623 self.assertEqual(tarinfo.size, 7011)
624 self.assertEqual(tarinfo.uid, 123)
625 self.assertEqual(tarinfo.gid, 123)
626 self.assertEqual(tarinfo.mtime, 1041808783.0)
627 self.assertEqual(type(tarinfo.mtime), float)
628 self.assertEqual(float(tarinfo.pax_headers["atime"]), 1041808783.0)
629 self.assertEqual(float(tarinfo.pax_headers["ctime"]), 1041808783.0)
639 tar.addfile(tarfile.TarInfo("foo"))
655 t = tarfile.TarInfo(name)
683 tarinfo = tar.gettarinfo(path)
684 self.assertEqual(tarinfo.size, 0)
689 tarinfo = tar.gettarinfo(path)
690 self.assertEqual(tarinfo.size, 3)
699 tarinfo = tar.gettarinfo(path)
700 self.assertEqual(tarinfo.size, 0)
716 tarinfo = tar.gettarinfo(link)
717 self.assertEqual(tarinfo.size, 0)
728 tarinfo = tar.gettarinfo(path)
729 self.assertEqual(tarinfo.size, 0)
779 def filter(tarinfo):
780 if os.path.basename(tarinfo.name) == "bar":
782 tarinfo.uid = 123
783 tarinfo.uname = "foo"
784 return tarinfo
791 for tarinfo in tar:
792 self.assertEqual(tarinfo.uid, 123)
793 self.assertEqual(tarinfo.uname, "foo")
1036 tarinfo = tarfile.TarInfo(name)
1038 tarinfo.linkname = link
1039 tarinfo.type = tarfile.LNKTYPE
1043 tar.addfile(tarinfo)
1055 self.assertEqual(tarinfo.name, member.name,
1057 self.assertEqual(tarinfo.linkname, member.linkname,
1115 tarinfo = self.tar.gettarinfo(self.foo)
1116 self.assertTrue(tarinfo.type == tarfile.REGTYPE,
1120 tarinfo = self.tar.gettarinfo(self.bar)
1121 self.assertTrue(tarinfo.type == tarfile.LNKTYPE,
1126 tarinfo = self.tar.gettarinfo(self.bar)
1127 self.assertTrue(tarinfo.type == tarfile.REGTYPE,
1135 tarinfo = tarfile.TarInfo(name)
1137 tarinfo.linkname = link
1138 tarinfo.type = tarfile.LNKTYPE
1141 tar.addfile(tarinfo)
1162 tar.addfile(tarfile.TarInfo("test"))
1182 # TarInfo.
1186 t = tarfile.TarInfo()
1217 tar.addfile(tarfile.TarInfo(name))
1227 tarinfo = tarfile.TarInfo()
1229 tarinfo.name = "???"
1231 self.assertRaises(UnicodeError, tar.addfile, tarinfo)
1233 tar.addfile(tarinfo)
1235 tarinfo.name = u"???"
1236 self.assertRaises(UnicodeError, tar.addfile, tarinfo)
1238 tarinfo.name = "foo"
1239 tarinfo.uname = u"???"
1240 self.assertRaises(UnicodeError, tar.addfile, tarinfo)
1253 t = tarfile.TarInfo("foo")
1280 t = tarfile.TarInfo()
1319 tar.addfile(tarfile.TarInfo("bar"))
1388 data = tarfile.TarInfo("foo").tobuf()
1392 data = tarfile.TarInfo("foo").tobuf()
1403 tarinfo = tarfile.TarInfo("0123456789" * 10)
1404 tarinfo.tobuf(tarfile.USTAR_FORMAT)
1407 tarinfo = tarfile.TarInfo("0123456789" * 10 + "0")
1408 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
1411 tarinfo = tarfile.TarInfo("123/" * 62 + "longname")
1412 tarinfo.tobuf(tarfile.USTAR_FORMAT)
1415 tarinfo = tarfile.TarInfo("1234567/" * 31 + "longname")
1416 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
1419 tarinfo = tarfile.TarInfo("123/" * 126 + "longname")
1420 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
1423 tarinfo = tarfile.TarInfo("longlink")
1424 tarinfo.linkname = "123/" * 126 + "longname"
1425 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
1428 tarinfo = tarfile.TarInfo("name")
1429 tarinfo.uid = 010000000
1430 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
1433 tarinfo = tarfile.TarInfo("123/" * 126 + "longname")
1434 tarinfo.tobuf(tarfile.GNU_FORMAT)
1436 tarinfo = tarfile.TarInfo("longlink")
1437 tarinfo.linkname = "123/" * 126 + "longname"
1438 tarinfo.tobuf(tarfile.GNU_FORMAT)
1441 tarinfo = tarfile.TarInfo("name")
1442 tarinfo.uid = 04000000000000000000L
1443 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.GNU_FORMAT)
1446 tarinfo = tarfile.TarInfo("123/" * 126 + "longname")
1447 tarinfo.tobuf(tarfile.PAX_FORMAT)
1449 tarinfo = tarfile.TarInfo("longlink")
1450 tarinfo.linkname = "123/" * 126 + "longname"
1451 tarinfo.tobuf(tarfile.PAX_FORMAT)
1453 tarinfo = tarfile.TarInfo("name")
1454 tarinfo.uid = 04000000000000000000L
1455 tarinfo.tobuf(tarfile.PAX_FORMAT)
1585 data = bz2.compress(tarfile.TarInfo("foo").tobuf())