bareutils.compression
module bareutils.compression ¶
Summary¶
Compression utilities
Description¶
Only compression direclty supported by standard library functions are provided here to avoid the need for additional dependencies. Other compression methods should be implemented in a separate module.
async function bareutils.compression.compression_reader ¶
Summary¶
Reads a compressed stream and returns the decompressed bytes.
Parameters¶
source: AsyncIterable[bytes]The input stream.
The decompressor.
async generator function bareutils.compression.compression_reader_adapter ¶
Summary¶
Adapters a reader to decompress the data.
function bareutils.compression.compression_writer ¶
Summary¶
Create an async iterator for compressed content.
Parameters¶
buf: bytesThe bytes to compress.
The compressor.
An optional chunk size where -1 indicates no chunking. Defaults to -1.
async generator function bareutils.compression.compression_writer_adapter ¶
Summary¶
Adapts a bytes generator to generated compressed output.
Parameters¶
writer: AsyncIterable[bytes]The writer to be adapted.
A compressor
function bareutils.compression.make_compress_compressobj ¶
Summary¶
Make a compressor for 'compress'
Description¶
Note: This is not used by browsers anymore and should be avoided.
function bareutils.compression.make_compress_decompressobj ¶
Summary¶
Make a compressor for 'compress'
Description¶
Note: This is not used by browsers anymore and should be avoided.
function bareutils.compression.make_deflate_compressobj ¶
Summary¶
Make a compressor for 'deflate'
function bareutils.compression.make_deflate_decompressobj ¶
Summary¶
Make a compressor for 'deflate'
function bareutils.compression.make_gzip_compressobj ¶
Summary¶
Make a compressor for 'gzip'
function bareutils.compression.make_gzip_decompressobj ¶
Summary¶
Make a compressor for 'gzip'
class Compressor ¶
Summary¶
A class to represent the methods available on a compressor
class Decompressor ¶
Summary¶
A class to represent the methods available on a compressor
property Decompressor.eof ¶
Summary¶
A boolean indicating whether the end of the compressed data stream has been reached.
Description¶
This makes it possible to distinguish between a properly formed compressed stream, and an incomplete or truncated one.
property Decompressor.unconsumed_tail ¶
Summary¶
A bytes object that contains any data that was not consumed by the
Description¶
last decompress() call because it exceeded the limit for the uncompressed data buffer.
property Decompressor.unused_data ¶
Summary¶
A bytes object which contains any bytes past the end of the
Description¶
compressed data.
That is, this remains b"" until the last byte that contains compression data is available. If the whole bytestring turned out to contain compressed data, this is b"", an empty bytes object.
method Decompressor.copy ¶
Summary¶
Returns a copy of the decompression object.
Description¶
This can be used to save the state of the decompressor midway through the data stream in order to speed up random seeks into the stream at a future point.
method Decompressor.decompress ¶
Summary¶
Decompress data, returning a bytes object containing the uncompressed
Description¶
data corresponding to at least part of the data in string.
This data should be concatenated to the output produced by any preceding calls to the decompress() method. Some of the input data may be preserved in internal buffers for later processing.
If the optional parameter max_length is non-zero then the return value will be no longer than max_length. This may mean that not all of the compressed input can be processed; and unconsumed data will be stored in the attribute unconsumed_tail. This bytestring must be passed to a subsequent call to decompress() if decompression is to continue. If max_length is zero then the whole input is decompressed, and unconsumed_tail is empty.
Parameters¶
buf: bytesThe data to decompress.
Max length of output. Defaults to 0.
method Decompressor.flush ¶
Summary¶
All pending input is processed, and a bytes object containing the
Description¶
remaining uncompressed output is returned. After calling flush(), the decompress() method cannot be called again; the only realistic action is to delete the object.