Lines Matching refs:fileobj
260 """Copy length bytes from fileobj src to fileobj dst.
398 def __init__(self, name, mode, comptype, fileobj, bufsize):
402 if fileobj is None:
403 fileobj = _LowLevelFile(name, mode)
409 fileobj = _StreamProxy(fileobj)
410 comptype = fileobj.getcomptype()
415 self.fileobj = fileobj
479 self.fileobj.write(self.buf[:self.bufsize])
493 self.fileobj.write(self.buf)
502 self.fileobj.write(struct.pack("<L", self.crc & 0xffffffffL))
503 self.fileobj.write(struct.pack("<L", self.pos & 0xffffFFFFL))
506 self.fileobj.close()
511 """Initialize for reading a gzip compressed fileobj.
606 buf = self.fileobj.read(self.bufsize)
621 def __init__(self, fileobj):
622 self.fileobj = fileobj
623 self.buf = self.fileobj.read(BLOCKSIZE)
626 self.read = self.fileobj.read
637 self.fileobj.close()
650 def __init__(self, fileobj, mode):
651 self.fileobj = fileobj
653 self.name = getattr(self.fileobj, "name", None)
661 self.fileobj.seek(0)
670 raw = self.fileobj.read(self.blocksize)
694 self.fileobj.write(raw)
699 self.fileobj.write(raw)
711 def __init__(self, fileobj, offset, size, sparse=None):
712 self.fileobj = fileobj
744 self.fileobj.seek(self.offset + self.position)
746 return self.fileobj.read(size)
772 self.fileobj.seek(self.offset + realpos)
774 return self.fileobj.read(size)
788 self.fileobj = _FileInFile(tarfile.fileobj,
817 buf += self.fileobj.read()
819 buf += self.fileobj.read(size - len(buf))
837 buf = self.fileobj.read(self.blocksize)
892 self.fileobj.seek(self.position)
1239 buf = tarfile.fileobj.read(BLOCKSIZE)
1241 obj.offset = tarfile.fileobj.tell() - BLOCKSIZE
1272 self.offset_data = tarfile.fileobj.tell()
1289 buf = tarfile.fileobj.read(self._block(self.size))
1336 buf = tarfile.fileobj.read(BLOCKSIZE)
1357 self.offset_data = tarfile.fileobj.tell()
1368 buf = tarfile.fileobj.read(self._block(self.size))
1501 fileobj=None, format=None,
1508 If `fileobj' is given, it is used for reading or writing data. If it
1509 can be determined, `mode' is overridden by `fileobj's mode.
1510 `fileobj' is not closed, when TarFile is closed.
1517 if not fileobj:
1522 fileobj = bltn_open(name, self._mode)
1525 if name is None and hasattr(fileobj, "name"):
1526 name = fileobj.name
1527 if hasattr(fileobj, "mode"):
1528 self._mode = fileobj.mode
1531 self.fileobj = fileobj
1566 self.offset = self.fileobj.tell()
1580 self.fileobj.seek(self.offset)
1585 self.fileobj.seek(self.offset)
1595 self.fileobj.write(buf)
1599 self.fileobj.close()
1627 def open(cls, name=None, mode="r", fileobj=None, bufsize=RECORDSIZE, **kwargs):
1650 if not name and not fileobj:
1657 if fileobj is not None:
1658 saved_pos = fileobj.tell()
1660 return func(name, "r", fileobj, **kwargs)
1662 if fileobj is not None:
1663 fileobj.seek(saved_pos)
1678 return func(name, filemode, fileobj, **kwargs)
1689 _Stream(name, filemode, comptype, fileobj, bufsize),
1695 return cls.taropen(name, mode, fileobj, **kwargs)
1700 def taropen(cls, name, mode="r", fileobj=None, **kwargs):
1705 return cls(name, mode, fileobj, **kwargs)
1708 def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9, **kwargs):
1721 if fileobj is None:
1722 fileobj = bltn_open(name, mode + "b")
1726 gzip.GzipFile(name, mode, compresslevel, fileobj),
1734 def bz2open(cls, name, mode="r", fileobj=None, compresslevel=9, **kwargs):
1746 if fileobj is not None:
1747 fileobj = _BZ2Proxy(fileobj, mode)
1749 fileobj = bz2.BZ2File(name, mode, compresslevel=compresslevel)
1752 t = cls.taropen(name, mode, fileobj, **kwargs)
1776 self.fileobj.write(NUL * (BLOCKSIZE * 2))
1782 self.fileobj.write(NUL * (RECORDSIZE - remainder))
1785 self.fileobj.close()
1815 def gettarinfo(self, name=None, arcname=None, fileobj=None):
1817 object `fileobj' (using os.fstat on its file descriptor). You can
1824 # When fileobj is given, replace name by
1825 # fileobj's real name.
1826 if fileobj is not None:
1827 name = fileobj.name
1845 if fileobj is None:
1851 statres = os.fstat(fileobj.fileno())
2003 def addfile(self, tarinfo, fileobj=None):
2004 """Add the TarInfo object `tarinfo' to the archive. If `fileobj' is
2007 On Windows platforms, `fileobj' should always be opened with mode
2015 self.fileobj.write(buf)
2019 if fileobj is not None:
2020 copyfileobj(fileobj, self.fileobj, tarinfo.size)
2023 self.fileobj.write(NUL * (BLOCKSIZE - remainder))
2124 if isinstance(self.fileobj, _Stream):
2315 self.fileobj.seek(self.offset)
2438 self.fileobj.close()