Factory API
sweet_tea.factory.Factory
Bases: BaseFactory
Base factory class for creating instances of registered classes.
This factory provides the core functionality for instantiating classes from the registry with optional filtering by library and label.
Source code in sweet_tea/factory.py
create(key, library='', label='', configuration=None)
classmethod
Create an instance of a registered class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Name to reference the class from the registry. |
required |
library
|
str
|
Optional library filter for the class. |
''
|
label
|
str
|
Optional label filter for the class. |
''
|
configuration
|
dict[str, Any] | None
|
Configuration parameters as keyword arguments. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
Configured instance of the requested class. |
Raises:
| Type | Description |
|---|---|
SweetTeaError
|
When the key is not found or filters don't match. |
Source code in sweet_tea/factory.py
Methods
create()
sweet_tea.factory.Factory.create(key, library='', label='', configuration=None)
classmethod
Create an instance of a registered class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Name to reference the class from the registry. |
required |
library
|
str
|
Optional library filter for the class. |
''
|
label
|
str
|
Optional label filter for the class. |
''
|
configuration
|
dict[str, Any] | None
|
Configuration parameters as keyword arguments. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
Configured instance of the requested class. |
Raises:
| Type | Description |
|---|---|
SweetTeaError
|
When the key is not found or filters don't match. |