Lines Matching refs:tarfile
4 # tarfile.py
61 # from tarfile import *
62 __all__ = ["TarFile", "TarInfo", "is_tarfile", "TarError"]
79 LNKTYPE = "1" # link (inside tarfile)
101 # tarfile constants
103 # File types that tarfile supports:
314 Used by TarFile.list()
388 """Class that serves as an adapter between TarFile and
781 Is returned by TarFile.extractfile().
785 def __init__(self, tarfile, tarinfo):
786 self.fileobj = _FileInFile(tarfile.fileobj,
913 TarInfo objects are returned by TarFile.getmember(),
914 TarFile.getmembers() and TarFile.gettarinfo() and are
1233 def fromtarfile(cls, tarfile):
1234 """Return the next TarInfo object from TarFile object
1235 tarfile.
1237 buf = tarfile.fileobj.read(BLOCKSIZE)
1239 obj.offset = tarfile.fileobj.tell() - BLOCKSIZE
1240 return obj._proc_member(tarfile)
1250 # 2. Set tarfile.offset to the position where the next member's header will
1253 def _proc_member(self, tarfile):
1258 return self._proc_gnulong(tarfile)
1260 return self._proc_sparse(tarfile)
1262 return self._proc_pax(tarfile)
1264 return self._proc_builtin(tarfile)
1266 def _proc_builtin(self, tarfile):
1270 self.offset_data = tarfile.fileobj.tell()
1275 tarfile.offset = offset
1279 self._apply_pax_info(tarfile.pax_headers, tarfile.encoding, tarfile.errors)
1283 def _proc_gnulong(self, tarfile):
1287 buf = tarfile.fileobj.read(self._block(self.size))
1291 next = self.fromtarfile(tarfile)
1305 def _proc_sparse(self, tarfile):
1334 buf = tarfile.fileobj.read(BLOCKSIZE)
1355 self.offset_data = tarfile.fileobj.tell()
1356 tarfile.offset = self.offset_data + self._block(self.size)
1361 def _proc_pax(self, tarfile):
1366 buf = tarfile.fileobj.read(self._block(self.size))
1372 pax_headers = tarfile.pax_headers
1374 pax_headers = tarfile.pax_headers.copy()
1399 next = self.fromtarfile(tarfile)
1405 next._apply_pax_info(pax_headers, tarfile.encoding, tarfile.errors)
1415 tarfile.offset = offset
1473 class TarFile(object):
1474 """The TarFile Class provides an interface to tar archives.
1508 `fileobj' is not closed, when TarFile is closed.
1615 # TarFile class. The open() method is the only one that is needed for
1620 # This concept allows one to subclass TarFile without losing the comfort of
1627 an appropriate TarFile class.
1764 # The public methods which TarFile provides:
1767 """Close the TarFile. In write-mode, two finishing zero blocks are
1839 tarinfo.tarfile = self
1962 self._dbg(2, "tarfile: Excluded %r" % name)
1967 self._dbg(2, "tarfile: Skipped %r" % name)
1976 self._dbg(1, "tarfile: Unsupported type %r" % name)
1983 self._dbg(2, "tarfile: Excluded %r" % name)
2063 self._dbg(1, "tarfile: %s" % e)
2089 self._dbg(1, "tarfile: %s" % e.strerror)
2091 self._dbg(1, "tarfile: %s %r" % (e.strerror, e.filename))
2096 self._dbg(1, "tarfile: %s" % e)
2208 self._dbg(1, "tarfile: Unknown file type %r, " \
2309 TarFile is opened for reading. Return None if there is no more
2390 """Check if TarFile is still open, and if the operation's mode
2391 corresponds to TarFile's mode.
2444 # class TarFile
2449 for tarinfo in TarFile(...):
2453 def __init__(self, tarfile):
2456 self.tarfile = tarfile
2463 """Return the next item using TarFile's next() method.
2464 When all members have been read, set TarFile as _loaded.
2469 if not self.tarfile._loaded:
2470 tarinfo = self.tarfile.next()
2472 self.tarfile._loaded = True
2476 tarinfo = self.tarfile.members[self.index]
2526 # zipfile compatible TarFile class
2531 """TarFile class compatible with standard module zipfile's
2539 self.tarfile = TarFile.taropen(file, mode)
2541 self.tarfile = TarFile.gzopen(file, mode)
2545 members = self.tarfile.getmembers()
2554 self.tarfile.getmembers())
2556 self.tarfile.list()
2560 return self.tarfile.getmember(name)
2562 return self.tarfile.extractfile(self.tarfile.getmember(name)).read()
2564 self.tarfile.add(filename, arcname)
2574 self.tarfile.addfile(tinfo, StringIO(bytes))
2576 self.tarfile.close()
2594 open = TarFile.open