Skip to main content

Registry

Components of one kind, looked up by the key configuration names them by.

Usage

Source

Registry(
    kind,
    protocol=None,
)

Components are added with the register decorator, or by a third-party package through the dazflow.plugins entry-point group. Each entry point names a module (name = package.module, or package.module:attr); loading it imports the module, whose decorators register its components. Entry points are loaded on the registry’s first lookup, once.

Parameters

kind: str

What the registry holds, for messages: "model", "reader".

protocol: type = None
Optional typing.Protocol every component must have the members of.

Examples

>>> widgets = Registry("widget")
>>> @widgets.register("plain")
... class Plain: ...
>>> widgets["plain"] is Plain

True