decompression Module

Streaming decompressors.

class wpull.decompression.DeflateDecompressor[source]

Bases: wpull.decompression.SimpleGzipDecompressor

zlib decompressor with raw deflate detection.

This class doesn’t do any special. It only tries regular zlib and then tries raw deflate on the first decompress.

decompress(value)[source]
flush()[source]
class wpull.decompression.GzipDecompressor[source]

Bases: wpull.decompression.SimpleGzipDecompressor

gzip decompressor with gzip header detection.

This class checks if the stream starts with the 2 byte gzip magic number. If it is not present, it returns the bytes unchanged.

decompress(value)[source]
flush()[source]
class wpull.decompression.SimpleGzipDecompressor[source]

Bases: object

Streaming gzip decompressor.

The interface is like that of zlib.decompressobj (without some of the optional arguments, but it understands gzip headers and checksums.

decompress(value)[source]

Decompress a chunk, returning newly-available data.

Some data may be buffered for later processing; flush must be called when there is no more input data to ensure that all data was processed.

flush()[source]

Return any remaining buffered data not yet returned by decompress.

Also checks for errors such as truncated input. No other methods may be called on this object after flush.

wpull.decompression.gzip_uncompress(data, truncated=False)[source]

Uncompress gzip data.

Parameters:
  • data (bytes) – The gzip data.
  • truncated (bool) – If True, the decompressor is not flushed.

This is a convenience function.

Returns:The inflated data.
Return type:bytes
Raises:zlib.error