Skip to content

symfonic.devtools.integrations.catalog

catalog

Load the optional-import map from its repository-owned TOML file.

The map is data, not code: it lives beside the T4.2.1 standard it encodes (integration-adapters.toml), exactly as the T1.2.4 checks read archcheck.toml. Nothing here imports the modules it describes -- the whole point of the map is that reading it costs no optional import.

MapError

Bases: ValueError

The optional-import map is missing or structurally invalid.

load_map

load_map(map_path: Path) -> IntegrationMap

Parse and validate the map file into an :class:IntegrationMap.

Source code in src/symfonic/devtools/integrations/catalog.py
def load_map(map_path: Path) -> IntegrationMap:
    """Parse and validate the map file into an :class:`IntegrationMap`."""
    if not map_path.is_file():
        raise MapError(f"optional-import map not found: {map_path}")
    with map_path.open("rb") as handle:
        raw = tomllib.load(handle)
    rows = raw.get("adapter")
    if not isinstance(rows, list) or not rows:
        raise MapError(f"{map_path} declares no [[adapter]] entries")
    entries = tuple(_entry(row, map_path) for row in rows)
    roots = _roots(raw, map_path)
    base = raw.get("base", {})
    if not isinstance(base, dict):
        raise MapError(f"{map_path}: [base] must be a table")
    try:
        integration_map = IntegrationMap(
            entries=entries,
            optional_roots=roots,
            unpinned_roots=_string_table(raw, "unpinned_roots", map_path),
            adopter_roots=_string_table(raw, "adopter_roots", map_path),
            base_transitive=_texts(base, "transitive_allowed", map_path),
            clean_packages=_texts(base, "clean_packages", map_path),
            integration_packages=_texts(base, "integration_packages", map_path),
        )
    except MapError:
        raise
    except ValueError as exc:
        raise MapError(str(exc)) from exc
    _validate(integration_map, map_path)
    return integration_map