Files
bin/finance/app/config.py
2026-07-17 17:04:59 +02:00

35 lines
963 B
Python

import os
from dataclasses import dataclass
from decimal import Decimal
from functools import lru_cache
from pathlib import Path
@dataclass(frozen=True)
class Settings:
database_url: str
api_key: str
gui_user: str
gui_password_hash: str
session_secret: str
inbox_dir: Path
uploads_dir: Path
warn_threshold: Decimal
horizon_days: int
@lru_cache
def get_settings() -> Settings:
e = os.environ.get
return Settings(
database_url=e("FB_DATABASE_URL", "sqlite:///./fb.sqlite"),
api_key=e("FB_API_KEY", ""),
gui_user=e("FB_GUI_USER", "admin"),
gui_password_hash=e("FB_GUI_PASSWORD_HASH", ""),
session_secret=e("FB_SESSION_SECRET", "dev-secret"),
inbox_dir=Path(e("FB_INBOX_DIR", "./inbox")),
uploads_dir=Path(e("FB_UPLOADS_DIR", "./uploads")),
warn_threshold=Decimal(e("FB_WARN_THRESHOLD", "0")),
horizon_days=int(e("FB_HORIZON_DAYS", "548")),
)