💾 Archived View for tris.fyi › pydoc › gzip captured on 2022-01-08 at 13:40:39. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
Functions that read and write gzipped files. The user of the file doesn't have to worry about the compression, but random access is not allowed.
Exception raised in some cases for invalid gzip files.
with_traceback(...) Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.
args = <attribute 'args' of 'BaseException' objects>
characters_written = <attribute 'characters_written' of 'OSError' objects>
errno = <member 'errno' of 'OSError' objects> POSIX exception code
filename = <member 'filename' of 'OSError' objects> exception filename
filename2 = <member 'filename2' of 'OSError' objects> second exception filename
strerror = <member 'strerror' of 'OSError' objects> exception strerror
The GzipFile class simulates most of the methods of a file object with the exception of the truncate() method. This class only supports opening files in binary mode. If you need to open a compressed file in text mode, use the gzip.open() function.
close(self)
detach(self, /) Disconnect this buffer from its underlying raw stream and return it. After the raw stream has been detached, the buffer is in an unusable state.
fileno(self) Invoke the underlying file object's fileno() method. This will raise AttributeError if the underlying file object doesn't support fileno().
flush(self, zlib_mode=2)
isatty(self, /) Return whether this is an 'interactive' stream. Return False if it can't be determined.
peek(self, n)
read(self, size=-1)
read1(self, size=-1) Implements BufferedIOBase.read1() Reads up to a buffer's worth of data if size is negative.
readable(self)
readinto(self, buffer, /)
readinto1(self, buffer, /)
readline(self, size=-1)
readlines(self, hint=-1, /) Return a list of lines from the stream. hint can be specified to control the number of lines read: no more lines will be read if the total size (in bytes/characters) of all lines so far exceeds hint.
rewind(self) Return the uncompressed stream file position indicator to the beginning of the file
seek(self, offset, whence=0)
seekable(self)
tell(self, /) Return current stream position.
truncate(...) Truncate file to size bytes. File pointer is left unchanged. Size defaults to the current IO position as reported by tell(). Returns the new size.
writable(self)
write(self, data)
writelines(self, lines, /) Write a list of lines to stream. Line separators are not added, so it is usual for each of the lines provided to have a line separator at the end.
closed = <property object at 0x7f0566118810>
filename = <property object at 0x7f0566118770>
mtime = <property object at 0x7f05661187c0> Last modification time read from stream, or None
myfileobj = None
compress(data, compresslevel=9, *, mtime=None) Compress data in one shot and return the compressed string. Optional argument is the compression level, in range of 0-9.
decompress(data) Decompress a gzip compressed string in one shot. Return the decompressed string.
main()
open(filename, mode='rb', compresslevel=9, encoding=None, errors=None, newline=None) Open a gzip-compressed file in binary or text mode. The filename argument can be an actual filename (a str or bytes object), or an existing file object to read from or write to. The mode argument can be "r", "rb", "w", "wb", "x", "xb", "a" or "ab" for binary mode, or "rt", "wt", "xt" or "at" for text mode. The default mode is "rb", and the default compresslevel is 9. For binary mode, this function is equivalent to the GzipFile constructor: GzipFile(filename, mode, compresslevel). In this case, the encoding, errors and newline arguments must not be provided. For text mode, a GzipFile object is created, and wrapped in an io.TextIOWrapper instance with the specified encoding, error handling behavior, and line ending(s).
write32u(output, value)
FCOMMENT = 16
FEXTRA = 4
FHCRC = 2
FNAME = 8
FTEXT = 1
READ = 1
WRITE = 2