Skip to content

Gio.ZlibCompressor

class — extends GObject.Object, Converter

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

Constructors

new

@classmethod
def new(cls, format: ZlibCompressorFormat | int, level: int) -> ZlibCompressor

Creates a compressor.

Parameters:

  • format — the format to use for the compressed data
  • level — compression level (0-9), -1 for default

Methods

get_file_info

def get_file_info(self) -> FileInfo | None

Gets the ZlibCompressor.file-info property.

get_os

def get_os(self) -> int

Gets the ZlibCompressor.os property.

set_file_info

def set_file_info(self, file_info: FileInfo | None = ...) -> None

Sets the ZlibCompressor.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 Converter.reset.

Parameters:

  • file_info — file info for the gzip header

set_os

def set_os(self, os: int) -> None

Sets the ZlibCompressor.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 Converter.reset.

Parameters:

  • os — the OS code to use, or -1 to unset

Properties

file_info

file_info: FileInfo  # read/write

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 ZlibCompressor.format is ZlibCompressorFormat.GZIP.

format

format: ZlibCompressorFormat | int  # read/write

The format of the compressed data.

level

level: int  # read/write

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

-1 for the default level.

os

os: int  # read/write

The OS code of the gzip header.

This will be used if set to a non-negative value, and if ZlibCompressor.format is ZlibCompressorFormat.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.