模块化

This commit is contained in:
riglen
2026-04-20 11:47:10 +08:00
parent 0a46ebf0a8
commit ee9cc6f429
8 changed files with 685 additions and 511 deletions

View File

@@ -0,0 +1,21 @@
from __future__ import annotations
from app.models import AppConfig, ResolvedProfile
def resolve_profile(
*,
app_config: AppConfig,
client_type: str,
selected_source_names: list[str],
) -> ResolvedProfile:
client = app_config.clients[client_type]
return ResolvedProfile(
client_type=client_type,
client=client,
selected_sources={name: app_config.sources[name] for name in selected_source_names if name in app_config.sources},
rules=dict(app_config.rules),
regions=dict(app_config.regions),
selector_groups=list(app_config.selector_groups),
policy_groups=list(app_config.policy_groups),
)