ExtensionRegistry¶
- class hugr.ext.ExtensionRegistry(versioned_extensions: dict[ExtensionId, ExtensionVersions] = <factory>)[source]¶
Bases:
objectRegistry of extensions.
Methods
Add a registry of extensions to this registry.
Create an extension registry from a list of extensions.
Retrieve an extension by name.
Get the set of extension IDs in the registry.
Add an extension to the registry.
Attributes
Get all extensions in the registry.
Get the latest version of each extension in the registry.
Set of different versions of each extension in the registry.
- exception ExtensionNotFound(extension_id: ExtensionId)[source]¶
Bases:
ExceptionExtension not found in registry.
- add_note(note, /)¶
Add a note to the exception
- with_traceback(tb, /)¶
Set self.__traceback__ to tb and return self.
- property all_extensions: Iterator[Extension]¶
Get all extensions in the registry.
This may contain different versions of the same extension. To get only the latest version of each extension, use
extensions().
- extend(other: ExtensionRegistry) None[source]¶
Add a registry of extensions to this registry.
If an extension with the same name already exists, the one with the higher version is kept.
- Parameters:
other – The extension registry to add.
- property extensions: Iterator[Extension]¶
Get the latest version of each extension in the registry.
To get all registered versions of all extensions, use
all_extensions().
- classmethod from_extensions(extensions: Iterable[Extension]) ExtensionRegistry[source]¶
Create an extension registry from a list of extensions.
- get_extension(name: ExtensionId) Extension[source]¶
Retrieve an extension by name.
- Parameters:
name – The name of the extension.
- Returns:
Extension in the registry.
- Raises:
ExtensionNotFound – If the extension is not found in the registry.
- ids() set[ExtensionId][source]¶
Get the set of extension IDs in the registry.
- Returns:
Set of extension IDs.
- register(extension: Extension) Extension[source]¶
Add an extension to the registry.
If a different version of the same extension already exists, keeps both.
- Parameters:
extension – The extension to add.
- Returns:
The added extension.
- Raises:
ExtensionExists – If an extension with the same name already exists.
- versioned_extensions: dict[ExtensionId, ExtensionVersions]¶
Set of different versions of each extension in the registry.