Registry¶
Registry
¶
Generic registry for storing and retrieving registered elements by key.
Type Parameters:
T Type of registered objects
Source code in meld/registry.py
get(key)
classmethod
¶
Retrieves a registered element by key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key of the element to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
T
|
The registered element. |
register(key)
classmethod
¶
Creates a decorator to register a target function or class under the given key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key to register the element under. |
required |
Returns:
| Type | Description |
|---|---|
Callable[[T], T]
|
A decorator function that registers the target. |
Raises:
| Type | Description |
|---|---|
ValueError
|
In the returned decorator if the key is already registered. |