Skip to content

Manifest

manifest

manifest.py — Load and save the v1 registry and per-project crux.json files.

load_registry

load_registry(path=None)

Load the v1 registry from path.

If path is None, uses the canonical registry_path() location. When the file does not exist an empty registry is created on disk and returned.

Source code in src/crux_cli/manifest.py
def load_registry(path: Path | None = None) -> dict[str, Any]:
    """Load the v1 registry from *path*.

    If *path* is ``None``, uses the canonical registry_path() location.
    When the file does not exist an empty registry is created on disk and returned.
    """
    if path is None:
        path = registry_path()

    if not path.exists():
        reg = _empty_registry()
        save_registry(reg, path)
        return reg

    with open(path) as f:
        data = json.load(f)
    if not isinstance(data, dict):
        msg = f"Registry at {path} is not a JSON object — got {type(data).__name__}"
        raise ValueError(msg)
    return data

save_registry

save_registry(data, path=None)

Atomically write the v1 registry to path.

Source code in src/crux_cli/manifest.py
def save_registry(data: dict[str, Any], path: Path | None = None) -> None:
    """Atomically write the v1 registry to *path*."""
    if path is None:
        path = registry_path()

    _atomic_json_write(path, data)

load_crux_json

load_crux_json(project_dir)

Load a project's crux.json, returning None if it doesn't exist.

Source code in src/crux_cli/manifest.py
def load_crux_json(project_dir: Path) -> dict[str, Any] | None:
    """Load a project's crux.json, returning None if it doesn't exist."""
    path = project_dir / "crux.json"
    if not path.exists():
        return None
    with open(path) as f:
        return json.load(f)

save_crux_json

save_crux_json(project_dir, data)

Atomically write a project's crux.json.

Source code in src/crux_cli/manifest.py
def save_crux_json(project_dir: Path, data: dict[str, Any]) -> None:
    """Atomically write a project's crux.json."""
    _atomic_json_write(project_dir / "crux.json", data)