runtimepy.registry package#

Submodules#

runtimepy.registry.bool module#

A simple boolean-to-identifier registry interface.

class runtimepy.registry.bool.BooleanRegistry(mapping: MutableMapping[T, str] = None, reverse: MutableMapping[str, T] = None)[source]#

Bases: TwoWayNameMapping[bool]

A simple class for keeping track of boolean-to-identifier mappings.

register(name: str, value: bool) bool[source]#

Register a new name and value pair.

runtimepy.registry.item module#

A module implementing an interface for items that can belong to registries.

class runtimepy.registry.item.RegistryItem(data: dict[str, str | int | float | bool | None | dict[str, str | int | float | bool | None] | list[str | int | float | bool | None]] = None, schemas: SchemaMap = None, dest_attr: str = 'data', verify: bool = True)[source]#

Bases: RuntimepyDictCodec

A class interface for items that can be managed via a registry.

init(data: dict[str, str | int | float | bool | None | dict[str, str | int | float | bool | None] | list[str | int | float | bool | None]]) None[source]#

Perform implementation-specific initialization.

runtimepy.registry.name module#

A simple name-to-identifier registry interface.

class runtimepy.registry.name.NameRegistry(mapping: MutableMapping[int, str] = None, reverse: MutableMapping[str, int] = None)[source]#

Bases: TwoWayNameMapping[int]

A simple class for keeping track of name-to-identifier mappings.

register_name(name: str, identifier: int = None) int | None[source]#

Register a new name.

Module contents#

A generic registry interface for keeping track of objects by either string or integer identifier.

class runtimepy.registry.Registry(data: dict[str, str | int | float | bool | None | dict[str, str | int | float | bool | None] | list[str | int | float | bool | None]] = None, schemas: SchemaMap = None, dest_attr: str = 'data', verify: bool = True)[source]#

Bases: RuntimepyDictCodec, Generic[T]

A base class for a generic registry.

asdict() dict[str, str | int | float | bool | None | dict[str, str | int | float | bool | None] | list[str | int | float | bool | None]][source]#

Get this registry as a dictionary.

get(key: str | int) T | None[source]#

Attempt to get an item from a registry key.

init(data: dict[str, str | int | float | bool | None | dict[str, str | int | float | bool | None] | list[str | int | float | bool | None]]) None[source]#

Perform implementation-specific initialization.

abstract property kind: type[T]#

Determine what kind of registry this is.

name_registry#

alias of NameRegistry

register(name: str, item: T) bool[source]#

Attempt to register a new item.

register_dict(name: str, data: dict[str, str | int | float | bool | None | dict[str, str | int | float | bool | None] | list[str | int | float | bool | None]]) T | None[source]#

Register a new item from dictionary data.

search(pattern: str, exact: bool = False) Iterator[tuple[str, T]][source]#

Search for items in the registry by name.