Module

config.loader

Configuration loader supporting TOML and YAML formats.

Classes

ConfigLoader
Loads site configuration from bengal.toml or bengal.yaml.
12

Loads site configuration from bengal.toml or bengal.yaml.

Methods 4

load
Load configuration from file.
1 dict[str, Any]
def load(self, config_path: Path | None = None) -> dict[str, Any]

Load configuration from file.

Parameters 1
config_path Path | None

Optional explicit path to config file

Returns

dict[str, Any]

Configuration dictionary

get_warnings
Get configuration warnings (aliases used, unknown sections, etc).
0 list[str]
def get_warnings(self) -> list[str]

Get configuration warnings (aliases used, unknown sections, etc).

Returns

list[str]

get_deprecated_keys
Get list of deprecated keys found (old_key, new_location, note).
0 list[tuple[str, str…
def get_deprecated_keys(self) -> list[tuple[str, str, str]]

Get list of deprecated keys found (old_key, new_location, note).

Returns

list[tuple[str, str, str]]

print_warnings
Print configuration warnings if verbose mode is enabled.
1 None
def print_warnings(self, verbose: bool = False) -> None

Print configuration warnings if verbose mode is enabled.

Parameters 1
verbose bool
Internal Methods 8
__init__
Initialize the config loader.
1 None
def __init__(self, root_path: Path) -> None

Initialize the config loader.

Parameters 1
root_path Path

Root directory to look for config files

_load_file
Load a specific config file with validation.
1 dict[str, Any]
def _load_file(self, config_path: Path) -> dict[str, Any]

Load a specific config file with validation.

Parameters 1
config_path Path

Path to config file

Returns

dict[str, Any]

Validated configuration dictionary

_load_toml
Load TOML configuration file. Uses bengal.utils.file_io.load_toml internally f…
1 dict[str, Any]
def _load_toml(self, config_path: Path) -> dict[str, Any]

Load TOML configuration file.

Uses bengal.utils.file_io.load_toml internally for robust loading.

Parameters 1
config_path Path

Path to TOML file

Returns

dict[str, Any]

Configuration dictionary

_load_yaml
Load YAML configuration file. Uses bengal.utils.file_io.load_yaml internally f…
1 dict[str, Any]
def _load_yaml(self, config_path: Path) -> dict[str, Any]

Load YAML configuration file.

Uses bengal.utils.file_io.load_yaml internally for robust loading.

Parameters 1
config_path Path

Path to YAML file

Returns

dict[str, Any]

Configuration dictionary

_flatten_config
Flatten nested config structure for easier access.
1 dict[str, Any]
def _flatten_config(self, config: dict[str, Any]) -> dict[str, Any]

Flatten nested config structure for easier access.

Parameters 1
config dict[str, Any]

Nested configuration dictionary

Returns

dict[str, Any]

Flattened configuration (sections are preserved but accessible at top level too)

_normalize_sections
Normalize config section names using aliases. Accepts common variations like […
1 dict[str, Any]
def _normalize_sections(self, config: dict[str, Any]) -> dict[str, Any]

Normalize config section names using aliases.

Accepts common variations like [menus] → [menu]. Warns about unknown sections.

Parameters 1
config dict[str, Any]

Raw configuration dictionary

Returns

dict[str, Any]

Normalized configuration with canonical section names

_default_config
Get default configuration. Uses centralized defaults from bengal.config.defaul…
0 dict[str, Any]
def _default_config(self) -> dict[str, Any]

Get default configuration.

Uses centralized defaults from bengal.config.defaults module.

Returns

dict[str, Any]

Default configuration dictionary

_apply_env_overrides
Apply environment-based overrides for deployment platforms. Delegates to share…
1 dict[str, Any]
def _apply_env_overrides(self, config: dict[str, Any]) -> dict[str, Any]

Apply environment-based overrides for deployment platforms.

Delegates to shared utility function. Kept as method for backward compatibility.

Parameters 1
config dict[str, Any]
Returns

dict[str, Any]

Functions

pretty_print_config
Pretty print configuration using Rich (if available) or fallback to pprint.
2 None
def pretty_print_config(config: dict[str, Any], title: str = 'Configuration') -> None

Pretty print configuration using Rich (if available) or fallback to pprint.

Parameters 2

Name Type Default Description
config dict[str, Any]

Configuration dictionary to display

title str 'Configuration'

Title for the output