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)
195 fobj.write(tarfile.TarInfo("foo").tobuf())
269 tarinfo = self.tar.getmember("misc/dirtype-old-v7")
270 self.assertTrue(tarinfo.type == tarfile.DIRTYPE,
283 for tarinfo in self.tar:
284 self.assertTrue(int(tarinfo.mtime) == 07606136617,
285 "wrong mtime for %s" % tarinfo.name)
286 if not tarinfo.name.startswith("ustar/"):
288 self.assertTrue(tarinfo.uname == "tarfile",
289 "wrong uname for %s" % tarinfo.name)
324 for tarinfo in directories:
325 path = os.path.join(TEMPDIR, tarinfo.name)
328 self.assertEqual(tarinfo.mode & 0777, os.stat(path).st_mode & 0777)
329 self.assertEqual(tarinfo.mtime, os.path.getmtime(path))
356 tarinfo = self.tar.next() # get "regtype" (can't use getmember)
357 fobj = self.tar.extractfile(tarinfo)
359 self.assertTrue((len(data), md5sum(data)) == (tarinfo.size, md5_regtype),
446 def _test_member(self, tarinfo, chksum=None, **kwargs):
448 self.assertTrue(md5sum(self.tar.extractfile(tarinfo).read()) == chksum,
449 "wrong md5sum for %s" % tarinfo.name)
454 if "old-v7" not in tarinfo.name:
459 self.assertTrue(getattr(tarinfo, k) == v,
460 "wrong value in %s field of %s" % (k, tarinfo.name))
463 tarinfo = self.tar.getmember("ustar/regtype")
464 self._test_member(tarinfo, size=7011, chksum=md5_regtype)
467 tarinfo = self.tar.getmember("ustar/conttype")
468 self._test_member(tarinfo, size=7011, chksum=md5_regtype)
471 tarinfo = self.tar.getmember("ustar/dirtype")
472 self._test_member(tarinfo, size=0)
475 tarinfo = self.tar.getmember("ustar/dirtype-with-size")
476 self._test_member(tarinfo, size=255)
479 tarinfo = self.tar.getmember("ustar/lnktype")
480 self._test_member(tarinfo, size=0, linkname="ustar/regtype")
483 tarinfo = self.tar.getmember("ustar/symtype")
484 self._test_member(tarinfo, size=0, linkname="regtype")
487 tarinfo = self.tar.getmember("ustar/blktype")
488 self._test_member(tarinfo, size=0, devmajor=3, devminor=0)
491 tarinfo = self.tar.getmember("ustar/chrtype")
492 self._test_member(tarinfo, size=0, devmajor=1, devminor=3)
495 tarinfo = self.tar.getmember("ustar/fifotype")
496 self._test_member(tarinfo, size=0)
499 tarinfo = self.tar.getmember("ustar/sparse")
500 self._test_member(tarinfo, size=86016, chksum=md5_sparse)
503 tarinfo = self.tar.getmember("ustar/umlauts-???????")
504 self._test_member(tarinfo, size=7011, chksum=md5_regtype)
511 tarinfo = self.tar.getmember("misc/regtype-old-v7")
512 self._test_member(tarinfo, size=7011, chksum=md5_regtype)
516 tarinfo = self.tar.getmember("pax/umlauts-???????")
517 self._test_member(tarinfo, size=7011, chksum=md5_regtype)
526 tarinfo = self.tar.getmember(longname)
529 self.assertTrue(tarinfo.type != tarfile.DIRTYPE, "read longname as dirtype")
535 tarinfo = self.tar.getmember(longlink)
538 self.assertTrue(tarinfo.linkname == longname, "linkname wrong")
542 tarinfo = self.tar.getmember(longname)
543 offset = tarinfo.offset
549 # Test if the start offset of the TarInfo object includes
555 tarinfo = tarfile.TarInfo.frombuf(fobj.read(512))
556 self.assertEqual(tarinfo.type, self.longnametype)
581 tarinfo = tar.getmember("pax/regtype1")
582 self.assertEqual(tarinfo.uname, "foo")
583 self.assertEqual(tarinfo.gname, "bar")
584 self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), u"???????")
586 tarinfo = tar.getmember("pax/regtype2")
587 self.assertEqual(tarinfo.uname, "")
588 self.assertEqual(tarinfo.gname, "bar")
589 self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), u"???????")
591 tarinfo = tar.getmember("pax/regtype3")
592 self.assertEqual(tarinfo.uname, "tarfile")
593 self.assertEqual(tarinfo.gname, "tarfile")
594 self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), u"???????")
599 tarinfo = tar.getmember("pax/regtype4")
600 self.assertEqual(tarinfo.size, 7011)
601 self.assertEqual(tarinfo.uid, 123)
602 self.assertEqual(tarinfo.gid, 123)
603 self.assertEqual(tarinfo.mtime, 1041808783.0)
604 self.assertEqual(type(tarinfo.mtime), float)
605 self.assertEqual(float(tarinfo.pax_headers["atime"]), 1041808783.0)
606 self.assertEqual(float(tarinfo.pax_headers["ctime"]), 1041808783.0)
616 tar.addfile(tarfile.TarInfo("foo"))
632 t = tarfile.TarInfo(name)
660 tarinfo = tar.gettarinfo(path)
661 self.assertEqual(tarinfo.size, 0)
666 tarinfo = tar.gettarinfo(path)
667 self.assertEqual(tarinfo.size, 3)
676 tarinfo = tar.gettarinfo(path)
677 self.assertEqual(tarinfo.size, 0)
693 tarinfo = tar.gettarinfo(link)
694 self.assertEqual(tarinfo.size, 0)
705 tarinfo = tar.gettarinfo(path)
706 self.assertEqual(tarinfo.size, 0)
756 def filter(tarinfo):
757 if os.path.basename(tarinfo.name) == "bar":
759 tarinfo.uid = 123
760 tarinfo.uname = "foo"
761 return tarinfo
768 for tarinfo in tar:
769 self.assertEqual(tarinfo.uid, 123)
770 self.assertEqual(tarinfo.uname, "foo")
1006 tarinfo = tarfile.TarInfo(name)
1008 tarinfo.linkname = link
1009 tarinfo.type = tarfile.LNKTYPE
1013 tar.addfile(tarinfo)
1025 self.assertEqual(tarinfo.name, member.name,
1027 self.assertEqual(tarinfo.linkname, member.linkname,
1085 tarinfo = self.tar.gettarinfo(self.foo)
1086 self.assertTrue(tarinfo.type == tarfile.REGTYPE,
1090 tarinfo = self.tar.gettarinfo(self.bar)
1091 self.assertTrue(tarinfo.type == tarfile.LNKTYPE,
1096 tarinfo = self.tar.gettarinfo(self.bar)
1097 self.assertTrue(tarinfo.type == tarfile.REGTYPE,
1105 tarinfo = tarfile.TarInfo(name)
1107 tarinfo.linkname = link
1108 tarinfo.type = tarfile.LNKTYPE
1111 tar.addfile(tarinfo)
1132 tar.addfile(tarfile.TarInfo("test"))
1152 # TarInfo.
1156 t = tarfile.TarInfo()
1187 tar.addfile(tarfile.TarInfo(name))
1197 tarinfo = tarfile.TarInfo()
1199 tarinfo.name = "???"
1201 self.assertRaises(UnicodeError, tar.addfile, tarinfo)
1203 tar.addfile(tarinfo)
1205 tarinfo.name = u"???"
1206 self.assertRaises(UnicodeError, tar.addfile, tarinfo)
1208 tarinfo.name = "foo"
1209 tarinfo.uname = u"???"
1210 self.assertRaises(UnicodeError, tar.addfile, tarinfo)
1223 t = tarfile.TarInfo("foo")
1250 t = tarfile.TarInfo()
1289 tar.addfile(tarfile.TarInfo("bar"))
1358 data = tarfile.TarInfo("foo").tobuf()
1362 data = tarfile.TarInfo("foo").tobuf()
1373 tarinfo = tarfile.TarInfo("0123456789" * 10)
1374 tarinfo.tobuf(tarfile.USTAR_FORMAT)
1377 tarinfo = tarfile.TarInfo("0123456789" * 10 + "0")
1378 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
1381 tarinfo = tarfile.TarInfo("123/" * 62 + "longname")
1382 tarinfo.tobuf(tarfile.USTAR_FORMAT)
1385 tarinfo = tarfile.TarInfo("1234567/" * 31 + "longname")
1386 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
1389 tarinfo = tarfile.TarInfo("123/" * 126 + "longname")
1390 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
1393 tarinfo = tarfile.TarInfo("longlink")
1394 tarinfo.linkname = "123/" * 126 + "longname"
1395 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
1398 tarinfo = tarfile.TarInfo("name")
1399 tarinfo.uid = 010000000
1400 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
1403 tarinfo = tarfile.TarInfo("123/" * 126 + "longname")
1404 tarinfo.tobuf(tarfile.GNU_FORMAT)
1406 tarinfo = tarfile.TarInfo("longlink")
1407 tarinfo.linkname = "123/" * 126 + "longname"
1408 tarinfo.tobuf(tarfile.GNU_FORMAT)
1411 tarinfo = tarfile.TarInfo("name")
1412 tarinfo.uid = 04000000000000000000L
1413 self.assertRaises(ValueError, tarinfo.tobuf, tarfile.GNU_FORMAT)
1416 tarinfo = tarfile.TarInfo("123/" * 126 + "longname")
1417 tarinfo.tobuf(tarfile.PAX_FORMAT)
1419 tarinfo = tarfile.TarInfo("longlink")
1420 tarinfo.linkname = "123/" * 126 + "longname"
1421 tarinfo.tobuf(tarfile.PAX_FORMAT)
1423 tarinfo = tarfile.TarInfo("name")
1424 tarinfo.uid = 04000000000000000000L
1425 tarinfo.tobuf(tarfile.PAX_FORMAT)
1555 data = bz2.compress(tarfile.TarInfo("foo").tobuf())