pyaml.configuration.factory#
Build PyAML objects from configuration dictionaries and lists.
The factory resolves class paths, optionally validates configuration with Pydantic models, recursively builds nested values, and registers constructed accelerator elements.
Classes
|
Store the resolved information required to construct one object. |
Singleton registry of all instantiated Elements. |
|
Construct PyAML objects from recursively nested configuration data. |
- class pyaml.configuration.factory.BuildInfo(module, config_cls, class_cls, control_modes, config)#
Bases:
objectStore the resolved information required to construct one object.
Attributes
moduleModule containing the target class.
config_clsOptional configuration model used to validate the object data.
class_clsClass to instantiate.
control_modesControl-system modes for creating an
UnboundElement.configRemaining constructor configuration.
- class pyaml.configuration.factory.ElementRegistry#
Bases:
objectSingleton registry of all instantiated Elements.
Elements are registered by name and can later be retrieved individually, by wildcard pattern, or by type.
Methods
Register an Element by name.
Return an Element by name.
Return all elements whose name matches a wildcard pattern.
Return all registered elements of the given type.
Remove all registered elements.
- clear()#
Remove all registered elements.
- get(name)#
Return an Element by name.
- Parameters:
name (str) – Element name.
- Returns:
Element – Registered element.
- Raises:
PyAMLConfigException – If the element is not registered.
- Return type:
- get_by_name(wildcard)#
Return all elements whose name matches a wildcard pattern.
- Parameters:
wildcard (str) – Wildcard expression compatible with
fnmatch.- Returns:
list[Element] – Matching elements.
- Return type:
list[Element]
- get_by_type(element_type)#
Return all registered elements of the given type.
- Parameters:
element_type (type[Element]) – Element type to match.
- Returns:
list[TElement] – Matching elements.
- Return type:
list[TElement]
- register(element)#
Register an Element by name.
- Parameters:
element (Element) – Element to register.
- Raises:
PyAMLConfigException – If the object is not an Element or if another element with the same name is already registered.
- class pyaml.configuration.factory.PyAMLFactory#
Bases:
objectConstruct PyAML objects from recursively nested configuration data.
Methods
Build objects from a top-level mapping or sequence.
Remove all registered elements from the global registry.
- build(data, ignore_external=False)#
Build objects from a top-level mapping or sequence.
- Parameters:
data (dict | list) – Configuration dictionary or list to resolve.
ignore_external (bool) – If
True, ignore unavailable external modules.
- Returns:
Any – Built object, list, or recursively processed mapping.
- Return type:
Any
- clear()#
Remove all registered elements from the global registry.