Skip to content

Profile

profile

current_profile()

Return the active, lexically validated state profile.

Source code in packages/axm-config/src/axm_config/profile.py
Python
def current_profile() -> str:
    """Return the active, lexically validated state profile."""
    profile = os.environ.get(PROFILE_ENV_VAR) or DEFAULT_PROFILE
    return validate_profile_name(profile)

profile_config_path()

Return the config store path for the active profile.

Source code in packages/axm-config/src/axm_config/profile.py
Python
def profile_config_path() -> Path:
    """Return the config store path for the active profile."""
    root = profile_root()
    if root is None:
        return axm_home() / "config.toml"
    return root / "config.toml"

profile_env()

Return the environment overlay that propagates the active profile.

Source code in packages/axm-config/src/axm_config/profile.py
Python
def profile_env() -> dict[str, str]:
    """Return the environment overlay that propagates the active profile."""
    return {PROFILE_ENV_VAR: current_profile()}

profile_root()

Return the isolated state root, or None for production.

Source code in packages/axm-config/src/axm_config/profile.py
Python
def profile_root() -> Path | None:
    """Return the isolated state root, or None for production."""
    profile = current_profile()
    if profile == DEFAULT_PROFILE:
        return None
    return axm_home() / "profiles" / profile

validate_profile_name(name)

Return a valid profile name or raise :class:ConfigError.

Source code in packages/axm-config/src/axm_config/profile.py
Python
def validate_profile_name(name: str) -> str:
    """Return a valid profile name or raise :class:`ConfigError`."""
    if not _PROFILE_RE.fullmatch(name):
        msg = f"invalid profile {name!r}: must match {_PROFILE_RE.pattern}"
        raise ConfigError(msg)
    return name