RLEBDecompressor¶
- class tinycompress.rleb.RLEBDecompressor(minsame=3)[source]¶
RLEB decompression implementation.
This decompressor handles data compressed using Run-Length Encoding for Bytes (RLEB). It processes the compressed data in chunks, expanding runs of repeated bytes and copying literal byte sequences.
Attributes
Whether the decompressor has reached the end of the compressed stream.
Checks if more input data is needed to continue decompression.
Gets any unprocessed data remaining after decompression.
Methods
Initializes a new RLEB decompressor instance.
Decompresses RLEB-encoded data.
Flushes any remaining data and marks decompression as complete.
Resets the decompressor to its initial state.
- __init__(minsame=3)[source]¶
Initializes a new RLEB decompressor instance.
Sets up internal state for processing compressed data including tracking whether in RLE mode and buffering input data.
- Parameters:
minsame (
int) – Minimum compressed size, within MINSAME_MIN and MINSAME_MAX.- Raises:
ValueError – If any parameters are out of their valid ranges.
- __weakref__¶
list of weak references to the object
- decompress(data, max_length=-1, /)[source]¶
Decompresses RLEB-encoded data.
Processes compressed data, expanding runs of repeated bytes and copying literal sequences. Can optionally limit the amount of output produced.
- Parameters:
data (
Union[bytes,bytearray,memoryview,Iterable[int]]) – Compressed input data to decompress.max_length (
int) – Maximum number of output bytes to produce. Default -1 means no limit.
- Returns:
Decompressed data as bytearray.
- Raises:
RLEBException – If the decompressor has already been flushed.
- property eof: bool¶
Whether the decompressor has reached the end of the compressed stream.
- Returns:
True if all input has been processed and flushed, False otherwise.
- flush()[source]¶
Flushes any remaining data and marks decompression as complete.
Should be called when all input data has been provided to ensure any buffered output is returned.
- Returns:
Any remaining decompressed data, or empty bytearray if already flushed.
- property needs_input: bool¶
Checks if more input data is needed to continue decompression.
This property indicates whether the decompressor needs more data to make progress. When True, no output can be produced until more data is provided.
- Returns:
True if more input is needed, False if decompressor can continue with current data.
- reset()[source]¶
Resets the decompressor to its initial state.
Clears all internal buffers and state variables, allowing the decompressor to be reused for a new decompression task.
- property unused_data: bytearray¶
Gets any unprocessed data remaining after decompression.
This property returns any data that was found after the end of the compressed stream.
- Returns:
Remaining unprocessed data if eof is True, empty bytearray otherwise.