from ..decorators import LogLevels as LogLevels, handle_error as handle_error
from ..io.path import clean_path as clean_path, super_copy as super_copy

@handle_error
def make_archive(source: str, destinations: list[str] | str | None = None, override_time: None | tuple[int, int, int, int, int, int] = None, create_dir: bool = False, ignore_patterns: str | None = None) -> bool:
    ''' Create a zip archive from a source directory with consistent file timestamps.
\t(Meaning deterministic zip file each time)

\tCreates a zip archive from the source directory and copies it to one or more destinations.
\tThe archive will have consistent file timestamps across runs if override_time is specified.
\tUses maximum compression level (9) with ZIP_DEFLATED algorithm.

\tArgs:
\t\tsource\t\t\t\t(str):\t\t\t\t\t\tThe source folder to archive
\t\tdestinations\t\t(list[str]|str):\t\t\tThe destination folder(s) or file(s) to copy the archive to
\t\toverride_time\t\t(None | tuple[int, ...]):\tThe constant time to use for the archive
\t\t\t(e.g. (2024, 1, 1, 0, 0, 0) for 2024-01-01 00:00:00)
\t\tcreate_dir\t\t\t(bool):\t\t\t\t\t\tWhether to create the destination directory if it doesn\'t exist
\t\tignore_patterns\t\t(str | None):\t\t\t\tGlob pattern(s) to ignore files. Can be a single pattern or comma-separated patterns (e.g. "*.pyc" or "*.pyc,__pycache__,*.log")
\tReturns:
\t\tbool: Always returns True unless any strong error
\tExamples:

\t.. code-block:: python

\t\t> make_archive("/path/to/source", "/path/to/destination.zip")
\t\t> make_archive("/path/to/source", ["/path/to/destination.zip", "/path/to/destination2.zip"])
\t\t> make_archive("src", "hello_from_year_2085.zip", override_time=(2085,1,1,0,0,0))
\t\t> make_archive("src", "output.zip", ignore_patterns="*.pyc")
\t\t> make_archive("src", "output.zip", ignore_patterns="__pycache__")
\t\t> make_archive("src", "output.zip", ignore_patterns="*.pyc,__pycache__,*.log")
\t'''
