INNER CODE UNIT · Python

_load_project_config_for_editing

tomascupr/sandstorm · src/sandstorm/cli.py:122

def _load_project_config_for_editing() -> tuple[Path, dict]:
    """Load sandstorm.json as a mutable JSON object for CLI edits."""
    config_path = _get_config_path()
    if not config_path.exists():
        raise click.ClickException(
            "sandstorm.json not found in the current directory. "
            "Run `ds init` first or create a sandstorm.json file."
        )
    try:
        raw = json.loads(config_path.read_text(encoding="utf-8"))
    except json.JSONDecodeError as exc:
        raise click.ClickException(f"Invalid sandstorm.json: {exc}") from exc
    except OSError as exc:
        raise click.ClickException(f"Failed to read {config_path}: {exc}") from exc
    if not isinstance(raw, dict):
        raise click.ClickException(
            f"sandstorm.json must contain a JSON object, got {type(raw).__name__}."
        )

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…