BaseDecompressor¶
- class tinycompress.base.BaseDecompressor[source]¶
Abstract base class for implementing data decompressors.
This class defines the interface that all decompressor classes must implement. Decompressors process compressed input data in chunks and can be flushed to get any remaining decompressed data.
Attributes
Whether the decompressor has reached the end of the input stream.
Whether the decompressor needs more data to continue.
Data found after the end of the compressed stream.
Methods
__init__Decompresses the given data.
Flushes any pending decompressed data.
Resets the decompressor to its initial state.
- __weakref__¶
list of weak references to the object
- abstractmethod decompress(data, max_length=-1, /)[source]¶
Decompresses the given data.
- Parameters:
data (
Union[bytes,bytearray,memoryview,Iterable[int]]) – Compressed input data, can be bytes, bytearray, memoryview or any iterable of integers in range(256).max_length (
int) – Maximum number of bytes to decompress. Default -1 means no limit.
- Returns:
The decompressed data as bytes or bytearray.
- Raises:
Exception – If the decompressor has been flushed.
- abstract property eof: bool¶
Whether the decompressor has reached the end of the input stream.
- Returns:
True if all input has been processed and flushed, False otherwise.
- abstractmethod flush()[source]¶
Flushes any pending decompressed data.
- Returns:
Any remaining decompressed data as bytes or bytearray.
- Raises:
Exception – If the decompressor has already been flushed.
- abstract property needs_input: bool¶
Whether the decompressor needs more data to continue.
- Returns:
True if more input data is needed, False otherwise.
- abstractmethod reset()[source]¶
Resets the decompressor to its initial state.
This allows reusing the same decompressor instance for multiple decompression tasks.
- abstract property unused_data: bytes | bytearray¶
Data found after the end of the compressed stream.
- Returns:
Any data found after the end of the compressed stream, or empty bytes/bytearray if none.