Lines Matching refs:tar
46 self.tar = tarfile.open(self.tarname, mode=self.mode, encoding="iso8859-1")
49 self.tar.close()
55 tarinfo = self.tar.getmember("ustar/regtype")
56 fobj = self.tar.extractfile(tarinfo)
62 self.tar.extract("ustar/regtype", TEMPDIR)
63 tarinfo = self.tar.getmember("ustar/regtype")
67 fobj2 = self.tar.extractfile(tarinfo)
79 self.tar.extract("ustar/regtype", TEMPDIR)
80 tarinfo = self.tar.getmember("ustar/regtype")
83 fobj2 = self.tar.extractfile(tarinfo)
89 self.tar.extract("ustar/regtype", TEMPDIR)
93 tarinfo = self.tar.getmember("ustar/regtype")
94 fobj = self.tar.extractfile(tarinfo)
142 a = self.tar.extractfile(lnktype)
143 b = self.tar.extractfile(regtype)
166 self.tar = tarfile.open(self.tarname, mode=self.mode)
170 self.tar.list(verbose=False)
202 self.tar.list(verbose=True)
246 tar = tarfile.open(tmpname, self.mode)
247 tar.getnames()
251 self.assertListEqual(tar.getmembers(), [])
253 tar.close()
293 tar = tarfile.open(tmpname, mode="r", ignore_zeros=True)
295 self.assertListEqual(tar.getnames(), ["foo"],
298 tar.close()
302 with tarfile.open(tmpname, "w:") as tar:
305 tar.addfile(t, StringIO.StringIO("a" * 1024))
310 with tarfile.open(tmpname) as tar:
312 for t in tar:
315 with tarfile.open(tmpname) as tar:
316 t = tar.next()
319 tar.extract(t, TEMPDIR)
322 tar.extractfile(t).read()
330 tar = tarfile.open(fileobj=fobj, mode=self.mode)
331 self.assertEqual(tar.name, os.path.abspath(fobj.name))
338 tar = tarfile.open(fileobj=fobj, mode=self.mode)
339 self.assertEqual(tar.name, None)
346 tar = tarfile.open(fileobj=fobj, mode=self.mode)
347 self.assertEqual(tar.name, None)
354 tar = self.taropen(tmpname, 'q')
356 tar = self.taropen(tmpname, 'rw')
358 tar = self.taropen(tmpname, '')
363 tar = tarfile.open(self.tarname, mode=self.mode)
365 tar.next()
366 t = tar.next()
369 data = tar.extractfile(t).read()
371 tar.close()
385 tar = tar.open(self.tarname, mode="r:", fileobj=fobj)
386 t = tar.next()
390 tar.getmembers()
391 self.assertEqual(tar.extractfile(t).read(), data,
393 tar.close()
410 tarinfo = self.tar.getmember("misc/dirtype-old-v7")
419 self.tar.getmember("misc/regtype-xstar")
424 for tarinfo in self.tar:
433 self.assertTrue(self.tar.getmembers()[-1].name == "misc/eof",
438 with tarfile.open(tarname, errorlevel=1, encoding="iso8859-1") as tar:
439 tar.extract("ustar/regtype", TEMPDIR)
442 tar.extract("ustar/lnktype", TEMPDIR)
448 tar.extract("ustar/symtype", TEMPDIR)
457 tar = tarfile.open(tarname, encoding="iso8859-1")
459 directories = [t for t in tar if t.isdir()]
460 tar.extractall(TEMPDIR, directories)
468 tar.close()
479 tar = object.__new__(tarfile.TarFile)
481 tar.__init__(empty)
483 self.assertTrue(tar.fileobj.closed)
492 with tarfile.open(self.tarname) as tar:
493 for m1, m2 in zip(tar, tar):
503 tarinfo = self.tar.next() # get "regtype" (can't use getmember)
504 fobj = self.tar.extractfile(tarinfo)
510 tarinfos = self.tar.getmembers()
511 f = self.tar.extractfile(tarinfos[0]) # read the first member
517 tar2 = self.tar
544 tar = tarfile.open(name, mode)
548 tar.close()
552 tar = tarfile.open(name, mode, fileobj=open(name, "rb"))
556 tar.close()
615 self.assertTrue(md5sum(self.tar.extractfile(tarinfo).read()) == chksum,
630 tarinfo = self.tar.getmember("ustar/regtype")
634 tarinfo = self.tar.getmember("ustar/conttype")
638 tarinfo = self.tar.getmember("ustar/dirtype")
642 tarinfo = self.tar.getmember("ustar/dirtype-with-size")
646 tarinfo = self.tar.getmember("ustar/lnktype")
650 tarinfo = self.tar.getmember("ustar/symtype")
654 tarinfo = self.tar.getmember("ustar/blktype")
658 tarinfo = self.tar.getmember("ustar/chrtype")
662 tarinfo = self.tar.getmember("ustar/fifotype")
666 tarinfo = self.tar.getmember("ustar/sparse")
670 tarinfo = self.tar.getmember("ustar/umlauts-\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
675 self.assertIn(name, self.tar.getnames())
678 tarinfo = self.tar.getmember("misc/regtype-old-v7")
682 self.tar = tarfile.open(self.tarname, mode=self.mode, encoding="iso8859-1")
683 tarinfo = self.tar.getmember("pax/umlauts-\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
693 tarinfo = self.tar.getmember(longname)
702 tarinfo = self.tar.getmember(longlink)
709 tarinfo = self.tar.getmember(longname)
711 self.tar.fileobj.seek(offset)
712 fobj = StringIO.StringIO(self.tar.fileobj.read(3 * 512))
719 offset = self.tar.getmember(longname).offset
732 tarinfo1 = self.tar.getmember("ustar/sparse")
733 fobj1 = self.tar.extractfile(tarinfo1)
734 tarinfo2 = self.tar.getmember("gnu/sparse")
735 fobj2 = self.tar.extractfile(tarinfo2)
746 tar = tarfile.open(tarname, encoding="iso8859-1")
749 tarinfo = tar.getmember("pax/regtype1")
754 tarinfo = tar.getmember("pax/regtype2")
759 tarinfo = tar.getmember("pax/regtype3")
764 tar.close()
768 tar = tarfile.open(tarname, encoding="iso8859-1")
770 tarinfo = tar.getmember("pax/regtype4")
779 tar.close()
788 tar = tarfile.open(fileobj=fobj, mode=self.mode)
789 tar.addfile(tarfile.TarInfo("foo"))
790 tar.close()
794 del tar
810 tar = tarfile.open(tmpname, self.mode)
813 tar.addfile(t)
815 tar.close()
817 tar = tarfile.open(tmpname)
819 self.assertTrue(tar.getnames()[0] == name,
822 tar.close()
826 tar = tarfile.open(tmpname, self.mode)
831 tar.add(path)
833 tar.close()
839 tar = tarfile.open(tmpname, self.mode)
845 tarinfo = tar.gettarinfo(path)
850 tarinfo = tar.gettarinfo(path)
853 tar.close()
859 tar = tarfile.open(tmpname, self.mode)
861 tarinfo = tar.gettarinfo(path)
864 tar.close()
876 tar = tarfile.open(tmpname, self.mode)
879 tar.gettarinfo(target)
880 tarinfo = tar.gettarinfo(link)
883 tar.close()
893 tar = tarfile.open(tmpname, self.mode)
895 tarinfo = tar.gettarinfo(path)
898 tar.close()
905 tar = tarfile.open(tmpname, self.mode)
907 self.assertTrue(tar.name == dstname, "archive name must be absolute")
908 tar.add(dstname)
909 self.assertTrue(tar.getnames() == [], "added the archive to itself")
913 tar.add(dstname)
915 self.assertTrue(tar.getnames() == [], "added the archive to itself")
917 tar.close()
929 tar = tarfile.open(tmpname, self.mode, encoding="iso8859-1")
933 tar.add(tempdir, arcname="empty_dir", exclude=exclude)
935 tar.close()
937 tar = tarfile.open(tmpname, "r")
939 self.assertEqual(len(tar.getmembers()), 1)
940 self.assertEqual(tar.getnames()[0], "empty_dir")
942 tar.close()
961 tar = tarfile.open(tmpname, self.mode, encoding="iso8859-1")
963 tar.add(tempdir, arcname="empty_dir", filter=filter)
965 tar.close()
967 tar = tarfile.open(tmpname, "r")
969 for tarinfo in tar:
972 self.assertEqual(len(tar.getmembers()), 3)
974 tar.close()
991 tar = tarfile.open(tmpname, self.mode)
993 tar.add(foo, arcname=path)
995 tar.close()
997 tar = tarfile.open(tmpname, "r")
999 t = tar.next()
1001 tar.close()
1037 tar = tarfile.open(tmpname, self.mode)
1039 tar.add(".")
1041 tar.close()
1043 tar = tarfile.open(tmpname, "r")
1045 for t in tar:
1048 tar.close()
1062 tar = tarfile.open(temparchive,'w')
1063 tar.add(source_file, arcname=os.path.basename(source_file))
1064 tar.add(target_file, arcname=os.path.basename(target_file))
1065 tar.close()
1067 tar = tarfile.open(temparchive,'r')
1070 tar.extractall(path=tempdir)
1074 tar.close()
1092 tar = tarfile.open(temparchive,'w')
1093 tar.add(target_file, arcname=os.path.basename(target_file))
1094 tar.close()
1098 tar = tarfile.open(temparchive,'r')
1101 tar.extractall(path=tempdir)
1105 tar.close()
1122 tar = tarfile.open(temparchive,'w')
1123 tar.add(source_file, arcname=os.path.basename(source_file))
1124 tar.add(target_file, arcname=os.path.basename(target_file))
1125 tar.close()
1127 tar = tarfile.open(temparchive,'r')
1130 tar.extractall(path=tempdir)
1134 tar.close()
1150 tar = tarfile.open(tmpname, self.mode, fileobj=f,
1161 tar = tarfile.open(tmpname, self.mode)
1162 tar.close()
1191 tar = tarfile.open(tmpname, self.mode)
1192 tar.close()
1236 tar = tarfile.open(tmpname, "w")
1238 tar.format = tarfile.GNU_FORMAT
1239 tar.addfile(tarinfo)
1242 v2 = tar.offset
1245 tar.close()
1247 tar = tarfile.open(tmpname)
1249 member = tar.next()
1257 tar.close()
1302 self.tar = tarfile.open(tmpname, "w")
1303 self.tar.add(self.foo)
1306 self.tar.close()
1313 tarinfo = self.tar.gettarinfo(self.foo)
1318 tarinfo = self.tar.gettarinfo(self.bar)
1323 self.tar.dereference = True
1324 tarinfo = self.tar.gettarinfo(self.bar)
1338 tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT)
1340 tar.addfile(tarinfo)
1342 tar.close()
1344 tar = tarfile.open(tmpname)
1347 l = tar.getmembers()[0].linkname
1350 n = tar.getmembers()[0].name
1353 tar.close()
1363 tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT,
1366 tar.addfile(tarfile.TarInfo("test"))
1368 tar.close()
1371 tar = tarfile.open(tmpname, encoding="iso8859-1")
1373 self.assertEqual(tar.pax_headers, pax_headers)
1374 self.assertEqual(tar.getmembers()[0].pax_headers, pax_headers)
1377 for key, val in tar.pax_headers.iteritems():
1386 tar.close()
1393 tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT, encoding="iso8859-1")
1399 tar.addfile(t)
1401 tar.close()
1403 tar = tarfile.open(tmpname, encoding="iso8859-1")
1405 t = tar.getmembers()[0]
1410 tar.close()
1428 tar = tarfile.open(tmpname, "w", format=self.format, encoding=encoding, errors="strict")
1431 tar.addfile(tarfile.TarInfo(name))
1433 tar.close()
1435 tar = tarfile.open(tmpname, encoding=encoding)
1437 self.assertTrue(type(tar.getnames()[0]) is not unicode)
1438 self.assertEqual(tar.getmembers()[0].name, name.encode(encoding))
1440 tar.close()
1443 tar = tarfile.open(tmpname, "w", format=self.format, encoding="ascii", errors="strict")
1449 self.assertRaises(UnicodeError, tar.addfile, tarinfo)
1451 tar.addfile(tarinfo)
1454 self.assertRaises(UnicodeError, tar.addfile, tarinfo)
1458 self.assertRaises(UnicodeError, tar.addfile, tarinfo)
1460 tar.close()
1463 tar = tarfile.open(tarname, "r", encoding="iso8859-1", errors="strict")
1465 for t in tar:
1471 tar.close()
1480 … tar = tarfile.open("foo.tar", mode="w", fileobj=fobj, format=self.format, encoding="iso8859-1")
1482 tar.addfile(t)
1484 tar.close()
1487 tar = tarfile.open("foo.tar", fileobj=fobj, encoding="iso8859-1")
1488 t = tar.getmember("foo")
1503 tar = tarfile.open(tmpname, "w", format=self.format)
1506 tar.addfile(t)
1507 tar.close()
1516 tar = tarfile.open(tmpname, format=self.format, encoding="ascii",
1518 self.assertEqual(tar.getnames()[0], name)
1528 tar = tarfile.open(tmpname, format=self.format, encoding="iso8859-1",
1530 self.assertEqual(tar.getnames()[0], "\xe4\xf6\xfc/" + u"\u20ac".encode("utf8"))
1542 with tarfile.open(self.tarname, "a", fileobj=fileobj) as tar:
1543 tar.addfile(tarfile.TarInfo("bar"))
1550 with tarfile.open(self.tarname, mode) as tar:
1551 tar.addfile(t, f)
1554 with tarfile.open(self.tarname, fileobj=fileobj) as tar:
1555 self.assertEqual(tar.getnames(), names)
1691 with tarfile.open(tarname) as tar:
1692 self.assertFalse(tar.closed, "closed inside runtime context")
1693 self.assertTrue(tar.closed, "context manager failed")
1698 tar = tarfile.open(tarname)
1699 tar.close()
1701 with tar:
1707 with tarfile.open(tarname) as tar:
1711 self.assertTrue(tar.closed, "context manager failed")
1717 with tarfile.open(tmpname, "w") as tar:
1723 self.assertTrue(tar.closed, "context manager failed")
1738 with tarfile.open(fileobj=fobj, mode="w") as tar:
1743 self.assertTrue(tar.closed, "context manager failed")
1752 self.tar.extract(name, TEMPDIR)
1867 with gzip.open(gzipname, "wb") as tar:
1868 tar.write(data)
1882 tar = bz2.BZ2File(bz2name, "wb")
1884 tar.write(data)
1886 tar.close()