aea.crypto.registries.base
This module implements the base registry.
ItemId Objects
The identifier of an item class.
name
Get the id name.
EntryPoint Objects
The entry point for a resource.
The regular expression matches the strings in the following format:
path.to.module:className
__
init__
Initialize the entrypoint.
import_
path
Get the import path.
class_
name
Get the class name.
load
Load the item object.
Returns:
the crypto object, loaded following the spec.
ItemSpec Objects
A specification for a particular instance of an object.
__
init__
| __init__(id_: ItemId, entry_point: EntryPoint[ItemType], class_kwargs: Optional[Dict[str, Any]] = None, **kwargs: Dict, ,) -> None
Initialize an item specification.
Arguments:
id_
: the id associated to this specificationentry_point
: The Python entry_point of the environment class (e.g. module.name:Class).class_kwargs
: keyword arguments to be attached on the class as class variables.kwargs
: other custom keyword arguments.
make
Instantiate an instance of the item object with appropriate arguments.
Arguments:
kwargs
: the key word arguments
Returns:
an item
get_
class
Get the class of the item with class variables instantiated.
Returns:
an item class
Registry Objects
Registry for generic classes.
__
init__
Initialize the registry.
supported_
ids
Get the supported item ids.
register
| register(id_: Union[ItemId, str], entry_point: Union[EntryPoint[ItemType], str], class_kwargs: Optional[Dict[str, Any]] = None, **kwargs: Any, ,) -> None
Register an item type.
Arguments:
id_
: the identifier for the crypto type.entry_point
: the entry point to load the crypto object.class_kwargs
: keyword arguments to be attached on the class as class variables.kwargs
: arguments to provide to the crypto class.
make
Create an instance of the associated type item id.
Arguments:
id_
: the id of the item class. Make sure it has been registered earlier before calling this function.module
: dotted path to a module. whether a module should be loaded before creating the object. this argument is useful when the item might not be registered beforehand, and loading the specified module will make the registration. E.g. suppose the call to 'register' for a custom object is located in some_package/init.py. By providing module="some_package", the call to 'register' in such module gets triggered and the make can then find the identifier.kwargs
: keyword arguments to be forwarded to the object.
Returns:
the new item instance.
make_
cls
Load a class of the associated type item id.
Arguments:
id_
: the id of the item class. Make sure it has been registered earlier before calling this function.module
: dotted path to a module. whether a module should be loaded before creating the object. this argument is useful when the item might not be registered beforehand, and loading the specified module will make the registration. E.g. suppose the call to 'register' for a custom object is located in some_package/init.py. By providing module="some_package", the call to 'register' in such module gets triggered and the make can then find the identifier.
Returns:
the new item class.
has_
spec
Check whether there exist a spec associated with an item id.
Arguments:
item_id
: the item identifier.
Returns:
True if it is registered, False otherwise.