zmxtools package

Submodules

zmxtools.cli module

unzar(argv=None)[source]

Function that can be called as a script.

Parameters:

argv (Optional[Sequence[str]]) – An optional sequence of input arguments.

Return type:

int

Returns:

The error code. 0: no error, 1: file skipped, 2: incorrect argument, -1: unexpected fatal error.

zmxtools.zar module

read(input_full_file)[source]

Reads a zar archive file and generates a series of (unpacked file name, unpacked file contents) tuples.

The returned Generator produces tuples in the order found in the archive.

Parameters:

input_full_file (Union[Path, str]) – The archive or the path to the archive.

Return type:

Generator[UnpackedData, None, None]

Returns:

A Generator of name-data tuples.

class UnpackedData(file_name, unpacked_contents)[source]

Bases: object

A structure to represent the file blocks in a zar-archive.

Parameters:

name: A string with the name of the file contained in the archive. unpacked_contents: The unpacked (decompressed) bytes of this file.

file_name: str
unpacked_contents: bytes
__annotations__ = {'file_name': <class 'str'>, 'unpacked_contents': <class 'bytes'>}
__dataclass_fields__ = {'file_name': Field(name='file_name',type=<class 'str'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'unpacked_contents': Field(name='unpacked_contents',type=<class 'bytes'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}
__hash__ = None
__init__(file_name, unpacked_contents)
__match_args__ = ('file_name', 'unpacked_contents')
__repr__()

Return repr(self).

extract(input_full_file, output_path=None)[source]

Imports the data from a zar archive file and writes it as a regular directory.

Parameters:
  • input_full_file (Union[Path, str]) – The path to zar-file.

  • output_path (Union[Path, str, None]) – The path where the files should be saved. Default: the same as the input_full_file but without the extension.

Return type:

None

repack(input_full_file, output_full_file=None)[source]

Imports the data from a zar archive file and writes it as a regular zip file.

Parameters:
  • input_full_file (Union[Path, str]) – The file path, including the file name, of the zar-file.

  • output_full_file (Union[Path, str, None]) – TThe file path, including the file name, of the destination zip-file. Default: the same as input_full_file but with the extension changed to ‘zip’.

Return type:

None