ConfigLoader
The config_loader module handles loading and parsing YAML and TOML configuration files.
- class oduit.config_loader.LoadedConfigDetails(config: dict[str, Any], canonical_config: dict[str, Any], raw_shape: str, normalized_shape: str, shape_version: str, format_type: str, config_path: str | None, deprecation_warnings: tuple[str, ...])[source]
Bases:
objectNormalized configuration plus shape metadata.
- class oduit.config_loader.ImportedOdooConfDetails(config: dict[str, Any], handled_option_keys: tuple[str, ...], unknown_option_keys: tuple[str, ...], odoo_bin_candidates: tuple[str, ...])[source]
Bases:
objectImported Odoo conf plus metadata useful for migration UX.
- class oduit.config_loader.ConfigLoader(config_dir: str | None = None)[source]
Bases:
objectHandles loading and managing Odoo environment configurations.
- __init__(config_dir: str | None = None)[source]
Initialize ConfigLoader with optional custom config directory.
- get_config_path(env_name: str, format_type: str = 'yaml') str[source]
Returns full path to environment-specific config.
- resolve_config_path(env_name: str) tuple[str, str][source]
Resolve the config path and format for an environment name.
- load_local_config_details() LoadedConfigDetails[source]
Load local config plus canonical normalized metadata.
- inspect_odoo_conf_import(conf_path: str, sectioned: bool = False) ImportedOdooConfDetails[source]
Import Odoo configuration and return migration-friendly metadata.
- import_odoo_conf(conf_path: str, sectioned: bool = False) dict[str, Any][source]
Import Odoo configuration from .conf file and convert to oduit format.
- Parameters:
conf_path – Path to the Odoo .conf file
sectioned – If True, return configuration in sectioned format
- Returns:
Dictionary with oduit-compatible configuration
- Raises:
FileNotFoundError – If conf file doesn’t exist
ValueError – If conf file format is invalid
- load_config(env_name: str) dict[str, Any][source]
Load config from ~/.config/oduit/<env>.(yaml|toml|conf) or from a direct file path
- load_config_details(env_name: str) LoadedConfigDetails[source]
Load config plus canonical normalized metadata.
Usage Examples
Loading Configurations
from oduit.config_loader import ConfigLoader
loader = ConfigLoader()
# Load configuration by environment name
config = loader.load_config('dev') # Loads ~/.config/oduit/dev.yaml or dev.toml
config = loader.load_config('prod') # Loads ~/.config/oduit/prod.yaml or prod.toml
# Load local configuration from current directory
if loader.has_local_config():
config = loader.load_local_config() # Loads .oduit.toml
Environment Management
from oduit.config_loader import ConfigLoader
loader = ConfigLoader()
# Get available environments
environments = loader.get_available_environments()
print(f"Available environments: {environments}")
# Load demo configuration for testing
demo_config = loader.load_demo_config()
print(f"Demo mode: {demo_config.get('demo_mode', False)}")