• Home
  • Raw
  • Download

Lines Matching refs:tar

87         self.tar = tarfile.open(self.tarname, mode=self.mode,
91 self.tar.close()
97 tarinfo = self.tar.getmember("ustar/regtype")
98 with self.tar.extractfile(tarinfo) as fobj:
106 self.tar.extract("ustar/regtype", TEMPDIR)
107 tarinfo = self.tar.getmember("ustar/regtype")
111 with self.tar.extractfile(tarinfo) as fobj:
124 self.tar.extract("ustar/regtype", TEMPDIR)
125 tarinfo = self.tar.getmember("ustar/regtype")
128 with self.tar.extractfile(tarinfo) as fobj2:
134 self.tar.extract("ustar/regtype", TEMPDIR)
138 tarinfo = self.tar.getmember("ustar/regtype")
139 with self.tar.extractfile(tarinfo) as fobj:
182 with self.tar.extractfile("ustar/regtype") as fobj:
197 with self.tar.extractfile(lnktype) as a, \
198 self.tar.extractfile(regtype) as b:
232 self.tar = tarfile.open(self.tarname, mode=self.mode)
237 self.tar.list(verbose=False)
250 s = b.decode(self.tar.encoding, 'surrogateescape')
274 self.tar.list(verbose=True)
297 def members(tar): argument
298 for tarinfo in tar.getmembers():
302 self.tar.list(verbose=False, members=members(self.tar))
362 tar = tarfile.open(tmpname, self.mode)
363 tar.getnames()
367 self.assertListEqual(tar.getmembers(), [])
369 tar.close()
400 tar = tarfile.open(tmpname, mode="r", ignore_zeros=True)
402 self.assertListEqual(tar.getnames(), ["foo"],
406 tar.close()
410 with tarfile.open(tmpname, "w:") as tar:
413 tar.addfile(t, io.BytesIO(b"a" * 1024))
418 with tarfile.open(tmpname) as tar:
420 for t in tar:
423 with tarfile.open(tmpname) as tar:
424 t = tar.next()
427 tar.extract(t, TEMPDIR)
430 tar.extractfile(t).read()
436 with tarfile.open(support.findfile('recursion.tar')) as tar:
447 with tarfile.open(fileobj=fobj, mode=self.mode) as tar:
448 self.assertIsInstance(tar.name, str)
449 self.assertEqual(tar.name, os.path.abspath(fobj.name))
456 tar = tarfile.open(fileobj=fobj, mode=self.mode)
457 self.assertIsNone(tar.name)
464 with tarfile.open(fileobj=fobj, mode=self.mode) as tar:
465 self.assertIsNone(tar.name)
473 with tarfile.open(fileobj=fobj, mode=self.mode) as tar:
474 self.assertIsNone(tar.name)
481 with tarfile.open(fileobj=fobj, mode=self.mode) as tar:
482 self.assertIsInstance(tar.name, bytes)
483 self.assertEqual(tar.name, os.path.abspath(fobj.name))
487 with tarfile.open(tarname, mode=self.mode) as tar:
488 self.assertIsInstance(tar.name, str)
489 self.assertEqual(tar.name, os.path.abspath(os.fspath(tarname)))
490 with self.taropen(tarname) as tar:
491 self.assertIsInstance(tar.name, str)
492 self.assertEqual(tar.name, os.path.abspath(os.fspath(tarname)))
493 with tarfile.TarFile.open(tarname, mode=self.mode) as tar:
494 self.assertIsInstance(tar.name, str)
495 self.assertEqual(tar.name, os.path.abspath(os.fspath(tarname)))
497 with tarfile.TarFile(tarname, mode='r') as tar:
498 self.assertIsInstance(tar.name, str)
499 self.assertEqual(tar.name, os.path.abspath(os.fspath(tarname)))
505 tar = self.taropen(tmpname, 'q')
507 tar = self.taropen(tmpname, 'rw')
509 tar = self.taropen(tmpname, '')
514 tar = tarfile.open(self.tarname, mode=self.mode)
516 tar.next()
517 t = tar.next()
520 with tar.extractfile(t) as f:
523 tar.close()
530 with tar.open(self.tarname, mode="r:", fileobj=fobj) as tar:
531 t = tar.next()
535 tar.getmembers()
536 self.assertEqual(tar.extractfile(t).read(), data,
550 tarinfo = self.tar.getmember("misc/dirtype-old-v7")
559 self.tar.getmember("misc/regtype-xstar")
564 for tarinfo in self.tar:
573 self.assertEqual(self.tar.getmembers()[-1].name, "misc/eof",
581 with tarfile.open(tarname, errorlevel=1, encoding="iso8859-1") as tar:
582 tar.extract("ustar/regtype", TEMPDIR)
585 tar.extract("ustar/lnktype", TEMPDIR)
591 tar.extract("ustar/symtype", TEMPDIR)
600 tar = tarfile.open(tarname, encoding="iso8859-1")
604 directories = [t for t in tar if t.isdir()]
605 tar.extractall(DIR, directories)
624 tar.close()
632 with tarfile.open(tarname, encoding="iso8859-1") as tar:
633 tarinfo = tar.getmember(dirtype)
634 tar.extract(tarinfo, path=DIR)
645 tarfile.open(tarname, encoding="iso8859-1") as tar:
646 directories = [t for t in tar if t.isdir()]
647 tar.extractall(DIR, directories)
656 tarfile.open(tarname, encoding="iso8859-1") as tar:
657 tarinfo = tar.getmember(dirtype)
658 tar.extract(tarinfo, path=DIR)
671 tar = object.__new__(tarfile.TarFile)
673 tar.__init__(empty)
675 self.assertTrue(tar.fileobj.closed)
684 with tarfile.open(self.tarname) as tar:
685 for m1, m2 in zip(tar, tar):
711 for tarinfo in self.tar:
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:
734 tarinfos = self.tar.getmembers()
735 with self.tar.extractfile(tarinfos[0]) as f: # read the first member
741 tar2 = self.tar
778 tar = tarfile.open(name, mode)
782 tar.close()
787 tar = tarfile.open(name, mode, fileobj=f)
791 tar.close()
841 with self.tar.extractfile(tarinfo) as f:
857 tarinfo = self.tar.getmember("ustar/regtype")
861 tarinfo = self.tar.getmember("ustar/conttype")
865 tarinfo = self.tar.getmember("ustar/dirtype")
869 tarinfo = self.tar.getmember("ustar/dirtype-with-size")
873 tarinfo = self.tar.getmember("ustar/lnktype")
877 tarinfo = self.tar.getmember("ustar/symtype")
881 tarinfo = self.tar.getmember("ustar/blktype")
885 tarinfo = self.tar.getmember("ustar/chrtype")
889 tarinfo = self.tar.getmember("ustar/fifotype")
893 tarinfo = self.tar.getmember("ustar/sparse")
897 tarinfo = self.tar.getmember("gnu/sparse")
901 tarinfo = self.tar.getmember("gnu/sparse-0.0")
905 tarinfo = self.tar.getmember("gnu/sparse-0.1")
909 tarinfo = self.tar.getmember("gnu/sparse-1.0")
913 tarinfo = self.tar.getmember("ustar/umlauts-"
919 self.assertIn(name, self.tar.getnames())
922 tarinfo = self.tar.getmember("misc/regtype-old-v7")
926 self.tar.close()
927 self.tar = tarfile.open(self.tarname, mode=self.mode,
929 tarinfo = self.tar.getmember("pax/umlauts-"
940 tarinfo = self.tar.getmember(longname)
950 tarinfo = self.tar.getmember(longlink)
957 tarinfo = self.tar.getmember(longname)
959 self.tar.fileobj.seek(offset)
960 fobj = io.BytesIO(self.tar.fileobj.read(3 * 512))
968 offset = self.tar.getmember(longname).offset
989 self.tar.extract(name, TEMPDIR)
1041 tar = tarfile.open(tarname, encoding="iso8859-1")
1043 tarinfo = tar.getmember("pax/regtype1")
1049 tarinfo = tar.getmember("pax/regtype2")
1055 tarinfo = tar.getmember("pax/regtype3")
1061 tar.close()
1065 tar = tarfile.open(tarname, encoding="iso8859-1")
1067 tarinfo = tar.getmember("pax/regtype4")
1076 tar.close()
1085 with tarfile.open(fileobj=fobj, mode=self.mode) as tar:
1086 tar.addfile(tarfile.TarInfo("foo"))
1090 del tar
1100 with tarfile.open(tmpname, self.mode) as tar:
1103 tar.addfile(t, io.BytesIO(b"a" * t.size))
1119 tar = tarfile.open(tmpname, self.mode)
1122 tar.addfile(t)
1124 tar.close()
1126 tar = tarfile.open(tmpname)
1128 self.assertEqual(tar.getnames()[0], name,
1131 tar.close()
1135 tar = tarfile.open(tmpname, self.mode)
1140 tar.add(path)
1142 tar.close()
1148 tar = tarfile.open(tmpname, self.mode)
1153 tarinfo = tar.gettarinfo(path)
1158 tarinfo = tar.gettarinfo(path)
1161 tar.close()
1167 tar = tarfile.open(tmpname, self.mode)
1169 tarinfo = tar.gettarinfo(path)
1172 tar.close()
1184 tar = tarfile.open(tmpname, self.mode)
1188 tar.add(path)
1190 for m in tar.getmembers():
1194 tar.close()
1201 with tarfile.open(tmpname, self.mode) as tar:
1205 tarinfo = tar.gettarinfo(path)
1206 tarinfo2 = tar.gettarinfo(os.fspath(path))
1223 tar = tarfile.open(tmpname, self.mode)
1226 tar.gettarinfo(target)
1227 tarinfo = tar.gettarinfo(link)
1230 tar.close()
1240 tar = tarfile.open(tmpname, self.mode)
1242 tarinfo = tar.gettarinfo(path)
1245 tar.close()
1252 tar = tarfile.open(tmpname, self.mode)
1254 self.assertEqual(tar.name, dstname,
1256 tar.add(dstname)
1257 self.assertEqual(tar.getnames(), [],
1261 tar.add(dstname)
1262 self.assertEqual(tar.getnames(), [],
1265 tar.close()
1282 tar = tarfile.open(tmpname, self.mode, encoding="iso8859-1")
1284 tar.add(tempdir, arcname="empty_dir", filter=filter)
1286 tar.close()
1290 tar.add(tempdir, "empty_dir", True, None, filter)
1292 tar = tarfile.open(tmpname, "r")
1294 for tarinfo in tar:
1297 self.assertEqual(len(tar.getmembers()), 3)
1299 tar.close()
1316 tar = tarfile.open(tmpname, self.mode)
1318 tar.add(foo, arcname=path)
1320 tar.close()
1322 tar = tarfile.open(tmpname, "r")
1324 t = tar.next()
1326 tar.close()
1348 with tarfile.open(temparchive, 'w') as tar:
1349 tar.add(source_file, arcname="source")
1350 tar.add(target_file, arcname="symlink")
1352 with tarfile.open(temparchive, errorlevel=2) as tar:
1355 tar.extractall(path=tempdir)
1389 tar = tarfile.open(tmpname, self.mode)
1391 tar.add(".")
1393 tar.close()
1395 tar = tarfile.open(tmpname, "r")
1397 for t in tar:
1401 tar.close()
1414 tar = tarfile.open(tmpname, self.mode, fileobj=f,
1439 tar = tarfile.open(tmpname, self.mode)
1440 tar.close()
1463 tar = tarfile.open(tmpname, self.mode)
1464 tar.close()
1517 tar = tarfile.open(tmpname, "w")
1519 tar.format = tarfile.GNU_FORMAT
1520 tar.addfile(tarinfo)
1523 v2 = tar.offset
1526 tar.close()
1528 tar = tarfile.open(tmpname)
1530 member = tar.next()
1538 tar.close()
1580 tar = tarfile.open(tmpname, self.mode)
1586 tar.addfile(input_blk)
1587 tar.addfile(input_reg)
1589 tar.close()
1592 tar = tarfile.open(tmpname, "r")
1594 output_blk = tar.getmember("my_block_device")
1595 output_reg = tar.getmember("my_regular_file")
1597 tar.close()
1743 self.tar = tarfile.open(tmpname, "w")
1744 self.tar.add(self.foo)
1747 self.tar.close()
1754 tarinfo = self.tar.gettarinfo(self.foo)
1759 tarinfo = self.tar.gettarinfo(self.bar)
1764 self.tar.dereference = True
1765 tarinfo = self.tar.gettarinfo(self.bar)
1779 tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT)
1781 tar.addfile(tarinfo)
1783 tar.close()
1785 tar = tarfile.open(tmpname)
1788 l = tar.getmembers()[0].linkname
1791 n = tar.getmembers()[0].name
1794 tar.close()
1804 tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT,
1807 tar.addfile(tarfile.TarInfo("test"))
1809 tar.close()
1812 tar = tarfile.open(tmpname, encoding="iso8859-1")
1814 self.assertEqual(tar.pax_headers, pax_headers)
1815 self.assertEqual(tar.getmembers()[0].pax_headers, pax_headers)
1817 for key, val in tar.pax_headers.items():
1826 tar.close()
1833 tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT,
1840 tar.addfile(t)
1842 tar.close()
1844 tar = tarfile.open(tmpname, encoding="iso8859-1")
1846 t = tar.getmembers()[0]
1851 tar.close()
1866 tar = tarfile.open(tmpname, "w", format=self.format,
1870 tar.addfile(tarfile.TarInfo(name))
1872 tar.close()
1874 tar = tarfile.open(tmpname, encoding=encoding)
1876 self.assertEqual(tar.getmembers()[0].name, name)
1878 tar.close()
1881 tar = tarfile.open(tmpname, "w", format=self.format,
1887 self.assertRaises(UnicodeError, tar.addfile, tarinfo)
1891 self.assertRaises(UnicodeError, tar.addfile, tarinfo)
1893 tar.close()
1896 tar = tarfile.open(tarname, "r",
1899 for t in tar:
1905 tar.close()
1912 tar = tarfile.open(tmpname, mode="w", format=self.format,
1915 tar.addfile(t)
1917 tar.close()
1919 tar = tarfile.open(tmpname, encoding="iso8859-1")
1921 t = tar.getmember("foo")
1926 tar.close()
1927 tar = tarfile.open(tmpname, encoding="ascii")
1928 t = tar.getmember("foo")
1932 tar.close()
1974 with tarfile.open(tmpname, "w", format=self.format, encoding="utf-8") as tar:
1977 tar.addfile(t)
1979 self.assertRaises(exc, tar.addfile, t)
1982 with tarfile.open(tmpname, "r", encoding="utf-8") as tar:
1983 for t in tar:
1999 with tarfile.open(tmpname, "w", format=self.format, encoding="utf-8") as tar:
2003 tar.addfile(t)
2005 self.assertRaises(exc, tar.addfile, t)
2008 with tarfile.open(tmpname, "r", encoding="utf-8") as tar:
2009 for t in tar:
2025 errors="surrogateescape") as tar:
2027 t = tar.getmember(name)
2045 errors="surrogateescape") as tar:
2047 t = tar.getmember(name)
2065 with tarfile.open(self.tarname, mode) as tar:
2066 tar.addfile(t, f)
2076 with tarfile.open(self.tarname, "a", fileobj=fileobj) as tar:
2077 tar.addfile(tarfile.TarInfo("bar"))
2080 with tarfile.open(self.tarname, fileobj=fileobj) as tar:
2081 self.assertEqual(tar.getnames(), names)
2388 with tarfile.open(tmpname) as tar:
2389 tar.getmembers()
2402 with tarfile.open(tmpname) as tar:
2403 tar.getmembers()
2412 with tarfile.open(dotlessname) as tar:
2413 tar.getmembers()
2423 with tarfile.open(tar_name) as tar:
2424 tar.getmembers()
2438 with filetype.taropen(tar_name) as tar:
2439 tar.getmembers()
2485 with tarfile.open(tarname) as tar:
2486 self.assertFalse(tar.closed, "closed inside runtime context")
2487 self.assertTrue(tar.closed, "context manager failed")
2492 tar = tarfile.open(tarname)
2493 tar.close()
2495 with tar:
2501 with tarfile.open(tarname) as tar:
2505 self.assertTrue(tar.closed, "context manager failed")
2511 with tarfile.open(tmpname, "w") as tar:
2517 self.assertTrue(tar.closed, "context manager failed")
2532 with tarfile.open(fileobj=fobj, mode="w") as tar:
2537 self.assertTrue(tar.closed, "context manager failed")
2547 self.tar.extract(name, TEMPDIR)
2751 with c.open(c.tarname, "wb") as tar:
2752 tar.write(data)