INNER CODE UNIT · Python

load_yaml

lishuangqiang/AI-Meeting · skills/xunzhi-ai-runtime/scripts/extract_config_index.py:49

def load_yaml(path: Path) -> dict[str, Any]:
    if not path.exists():
        return {}
    with path.open("r", encoding="utf-8") as fp:
        loaded = yaml.safe_load(fp)
    return loaded or {}


def group_by_prefix(flat: dict[str, Any]) -> dict[str, list[tuple[str, Any]]]:
    grouped: dict[str, list[tuple[str, Any]]] = defaultdict(list)
    for key, value in flat.items():
        for prefix in TARGET_PREFIXES:
            if key == prefix or key.startswith(prefix + "."):
                grouped[prefix].append((key, value))
                break
    for prefix in grouped:
        grouped[prefix].sort(key=lambda item: item[0])
    return grouped

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…