From 0eee28968f0be388a496c8994441dde43c19194f Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Sun, 12 Apr 2026 22:37:35 +0200 Subject: [PATCH] Move download all setting to config.py --- config.py | 1 + downloader.py | 3 +-- main.py | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/config.py b/config.py index 0ecab06..e998940 100644 --- a/config.py +++ b/config.py @@ -19,6 +19,7 @@ class Config: BROWSER_HEADLESS = os.getenv("BROWSER_HEADLESS", "true").lower() == "true" BROWSER_TIMEOUT = int(os.getenv("BROWSER_TIMEOUT", "60000")) LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO") + DOWNLOAD_ALL_YEARS = os.getenv("DOWNLOAD_ALL_YEARS", "false").lower() in ("1", "true", "yes", "y") @classmethod def validate(cls): diff --git a/downloader.py b/downloader.py index cb992db..b826c24 100644 --- a/downloader.py +++ b/downloader.py @@ -1,6 +1,5 @@ import html import logging -import os import re import time from pathlib import Path @@ -370,7 +369,7 @@ def download_all_invoices() -> list[Path]: years = get_year_options(page) if not years: raise RuntimeError("No years found on billing page.") - download_all_years = os.getenv("DOWNLOAD_ALL_YEARS", "").lower() in ("1", "true", "yes", "y") + download_all_years = Config.DOWNLOAD_ALL_YEARS if not download_all_years: years = [years[0]] logger.info("Group '%s' - years: %s", group["label"], years) diff --git a/main.py b/main.py index 120c12a..0c9064b 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 import argparse import logging -import os import sys from config import Config @@ -42,7 +41,7 @@ def main(): if args.notes: Config.INVOICE_NOTES = args.notes if args.all_years: - os.environ["DOWNLOAD_ALL_YEARS"] = "true" + Config.DOWNLOAD_ALL_YEARS = True try: Config.validate()