cobald.daemon.config.yaml module

cobald.daemon.config.yaml.load_configuration(path: str, loader: ~typing.Type[~yaml.loader.BaseLoader] = <class 'yaml.loader.SafeLoader'>, plugins: ~typing.Tuple[~cobald.daemon.config.mapping.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

  • factory – the factory function/class

  • eager – whether the YAML must be evaluated eagerly


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 to factory(*node), and scalar nodes to factory().

For example, registering the constructor yaml_constructor(factory) as !factory means the following YAML is converted to factory(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=True to enforce eager evaluation before calling the constructor.