mafw.lazy_import
This module provides classes for lazy importing of plugins, ensuring thread-safe access and transparent usage.
- Classes:
LazyImportPlugin: A generic class for lazy importing of plugin classes.
LazyImportProcessor: A specialised class for lazy importing of Processor plugins.
LazyImportUserInterface: A specialised class for lazy importing of UserInterface plugins.
- Protocols:
ProcessorClassProtocol: Defines the expected interface for Processor classes.
UserInterfaceClassProtocol: Defines the expected interface for UserInterface classes.
Added in version v2.0.0.
Module Attributes
The class type to be used for the generic lazy import plugin. |
|
The instance type to be used for the generic lazy import plugin. |
Classes
|
Proxy object that lazily imports a plugin class only when accessed. |
|
Lazy import proxy for Processor classes. |
|
Lazy import proxy for UserInterface classes. |
|
Protocol for Processor classes. |
|
Protocol for UserInterface classes. |
- class mafw.lazy_import.LazyImportPlugin(module: str, class_name: str)[source]
-
Proxy object that lazily imports a plugin class only when accessed. Thread-safe and transparent to the user.
Added in version v2.0.0.
Constructor parameter:
- Parameters:
module (str) – The module name where the class is located.
class_name (str) – The name of the class to be lazily imported.
- class mafw.lazy_import.LazyImportProcessor(module: str, class_name: str)[source]
Bases:
LazyImportPlugin[Processor,Processor]Lazy import proxy for Processor classes.
Added in version v2.0.0.
Constructor parameter:
- Parameters:
module (str) – The module name where the class is located.
class_name (str) – The name of the class to be lazily imported.
- class mafw.lazy_import.LazyImportUserInterface(module: str, class_name: str, ui_name: str)[source]
Bases:
LazyImportPlugin[UserInterfaceBase,UserInterfaceBase]Lazy import proxy for UserInterface classes.
Added in version v2.0.0.
Constructor parameter:
- Parameters:
module (str) – The module name where the class is located.
class_name (str) – The name of the class to be lazily imported.
ui_name (str) – The expected name of the user interface.
- _post_load(cls: Type[UserInterfaceBase]) Type[UserInterfaceBase][source]
Perform operations after loading the UserInterface class.
- Parameters:
cls (Type[UserInterfaceBase]) – The UserInterface class type that has been loaded.
- Returns:
The UserInterface class type after post-load operations.
- Return type:
Type[UserInterfaceBase]
- Raises:
ValueError – If the class name is inconsistent with the expected name.
- class mafw.lazy_import.ProcessorClassProtocol(*args, **kwargs)[source]
Bases:
ProtocolProtocol for Processor classes.
Added in version v2.0.0.
- Variables:
plugin_name – The name of the plugin.
plugin_qualname – The qualified name of the plugin.
__name__ – The name of the class.
- class mafw.lazy_import.R
The instance type to be used for the generic lazy import plugin.
alias of TypeVar(‘R’)
- class mafw.lazy_import.T
The class type to be used for the generic lazy import plugin.
alias of TypeVar(‘T’)