fliploha.blogg.se

Gzip file peek python
Gzip file peek python











gzip file peek python

GzipFile supports the io.BufferedIOBase interface, Writing as fileobj, and retrieve the resulting memory buffer using the This also allows you to pass an io.BytesIO object opened for See the mtime attribute for more details.Ĭalling a GzipFile object’s close() method does not closeįileobj, since you might wish to append more material after the compressedĭata. If omitted or None, theĬurrent time is used. Should only be provided in compression mode. The last modification time field in the stream when compressing. The mtime argument is an optional numeric timestamp to be written to The level of compression 1 is fastest and produces the leastĬompression, and 9 is slowest and produces the most compression. The compresslevel argument is an integer from 0 to 9 controlling

gzip file peek python

In text mode, use open() (or wrap your GzipFile with an Note that the file is always opened in binary mode. The default is the mode of fileobj if discernible otherwise, the 'wb', 'x', or 'xb', depending on whether the file will be read or The mode argument can be any of 'r', 'rb', 'a', 'ab', 'w', Original filename is not included in the header. It defaults to the filename of fileobj, ifĭiscernible otherwise, it defaults to the empty string, and in this case the Included in the gzip file header, which may include the originalįilename of the uncompressed file. When fileobj is not None, the filename argument is only used to be Itĭefaults to None, in which case filename is opened to provide a file

gzip file peek python

Io.BytesIO object, or any other object which simulates a file. The new class instance is based on fileobj, which can be a regular file, an At least one of fileobj and filename must be given a non-trivial Methods of a file object, with the exception of the truncate() GzipFile ( filename=None, mode=None, compresslevel=9, fileobj=None, mtime=None ) ¶Ĭonstructor for the GzipFile class, which simulates most of the Io.TextIOWrapper instance with the specified encoding, errorĬhanged in version 3.4: Added support for the 'x', 'xb' and 'xt' modes.

gzip file peek python

In this case, theĮncoding, errors and newline arguments must not be provided.įor text mode, a GzipFile object is created, and wrapped in an The compresslevel argument is an integer from 0 to 9, as for theįor binary mode, this function is equivalent to the GzipFileĬonstructor: GzipFile(filename, mode, compresslevel). 'w', 'wb', 'x' or 'xb' for binary mode, or 'rt', The mode argument can be any of 'r', 'rb', 'a', 'ab', The filename argument can be an actual filename (a str orīytes object), or an existing file object to read from or write to. Open a gzip-compressed file in binary or text mode, returning a file open ( filename, mode='rb', compresslevel=9, encoding=None, errors=None, newline=None ) ¶ The module defines the following items: gzip. Gzip and gunzip programs, such as those produced byĬompress and pack, are not supported by this module. Note that additional file formats which can be decompressed by the The GzipFile class reads and writes gzip-format files,Īutomatically compressing or decompressing the data so that it looks like an Open(), compress() and decompress() convenience functions. The gzip module provides the GzipFile class, as well as the The data compression is provided by the zlib module. Like the GNU programs gzip and gunzip would. This module provides a simple interface to compress and decompress files just













Gzip file peek python