Configuration Module#

SPDX-FileCopyrightText: 2025 DESY and the Constellation authors SPDX-License-Identifier: EUPL-1.2

Configuration class

class core.configuration.Configuration(root_dictionary: dict[str, Any] | None = None)#

Bases: Section

assemble() bytes#
static disassemble(frame: bytes) Configuration#
to_string(group: ConfigurationGroup) str#
exception core.configuration.ConfigurationError(what: str)#

Bases: RuntimeError

class core.configuration.ConfigurationGroup(*values)#

Bases: Enum

ALL = 1#
INTERNAL = 3#
USER = 2#
exception core.configuration.InvalidTypeError(config: Section, key: str, vtype: str, ttype: str | None = None, reason: str | None = None)#

Bases: ConfigurationError

exception core.configuration.InvalidUpdateError(config: Section, key: str, reason: str)#

Bases: ConfigurationError

exception core.configuration.InvalidValueError(config: Section, key: str, reason: str)#

Bases: ConfigurationError

exception core.configuration.MissingKeyError(config: Section, key: str)#

Bases: ConfigurationError

class core.configuration.Section(prefix: str, dictionary: dict[str, Any])#

Bases: object

Class to access a section in the configuration

count(keys: list[str]) int#

Check how many of the given keys are defined

get(key: str, default_value: Any | None = None, return_type: type[T] | Callable[[Any], T] | None = None) T | Any#

Get value of a key in requested type

get_array(key: str, default_value: list[T] | None = None, element_type: type | Callable[[Any], T] | None = None) list[T]#

Get list with uniform type

get_float(key: str, default_value: float | None = None, min_val: float | None = None, max_val: float | None = None) float#

Get value of key as float

get_int(key: str, default_value: int | None = None, min_val: int | None = None, max_val: int | None = None) int#

Get value of key as integer

get_keys() list[str]#

Get the keys of the configuration section

get_num(key: str, default_value: int | float | None = None, return_type: type[int] | type[float] | None = None, min_val: int | float | None = None, max_val: int | float | None = None) int | float#

Get value of key as number

get_path(key: str, default_value: Path | None = None, check_exists: bool = False) Path#

Get value of key as path

get_section(key: str, default_value: dict[str, Any] | None = None) Section#

Get nested configuration section

get_set(key: str, default_value: set[T] | None = None, element_type: type | Callable[[Any], T] | None = None) set[T]#

Get set with uniform type

has(key: str) bool#

Check if key is defined

set_alias(new_key: str, old_key: str) None#

Set alias name for an already existing key

set_default(key: str, value: Any) None#

Set default value for a key only if it is not defined yet

core.configuration.absolute_path_type(value: Any, check_exists: bool) Path#

Return type function for absolute paths

core.configuration.num_type(value: Any, return_type: type[int] | type[float] | None, min_val: int | float | None, max_val: int | float | None) int | float#

Return type function for numeric types

core.configuration.resolve_env_variable(match: Match[str]) str#

Resolve a variable name against environment variables

core.configuration.validate_dictionary_for_configuration(dictionary: Any, prefix: str = '') None#