pkgcore.config.central module

Collapse multiple config-sources and instantiate from them.

A lot of extra documentation on this is in dev-notes/config.rst.

class pkgcore.config.central.CollapsedConfig(type_obj: ConfigType, config: dict[str, Any], manager, debug: bool = False, default: bool = False)[source]

Bases: object

A collapsed config section.

Variables:
  • type – Our type.

  • config – The supplied configuration values.

  • debug – if True exception wrapping is disabled.

  • default – True if this section is a default.

  • name – our section name or C{None} for an anonymous section.

config: dict[str, Any]
debug: bool
default: bool
instantiate() Any[source]
type_obj: ConfigType
class pkgcore.config.central.ConfigManager(configs=(), debug: bool = False)[source]

Bases: object

Combine config type definitions and configuration sections.

Creates instances of a requested type and name by pulling the required data from any number of provided configuration sources.

The following special type names are recognized:
  • configsection: instantiated and used the same way as an entry in the configs __init__ arg.

These “magic” typenames are only recognized if they are used by a section with a name starting with “autoload”.

add_config_source(config) None[source]

Add the given config source and reload the internal rendering

collapse_named_section(name: str, raise_on_missing: bool = True)[source]

Collapse a config by name, possibly returning a cached instance.

@returns: CollapsedConfig.

If there is no section with this name a ConfigurationError is raised, unless raise_on_missing is False in which case None is returned.

collapse_section(sections, _name: str | None = None)[source]

Collapse a ConfigSection to a CollapsedConfig.

get_default(type_name: str) Any | None[source]

Finds the configuration specified default obj of type_name.

Returns C{None} if no defaults.

reload() None[source]

Reinitialize from the configured config sources.

This throws away all cached instances.

sections() Iterator[str][source]

Return an iterator of all section names.

types