Skip to content

Isolation

isolation

ProfileIsolation

Bases: BaseModel

Resolved state paths and their isolation verdict for one profile.

Source code in packages/axm-config/src/axm_config/isolation.py
Python
class ProfileIsolation(BaseModel):  # type: ignore[explicit-any]
    """Resolved state paths and their isolation verdict for one profile."""

    profile: str
    profile_root: Path
    paths: dict[str, Path]
    isolated: bool
    escapes: list[str]

is_isolated(root, paths)

Return whether every named path is contained by the root.

Source code in packages/axm-config/src/axm_config/isolation.py
Python
def is_isolated(
    root: Path,
    paths: Mapping[str, Path],
) -> tuple[bool, list[str]]:
    """Return whether every named path is contained by the root."""
    escapes = sorted(
        key for key, path in paths.items() if not path.is_relative_to(root)
    )
    return not escapes, escapes

profile_isolation(profile=None)

Resolve a profile's state paths without creating filesystem entries.

Source code in packages/axm-config/src/axm_config/isolation.py
Python
def profile_isolation(profile: str | None = None) -> ProfileIsolation:
    """Resolve a profile's state paths without creating filesystem entries."""
    selected_profile = (
        validate_profile_name(profile) if profile is not None else current_profile()
    )
    home = _home_path()
    root = home / "profiles" / selected_profile
    paths = _profile_paths(root)
    isolated, escapes = is_isolated(root, paths)
    return ProfileIsolation(
        profile=selected_profile,
        profile_root=root,
        paths=paths,
        isolated=isolated,
        escapes=escapes,
    )