registries
Generic EnumRegistry and DescriptorRegistry base classes for runtime-extensible registries.
EnumRegistry
Minimal registry helper for enum-like string values.
meta_consts.py exposes many register/is_known pairs. Centralizing the
semantics here keeps runtime-extensible enums consistent while still
allowing static enums for IDE help.
Source code in src/horde_model_reference/registries.py
__init__
Initialize the enum registry with an optional iterable of initial values.
Parameters:
-
initial(Iterable[T]) –An iterable of initial string values to populate the registry with.
Source code in src/horde_model_reference/registries.py
is_known
Check if a value is known (registered) in the enum registry.
Parameters:
Returns:
-
bool(bool) –True if the value is known (registered), False otherwise.
Source code in src/horde_model_reference/registries.py
register
Register a new value in the enum registry.
Attempting to register a value that is already known is a no-op.
Parameters:
Source code in src/horde_model_reference/registries.py
values
Get a set of all known (registered) values in the enum registry.
Returns:
mutable_values
Expose a live set for backwards-compatible global aliases.
Returns:
DescriptorRegistry
Registry for keyed descriptors with a rebuild hook for derived data.
Category/baseline registries need to invalidate and rebuild derived lookups after mutation, but only once initialization is complete. This helper centralizes that lifecycle so new registries get the same safety guards by default.
Source code in src/horde_model_reference/registries.py
__init__
Initialize the descriptor registry.
Parameters:
-
rebuild(Callable[[dict[K, V]], None]) –Function to call to rebuild derived data when the registry is updated.
Source code in src/horde_model_reference/registries.py
register
Register a key-value pair, raising if the key is already registered.
Parameters:
-
key(K) –The key to register.
-
value(V) –The value to associate with the key.
Raises:
-
ValueError–If the key is already registered.
Source code in src/horde_model_reference/registries.py
finalize
Mark initialization complete and trigger a final rebuild with all registered data.
Subsequent calls to register() will trigger immediate rebuilds, so this should only be called once after the initial batch of registrations is done.
Source code in src/horde_model_reference/registries.py
get
Get the value for a registered key, or raise if the key is unknown.
Parameters:
-
key(K) –The key to look up.
Returns:
-
V(V) –The value associated with the key.
Source code in src/horde_model_reference/registries.py
all
Get a copy of all registered key-value pairs.
Returns:
-
dict[K, V]–dict[K, V]: A copy of all registered key-value pairs.
contains
Check if a key is registered.
Parameters:
-
key(K) –The key to check.
Returns:
-
bool(bool) –True if the key is registered, False otherwise.