Skip to content

ConfigurationManager

Configuration storage and merge manager.

🔍 API

ConfigurationManager

ConfigurationManager(config_file: Path | None = None)

Centralized configuration manager for Ezpl.

This class handles all configuration operations including loading, saving, and merging configuration from multiple sources.

Initialize the configuration manager.

Parameters:

Name Type Description Default
config_file Path | None

Optional path to configuration file. Defaults to ~/.ezpl/config.json

None

Attributes

config_file property

config_file: Path

Return the path to the configuration file.

Functions

get

get(key: str, default: Any = None) -> Any

Get a configuration value.

Parameters:

Name Type Description Default
key str

Configuration key

required
default Any

Default value if key not found

None

Returns:

Type Description
Any

Configuration value or default

has_key

has_key(key: str) -> bool

Check if a configuration key is explicitly set (not just a default).

A key is considered explicit when it comes from a config file, an environment variable, or a direct call to configure()/set()/update(). Keys that are present only because of default values return False.

Parameters:

Name Type Description Default
key str

Configuration key to check

required

Returns:

Type Description
bool

True if the key was explicitly set, False if it is only a default.

get_log_level

get_log_level() -> str

Get the current log level.

get_log_file

get_log_file() -> Path

Get the current log file path.

get_printer_level

get_printer_level() -> str

Get the current printer level.

get_file_logger_level

get_file_logger_level() -> str

Get the current file logger level.

get_indent_step

get_indent_step() -> int

Get the current indent step.

get_indent_symbol

get_indent_symbol() -> str

Get the current indent symbol.

get_base_indent_symbol

get_base_indent_symbol() -> str

Get the current base indent symbol.

get_log_format

get_log_format() -> str

Get the current log format.

get_log_rotation

get_log_rotation() -> str | None

Get the current log rotation setting.

get_log_retention

get_log_retention() -> str | None

Get the current log retention setting.

get_log_compression

get_log_compression() -> str | None

Get the current log compression setting.

get_all

get_all() -> dict[str, Any]

Get all configuration values.

Returns:

Type Description
dict[str, Any]

Dictionary containing all configuration values

set

set(key: str, value: Any) -> None

Set a configuration value.

Parameters:

Name Type Description Default
key str

Configuration key

required
value Any

Configuration value

required

update

update(config_dict: dict[str, Any]) -> None

Update configuration with new values.

Parameters:

Name Type Description Default
config_dict dict[str, Any]

Dictionary of configuration values to update

required

save

save() -> None

Save current configuration to file.

Raises:

Type Description
FileOperationError

If unable to write to configuration file

reset_to_defaults

reset_to_defaults() -> None

Reset configuration to default values.

reload

reload() -> None

Reload configuration from file and environment variables.

This method reloads the configuration, useful when environment variables or the config file have changed after initialization.

export_to_script

export_to_script(output_file: str | Path, platform: str | None = None) -> None

Export configuration as environment variables script.

Parameters:

Name Type Description Default
output_file str | Path

Path to output script file

required
platform str | None

Target platform ('windows', 'unix', or None for auto-detect)

None

Raises:

Type Description
FileOperationError

If unable to write to output file