class lzma.LZMADecompressor(format=FORMAT_AUTO, memlimit=None, filters=None)
Create a decompressor object, which can be used to decompress data incrementally.
For a more convenient way of decompressing an entire compressed stream at once, see decompress()
.
The format argument specifies the container format that should be used. The default is FORMAT_AUTO
, which can decompress both .xz
and .lzma
files. Other possible values are FORMAT_XZ
, FORMAT_ALONE
, and FORMAT_RAW
.
The memlimit argument specifies a limit (in bytes) on the amount of memory that the decompressor can use. When this argument is used, decompression will fail with an LZMAError
if it is not possible to decompress the input within the given memory limit.
The filters argument specifies the filter chain that was used to create the stream being decompressed. This argument is required if format is FORMAT_RAW
, but should not be used for other formats. See Specifying custom filter chains for more information about filter chains.
Note
This class does not transparently handle inputs containing multiple compressed streams, unlike decompress()
and LZMAFile
. To decompress a multi-stream input with LZMADecompressor
, you must create a new decompressor for each stream.
-
decompress(data, max_length=-1)
-
Decompress data (a bytes-like object), returning uncompressed data as bytes. Some of data may be buffered internally, for use in later calls to
decompress()
. The returned data should be concatenated with the output of any previous calls todecompress()
.If max_length is nonnegative, returns at most max_length bytes of decompressed data. If this limit is reached and further output can be produced, the
needs_input
attribute will be set toFalse
. In this case, the next call todecompress()
may provide data asb''
to obtain more of the output.If all of the input data was decompressed and returned (either because this was less than max_length bytes, or because max_length was negative), the
needs_input
attribute will be set toTrue
.Attempting to decompress data after the end of stream is reached raises an EOFError. Any data found after the end of the stream is ignored and saved in the
unused_data
attribute.Changed in version 3.5: Added the max_length parameter.
-
check
-
The ID of the integrity check used by the input stream. This may be
CHECK_UNKNOWN
until enough of the input has been decoded to determine what integrity check it uses.
-
eof
-
True
if the end-of-stream marker has been reached.
-
unused_data
-
Data found after the end of the compressed stream.
Before the end of the stream is reached, this will be
b""
.
-
needs_input
-
False
if thedecompress()
method can provide more decompressed data before requiring new uncompressed input.New in version 3.5.
Please login to continue.