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- static disassemble(frame: bytes) Configuration#
- to_string(group: ConfigurationGroup) str#
- exception core.configuration.ConfigurationError(what: str)#
Bases:
RuntimeError
- 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:
objectClass to access a section in the configuration
- 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_enum(enum: type[T_E], key: str, default_value: T_E | None = None) T_E#
Get value of key as enum
Note: this assumes that enum keys are case-insensitive
- 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_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
- core.configuration.absolute_path_type(check_exists: bool) Callable[[Any], Path]#
Return type function for absolute paths
- core.configuration.enum_type(enum: type[T_E]) Callable[[Any], T_E]#
Return type function for enum types
Note: this assumes that enum keys are case-insensitive
- core.configuration.num_type(return_type: type[int] | type[float] | None, min_val: int | float | None, max_val: int | float | None) Callable[[Any], int | float]#
Return type function for numeric types