stouputils.archive module — stouputils 1.0.18 documentation

# stouputils.archive module

This module provides functions for creating and managing archives.

- make_archive: Make an archive with consistency using FILES_TO_WRITE variable

- repair_zip_file: Try to repair a corrupted zip file (NOT IMPLEMENTED)

make_archive(source: str, destinations: list[str] | str = [], override_time: None | tuple[int, int, int, int, int, int] = None, create_dir: bool = False) → bool

  Make an archive with consistency using FILES_TO_WRITE variable

  Parameters:

    - source (str) – The source folder to archive

    - destinations (list[str]|str) – The destination folder(s) or file(s) to copy the archive to

    - override_time (None | tuple[int, ...]) – The constant time to use for the archive (e.g. (2024, 1, 1, 0, 0, 0) for 2024-01-01 00:00:00)

    - create_dir (bool) – Whether to create the destination directory if it doesn’t exist (default: False)

  Returns:

    Always returns True unless any strong error

  Return type:

    bool

  Examples:

      > make_archive("/path/to/source", "/path/to/destination.zip")
      > make_archive("/path/to/source", ["/path/to/destination.zip", "/path/to/destination2.zip"])

repair_zip_file(file_path: str, destination: str) → bool

  Try to repair a corrupted zip file by ignoring some of the errors

  Parameters:

    - file_path (str) – Path of the zip file to repair

    - destination (str) – Destination of the new file

  Returns:

    Always returns True unless any strong error

  Return type:

    bool

  Examples:

      > repair_zip_file("/path/to/source.zip", "/path/to/destination.zip")