Classes
ConfigLoader
Loads site configuration from bengal.toml or bengal.yaml.
ConfigLoader
Loads site configuration from bengal.toml or bengal.yaml.
Methods 4
load
Load configuration from file.
load
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
Configuration dictionarydict[str, Any]
—
get_warnings
Get configuration warnings (aliases used, unknown sections, etc).
get_warnings
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).
get_deprecated_keys
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.
print_warnings
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.
__init__
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.
_load_file
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
Validated configuration dictionarydict[str, Any]
—
_load_toml
Load TOML configuration file.
Uses bengal.utils.file_io.load_toml internally f…
_load_toml
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
Configuration dictionarydict[str, Any]
—
_load_yaml
Load YAML configuration file.
Uses bengal.utils.file_io.load_yaml internally f…
_load_yaml
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
Configuration dictionarydict[str, Any]
—
_flatten_config
Flatten nested config structure for easier access.
_flatten_config
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
Flattened configuration (sections are preserved but accessible at top level too)dict[str, Any]
—
_normalize_sections
Normalize config section names using aliases.
Accepts common variations like […
_normalize_sections
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
Normalized configuration with canonical section namesdict[str, Any]
—
_default_config
Get default configuration.
Uses centralized defaults from bengal.config.defaul…
_default_config
def _default_config(self) -> dict[str, Any]
Get default configuration.
Uses centralized defaults from bengal.config.defaults module.
Returns
Default configuration dictionarydict[str, Any]
—
_apply_env_overrides
Apply environment-based overrides for deployment platforms.
Delegates to share…
_apply_env_overrides
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.
pretty_print_config
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 |