TRX/tools/shared/packaging.py

18 lines
527 B
Python
Raw Normal View History

2024-10-02 10:23:23 +02:00
import sys
import zipfile
from collections.abc import Iterable
from pathlib import Path
def create_zip(
output_path: Path, source_files: Iterable[tuple[Path, str]]
) -> None:
with zipfile.ZipFile(output_path, "w") as handle:
for source_path, archive_name in source_files:
if not source_path.exists():
print(
f"WARNING: {source_path} does not exist", file=sys.stderr
)
continue
handle.write(source_path, archive_name)