cobald.daemon.config.yaml module
- cobald.daemon.config.yaml.load_configuration(path: str, loader: Type[BaseLoader] = <class 'yaml.loader.SafeLoader'>, plugins: Tuple[SectionPlugin] = ())[source]
- cobald.daemon.config.yaml.yaml_constructor(factory: Callable[[...], R], *, eager: bool = False) Callable[[...], R][source]
Convert a factory function/class to a YAML constructor
- Parameters:
factory – the factory function/class
eager – whether the YAML must be evaluated eagerly
- Returns:
factory constructor
Applying this helper to a factory allows it to be used as a YAML constructor, without it knowing about YAML itself. It properly constructs nodes and converts mapping nodes to
factory(**node), sequence nodes tofactory(*node), and scalar nodes tofactory().For example, registering the constructor
yaml_constructor(factory)as!factorymeans the following YAML is converted tofactory(a=0.3, b=0.7):- !factory a: 0.3 b: 0.7
Since YAML can express recursive data, nested data structures are evaluated lazily by default. Set
eager=Trueto enforce eager evaluation before calling the constructor.