import sys import tomllib from dataclasses import dataclass from pathlib import Path @dataclass class Config: azure_connection_string: str scan_page_size: int = 500 scan_delay_ms: int = 200 scan_dir: Path = Path("./scan") delete_batch_size: int = 100 delete_delay_ms: int = 300 def load_config(config_path: Path) -> Config: if not config_path.exists(): print(f"Config file not found: {config_path}") sys.exit(1) with open(config_path, "rb") as f: raw = tomllib.load(f) azure = raw.get("azure", {}) connection_string = azure.get("connection_string") if not connection_string: print("Missing azure.connection_string in config") sys.exit(1) scan = raw.get("scan", {}) delete = raw.get("delete", {}) return Config( azure_connection_string=connection_string, scan_page_size=scan.get("page_size", 500), scan_delay_ms=scan.get("delay_ms", 200), scan_dir=Path(scan.get("scan_dir", "./scan")), delete_batch_size=delete.get("batch_size", 100), delete_delay_ms=delete.get("delay_ms", 300), )