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: object

Normalized configuration plus shape metadata.

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, ...]
__init__(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, ...]) None
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: object

Imported Odoo conf plus metadata useful for migration UX.

config: dict[str, Any]
handled_option_keys: tuple[str, ...]
unknown_option_keys: tuple[str, ...]
odoo_bin_candidates: tuple[str, ...]
__init__(config: dict[str, Any], handled_option_keys: tuple[str, ...], unknown_option_keys: tuple[str, ...], odoo_bin_candidates: tuple[str, ...]) None
class oduit.config_loader.ConfigLoader(config_dir: str | None = None)[source]

Bases: object

Handles 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.

has_local_config() bool[source]

Check if a local .oduit.toml file exists in current directory.

get_local_config_path() str[source]

Return the absolute path to the local .oduit.toml file.

resolve_config_path(env_name: str) tuple[str, str][source]

Resolve the config path and format for an environment name.

load_local_config() dict[str, Any][source]

Load config from .oduit.toml in current directory.

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:
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.

get_available_environments() list[str][source]

Return a list of available environment names based on config files.

load_demo_config(sectioned: bool = False) dict[str, Any][source]

Load a demo configuration for testing without a real Odoo server

Parameters:

sectioned – If True, return configuration in sectioned format

Returns:

Dictionary with demo configuration including demo_mode=True flag

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)}")