Move download all setting to config.py
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
3
main.py
3
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()
|
||||
|
||||
Reference in New Issue
Block a user