Toml Config#

class rizemind.configuration.toml_config.TomlConfig(path: str | Path)[source]#

Bases: object

Load and manage configuration from a TOML file.

On initialization, the file is parsed and all string values containing environment variable placeholders are expanded.

path#

Path to the TOML configuration file.

Examples

>>> # Example TOML Configuration File:
>>> # [database]
>>> # host = "127.0.0.1"
>>> # port = 5432
>>> # [api]
>>> # key = "$ENV_API_KEY"
>>> config = TomlConfig("config.toml")
>>> database_host = config.get("database.host", "localhost")
>>> api_key = config.get(["api", "key"], "default_key")
property data: dict#

The loaded configuration data as a dictionary.

get(keys: list[str] | str, default: Any | None = None) Any[source]#

Retrieve a nested configuration value.

Parameters:
  • keys – A dot-delimited string path (for example, "a.b.c") or a

  • segments (list of path)

  • default – Value to return if the path does not exist.

Returns:

The value at the given key path, or default if the path is not present.

rizemind.configuration.toml_config.replace_env_vars(obj: dict[str, Any] | str) dict[str, Any] | str[source]#