Decompress a block of data. Refer to LZMADecompressor's docstring for a description of the optional arguments *format*, *check* and *filters*. For incremental decompression, use an LZMADecompressor instead.
(data, format=FORMAT_AUTO, memlimit=None, filters=None)
| 337 | |
| 338 | |
| 339 | def decompress(data, format=FORMAT_AUTO, memlimit=None, filters=None): |
| 340 | """Decompress a block of data. |
| 341 | |
| 342 | Refer to LZMADecompressor's docstring for a description of the |
| 343 | optional arguments *format*, *check* and *filters*. |
| 344 | |
| 345 | For incremental decompression, use an LZMADecompressor instead. |
| 346 | """ |
| 347 | results = [] |
| 348 | while True: |
| 349 | decomp = LZMADecompressor(format, memlimit, filters) |
| 350 | try: |
| 351 | res = decomp.decompress(data) |
| 352 | except LZMAError: |
| 353 | if results: |
| 354 | break # Leftover data is not a valid LZMA/XZ stream; ignore it. |
| 355 | else: |
| 356 | raise # Error on the first iteration; bail out. |
| 357 | results.append(res) |
| 358 | if not decomp.eof: |
| 359 | raise LZMAError("Compressed data ended before the " |
| 360 | "end-of-stream marker was reached") |
| 361 | data = decomp.unused_data |
| 362 | if not data: |
| 363 | break |
| 364 | return b"".join(results) |
nothing calls this directly
no test coverage detected