Skip to content

Compressors

blake2signer.compressors

Compressors: classes that implement the CompressorInterface.

GzipCompressor

Gzip compressor.

default_compression_level: int property readonly

Get the default compression level.

compress(self, data, *, level)

Compress given data using gzip.

Parameters:

Name Type Description Default
data bytes

Data to compress.

required
level int

Desired compression level.

required

Returns:

Type Description
bytes

Raw compressed data.

Source code in blake2signer/compressors.py
def compress(self, data: bytes, *, level: int) -> bytes:
    """Compress given data using gzip.

    Args:
        data: Data to compress.
        level: Desired compression level.

    Returns:
        Raw compressed data.
    """
    return gzip.compress(data, compresslevel=level)

decompress(self, data)

Decompress given compressed data compressed with gzip.

Parameters:

Name Type Description Default
data bytes

Compressed data to decompress.

required

Returns:

Type Description
bytes

Original data.

Source code in blake2signer/compressors.py
def decompress(self, data: bytes) -> bytes:
    """Decompress given compressed data compressed with gzip.

    Args:
        data: Compressed data to decompress.

    Returns:
        Original data.
    """
    return gzip.decompress(data)

ZlibCompressor

Zlib compressor.

default_compression_level: int property readonly

Get the default compression level.

compress(self, data, *, level)

Compress given data using zlib.

Parameters:

Name Type Description Default
data bytes

Data to compress.

required
level int

Desired compression level.

required

Returns:

Type Description
bytes

Raw compressed data.

Source code in blake2signer/compressors.py
def compress(self, data: bytes, *, level: int) -> bytes:
    """Compress given data using zlib.

    Args:
        data: Data to compress.
        level: Desired compression level.

    Returns:
        Raw compressed data.
    """
    return zlib.compress(data, level=level)

decompress(self, data)

Decompress given compressed data compressed with zlib.

Parameters:

Name Type Description Default
data bytes

Compressed data to decompress.

required

Returns:

Type Description
bytes

Original data.

Source code in blake2signer/compressors.py
def decompress(self, data: bytes) -> bytes:
    """Decompress given compressed data compressed with zlib.

    Args:
        data: Compressed data to decompress.

    Returns:
        Original data.
    """
    return zlib.decompress(data)