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

Method _init_write_gz

Lib/tarfile.py:426–441  ·  view source on GitHub ↗

Initialize for writing with gzip compression.

(self, compresslevel)

Source from the content-addressed store, hash-verified

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

Callers 1

__init__Method · 0.95

Calls 6

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

Tested by

no test coverage detected