gzip_tools.py module

is_gz_bytes(checked_bytes)

Checks if provided bytes is a gzipped file stream. If so returns True.

Parameters:

checked_bytes (bytes) – bytes to check for being gz zipped file

Returns:

flag indicating if provided bytes is a gz compressed bytes

Return type:

bool

get_unzipped_gz(to_be_unzipped_bytes)

Unzips provided input bytes.

Parameters:

to_be_unzipped_bytes (bytes) – bytes to be unzipped

Returns:

unzipped bytes

Return type:

bytes

check_and_get_unzipped_model(model_src)

Checks if provided model is a gzipped one and unzips it if so.

Parameters:

model_src (Union[str, bytes]) – model source; cna be bytes or string

Returns:

either decompressed bytes or path to model file

Return type:

Union[str, bytes]