This commit is contained in:
2026-05-16 21:55:40 +02:00
parent 173d734d04
commit 045763576b
10 changed files with 116 additions and 220 deletions

View File

@@ -27,6 +27,7 @@ class ClientConfig:
domain: str
google_ads_customer_id: str
adspro_client_id: str | None = None
skip_in_all: tuple[str, ...] = ()
rules: dict | None = None
@property
@@ -45,6 +46,18 @@ class AppConfig:
global_rules: dict
def _string_tuple(value) -> tuple[str, ...]:
if value is None:
return ()
if isinstance(value, str):
values = [value]
elif isinstance(value, (list, tuple, set)):
values = value
else:
return ()
return tuple(str(item).strip() for item in values if str(item).strip())
def load_config(path: Path | None = None) -> AppConfig:
config_path = path or ROOT / "config" / "clients.toml"
if not config_path.exists():
@@ -59,6 +72,7 @@ def load_config(path: Path | None = None) -> AppConfig:
domain=domain,
google_ads_customer_id=str(row["google_ads_customer_id"]),
adspro_client_id=str(row.get("adspro_client_id")) if row.get("adspro_client_id") else None,
skip_in_all=_string_tuple(row.get("skip_in_all")),
rules={key: value for key, value in row.items() if isinstance(value, dict)},
)
return AppConfig(clients=clients, global_rules=data.get("global_rules", {}))