MCPcopy Index your code
hub / github.com/python/cpython / _init_write_gz

Method _init_write_gz

Lib/tarfile.py:424–439  ·  view source on GitHub ↗

Initialize for writing with gzip compression.

(self, compresslevel)

Source from the content-addressed store, hash-verified

422 self.close()
423
424 def _init_write_gz(self, compresslevel):
425 """Initialize for writing with gzip compression.
426 """
427 self.cmp = self.zlib.compressobj(compresslevel,
428 self.zlib.DEFLATED,
429 -self.zlib.MAX_WBITS,
430 self.zlib.DEF_MEM_LEVEL,
431 0)
432 timestamp = struct.pack("<L", int(time.time()))
433 self.__write(b"\037\213\010\010" + timestamp + b"\002\377")
434 if self.name.endswith(".gz"):
435 self.name = self.name[:-3]
436 # Honor "directory components removed" from RFC1952
437 self.name = os.path.basename(self.name)
438 # RFC1952 says we must use ISO-8859-1 for the FNAME field.
439 self.__write(self.name.encode("iso-8859-1", "replace") + NUL)
440
441 def write(self, s):
442 """Write string s to the stream.

Callers 1

__init__Method · 0.95

Calls 6

__writeMethod · 0.95
packMethod · 0.45
timeMethod · 0.45
endswithMethod · 0.45
basenameMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected