ZlibCompressor#

class ZlibCompressor(**properties: Any)#

Superclasses: Object

Implemented Interfaces: Converter

GZlibCompressor is an implementation of Converter that compresses data using zlib.

Constructors#

class ZlibCompressor
classmethod new(format: ZlibCompressorFormat, level: int) ZlibCompressor#

Creates a compressor.

Added in version 2.24.

Parameters:
  • format – the format to use for the compressed data

  • level – compression level (0-9), -1 for default

Methods#

class ZlibCompressor
get_file_info() FileInfo | None#

Gets the file_info property.

Added in version 2.26.

get_os() int#

Gets the os property.

Added in version 2.86.

set_file_info(file_info: FileInfo | None = None) None#

Sets the file_info property.

Note: it is an error to call this function while a compression is in progress; it may only be called immediately after creation of compressor, or after resetting it with reset.

Added in version 2.26.

Parameters:

file_info – file info for the gzip header

set_os(os: int) None#

Sets the os property.

Note: it is an error to call this function while a compression is in progress; it may only be called immediately after creation of compressor, or after resetting it with reset.

Added in version 2.86.

Parameters:

os – the OS code to use, or -1 to unset

Properties#

class ZlibCompressor
props.file_info: FileInfo#

A FileInfo containing file information to put into the gzip header.

The file name and modification time from the file info will be used.

This will only be used if non-NULL and format is GZIP.

Added in version 2.26.

props.format: ZlibCompressorFormat#

The format of the compressed data.

Added in version 2.24.

props.level: int#

The level of compression from 0 (no compression) to 9 (most compression).

-1 for the default level.

Added in version 2.24.

props.os: int#

The OS code of the gzip header.

This will be used if set to a non-negative value, and if format is GZIP, the compressor will set the OS code of the gzip header to this value.

If the value is unset, zlib will set the OS code depending on the platform. This may be undesirable when reproducible output is desired. In that case setting the OS code to 3 (for Unix) is recommended.

Added in version 2.86.