MCPcopy Index your code
hub / github.com/RustPython/RustPython / _init_read_gz

Method _init_read_gz

Lib/tarfile.py:484–513  ·  view source on GitHub ↗

Initialize for reading a gzip compressed fileobj.

(self)

Source from the content-addressed store, hash-verified

482 self.fileobj.close()
483
484 def _init_read_gz(self):
485 """Initialize for reading a gzip compressed fileobj.
486 """
487 self.cmp = self.zlib.decompressobj(-self.zlib.MAX_WBITS)
488 self.dbuf = b""
489
490 # taken from gzip.GzipFile with some alterations
491 if self.__read(2) != b"\037\213":
492 raise ReadError("not a gzip file")
493 if self.__read(1) != b"\010":
494 raise CompressionError("unsupported compression method")
495
496 flag = ord(self.__read(1))
497 self.__read(6)
498
499 if flag & 4:
500 xlen = ord(self.__read(1)) + 256 * ord(self.__read(1))
501 self.read(xlen)
502 if flag & 8:
503 while True:
504 s = self.__read(1)
505 if not s or s == NUL:
506 break
507 if flag & 16:
508 while True:
509 s = self.__read(1)
510 if not s or s == NUL:
511 break
512 if flag & 2:
513 self.__read(2)
514
515 def tell(self):
516 """Return the stream's file pointer position.

Callers 1

__init__Method · 0.95

Calls 5

__readMethod · 0.95
readMethod · 0.95
CompressionErrorClass · 0.85
ordFunction · 0.85
ReadErrorClass · 0.70

Tested by

no test coverage detected