update
This commit is contained in:
@@ -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", {}))
|
||||
|
||||
Reference in New Issue
Block a user