diff --git a/config.py b/config.py index 4ef38c6..801fa6b 100644 --- a/config.py +++ b/config.py @@ -20,7 +20,7 @@ def _get_int(name: str, default: int) -> int: class Config: """ - Konfiguracja aplikacji pobierana z ENV (z sensownymi domyślnymi wartościami). + Konfiguracja aplikacji pobierana z ENV. Zmiennych szukamy pod nazwami: - DATABASE_URL - SECRET_KEY diff --git a/make_zip.py b/make_zip.py new file mode 100644 index 0000000..e133aad --- /dev/null +++ b/make_zip.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python3 +import os +import sys +import zipfile +import subprocess +from pathlib import Path + + +def run_git_command(args, repo_path: Path) -> bytes: + result = subprocess.run( + ["git", *args], + cwd=repo_path, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + check=True, + ) + return result.stdout + + +def get_files_to_archive(repo_path: Path) -> list[str]: + output = run_git_command( + ["ls-files", "--cached", "--others", "--exclude-standard", "-z"], + repo_path, + ) + files = output.decode("utf-8", errors="surrogateescape").split("\0") + return [f for f in files if f] + + +def make_zip(repo_path: Path, output_zip: Path) -> None: + files = get_files_to_archive(repo_path) + + output_zip = output_zip.resolve() + if output_zip.exists(): + output_zip.unlink() + + with zipfile.ZipFile(output_zip, "w", compression=zipfile.ZIP_DEFLATED) as zf: + for rel_path in files: + abs_path = repo_path / rel_path + + if not abs_path.exists(): + continue + + if abs_path.resolve() == output_zip: + continue + + zf.write(abs_path, arcname=rel_path) + + print(f"Utworzono archiwum: {output_zip}") + print(f"Dodano plików: {len(files)}") + + +def main(): + repo_path = Path.cwd() + + if len(sys.argv) > 1: + output_zip = Path(sys.argv[1]) + else: + output_zip = repo_path / f"{repo_path.name}.zip" + + try: + run_git_command(["rev-parse", "--show-toplevel"], repo_path) + except subprocess.CalledProcessError: + print("Błąd: ten katalog nie jest repozytorium Git.", file=sys.stderr) + sys.exit(1) + + make_zip(repo_path, output_zip) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/zbiorka_app/routes.py b/zbiorka_app/routes.py index ed8fcfe..31961fe 100644 --- a/zbiorka_app/routes.py +++ b/zbiorka_app/routes.py @@ -1,7 +1,6 @@ import markdown as md from datetime import datetime, timedelta -from decimal import InvalidOperation - +from decimal import InvalidOperation, Decimal from flask import abort, current_app, flash, redirect, render_template, request, url_for from flask_login import current_user, login_required, login_user, logout_user from markupsafe import Markup diff --git a/zbiorki_app.zip b/zbiorki_app.zip new file mode 100644 index 0000000..6a6592c Binary files /dev/null and b/zbiorki_app.zip differ