htesp.check_json

Backwards-compatible wrapper around htesp.config.

Historically every module did from check_json import config. That name is kept so the science modules read the same as before, but the implementation is now the searching, caching, default-merging loader in htesp.config.

exception htesp.check_json.ConfigError[source]

Raised by config() in strict mode and by require_api_key().

htesp.check_json.api_key(cfg: Mapping[str, Any] | None = None) → str | None[source]

Materials Project API key: environment, then credentials file, then config.

Returns None when only the shipped placeholder is available, so callers can give a useful message rather than sending use_your_API_KEY to the MP servers.

htesp.check_json.clear_cache() → None[source]

Forget every parsed configuration (used by the tests).

htesp.check_json.config(start: PathLike | str | None = None, strict: bool = False) → dict[source]

Return the effective configuration as a plain dict.

Always returns a usable mapping: when no config.json is found the packaged default is returned, so importing a module no longer depends on the working directory. strict=True raises ConfigError instead, for commands that genuinely need the user’s own settings.

htesp.check_json.config_path(start: PathLike | str | None = None) → Path | None[source]

The file config() would read, or None for the packaged default.

htesp.check_json.find_config(start: PathLike | str | None = None) → Path | None[source]

Return the first config.json at or above start.

$HTESP_CONFIG wins over the directory search, so a whole campaign can share one file without copying it into every working directory.

htesp.check_json.require_api_key(cfg: Mapping[str, Any] | None = None) → str[source]

api_key(), but raise a message that says how to set it.

htesp.check_json.validate(cfg: Mapping[str, Any] | None = None) → list[str][source]

Return a list of human-readable problems with cfg (empty == fine).