Uranium
Application Framework
|
A central object to dynamically load modules as plugins. More...
Inherits QObject.
Public Member Functions | |
__init__ (self, parent=None) | |
addSupportedPluginExtension (self, extension, description) | |
supportedPluginExtensions (self) | |
isPluginFile (self, str plugin_path) | |
installPlugin (self, str plugin_path) | |
bool | checkRequiredPlugins (self, List[str] required_plugins) |
Check if all required plugins are loaded. | |
List[str] | getActivePlugins (self) |
Get the list of active plugins. | |
bool | isActivePlugin (self, str plugin_id) |
Ask whether plugin_name is an active plugin. | |
removeActivePlugin (self, str plugin_id) | |
Remove plugin from the list of active plugins. | |
addActivePlugin (self, str plugin_id) | |
Add a plugin to the list of active plugins. | |
loadPlugin (self, str plugin_id) | |
Load a single plugin by id. | |
loadPlugins (self, Optional[dict] meta_data=None) | |
Load all plugins matching a certain set of metadata. | |
PluginObject | getPluginObject (self, str plugin_id) |
Get a plugin object. | |
Dict | getMetaData (self, str plugin_id) |
Get the metadata for a certain plugin. | |
Optional[str] | getPluginPath (self, str plugin_id) |
Get the path to a plugin. | |
List | getAllMetaData (self, **kwargs) |
Get a list of all metadata matching a certain subset of metadata. | |
List | getPluginLocations (self) |
Get the list of plugin locations. | |
addPluginLocation (self, str location) | |
Add a plugin location to the list of locations to search. | |
setApplication (self, app) | |
Set the central application object This is used by plugins as a central access point for other objects. | |
addType (cls, str plugin_type, Callable[[Any], None] register_function) | |
Add a new plugin type. | |
removeType (cls, str plugin_type) | |
Remove a plugin type. | |
"PluginRegistry" | getInstance (cls) |
Get the singleton instance of this class. | |
Static Public Attributes | |
int | APIVersion = 4 |
supportedPluginExtensionsChanged = pyqtSignal() | |
Protected Member Functions | |
_addPluginObject (self, PluginObject plugin_object, str plugin_id, str plugin_type) | |
bool | _populateMetaData (self, str plugin_id) |
private: Populate the list of metadata | |
types.ModuleType | _findPlugin (self, str plugin_id) |
Try to find a module implementing a plugin. | |
_findAllPlugins (self, paths=None) | |
Optional[str] | _locatePlugin (self, str plugin_id, str folder) |
bool | _subsetInDict (self, Dict dictionary, Dict subset) |
Protected Attributes | |
_plugins | |
_plugin_objects | |
_meta_data | |
_plugin_locations | |
_folder_cache | |
_application | |
_active_plugins | |
_supported_file_types | |
_disabled_plugins | |
Static Protected Attributes | |
dict | _type_register_map = {} |
_instance = None | |
A central object to dynamically load modules as plugins.
The PluginRegistry class can load modules dynamically and use them as plugins. Each plugin module is expected to be a directory with and __init__
file defining a getMetaData
and a register
function.
For more details, see the plugins file.
|
protected |
Try to find a module implementing a plugin.
plugin_id | string The name of the plugin to find |
|
protected |
private: Populate the list of metadata
plugin_id | string |
UM.PluginRegistry.PluginRegistry.addActivePlugin | ( | self, | |
str | plugin_id | ||
) |
Add a plugin to the list of active plugins.
plugin_id | string The id of the plugin to add. |
UM.PluginRegistry.PluginRegistry.addPluginLocation | ( | self, | |
str | location | ||
) |
Add a plugin location to the list of locations to search.
location | string The location to add to the list |
UM.PluginRegistry.PluginRegistry.addType | ( | cls, | |
str | plugin_type, | ||
Callable[[Any], None] | register_function | ||
) |
Add a new plugin type.
This function is used to add new plugin types. Plugin types are simple string identifiers that match a certain plugin to a registration function.
The callable register_function
is responsible for handling the object. Usually it will add the object to a list of objects in the relevant class. For example, the plugin type 'tool' has Controller::addTool as register function.
register_function
will be called every time a plugin of type
is loaded.
type | string The name of the plugin type to add. |
register_function | callable A callable that takes an object as parameter. |
bool UM.PluginRegistry.PluginRegistry.checkRequiredPlugins | ( | self, | |
List[str] | required_plugins | ||
) |
Check if all required plugins are loaded.
required_plugins | list List of ids of plugins that ''must'' be activated. |
List UM.PluginRegistry.PluginRegistry.getAllMetaData | ( | self, | |
** | kwargs | ||
) |
Get a list of all metadata matching a certain subset of metadata.
kwargs | Keyword arguments. Possible keywords:
|
"PluginRegistry" UM.PluginRegistry.PluginRegistry.getInstance | ( | cls | ) |
Get the singleton instance of this class.
Dict UM.PluginRegistry.PluginRegistry.getMetaData | ( | self, | |
str | plugin_id | ||
) |
Get the metadata for a certain plugin.
plugin_id | string The ID of the plugin |
InvalidMetaDataError | Raised when no metadata can be found or the metadata misses the right keys. |
List UM.PluginRegistry.PluginRegistry.getPluginLocations | ( | self | ) |
Get the list of plugin locations.
PluginObject UM.PluginRegistry.PluginRegistry.getPluginObject | ( | self, | |
str | plugin_id | ||
) |
Get a plugin object.
plugin_id | string The ID of the plugin object to get. |
Optional[str] UM.PluginRegistry.PluginRegistry.getPluginPath | ( | self, | |
str | plugin_id | ||
) |
Get the path to a plugin.
plugin_id | string The ID of the plugin. |
bool UM.PluginRegistry.PluginRegistry.isActivePlugin | ( | self, | |
str | plugin_id | ||
) |
Ask whether plugin_name is an active plugin.
plugin_id | string The id of the plugin which might be active or not. |
UM.PluginRegistry.PluginRegistry.loadPlugin | ( | self, | |
str | plugin_id | ||
) |
Load a single plugin by id.
plugin_id | string The ID of the plugin, i.e. its directory name. |
PluginNotFoundError | Raised when the plugin could not be found. |
UM.PluginRegistry.PluginRegistry.loadPlugins | ( | self, | |
Optional[dict] | meta_data = None |
||
) |
Load all plugins matching a certain set of metadata.
meta_data | dict The meta data that needs to be matched. |
UM.PluginRegistry.PluginRegistry.removeActivePlugin | ( | self, | |
str | plugin_id | ||
) |
Remove plugin from the list of active plugins.
plugin_id | string The id of the plugin to remove. |
UM.PluginRegistry.PluginRegistry.removeType | ( | cls, | |
str | plugin_type | ||
) |
Remove a plugin type.
type | string The plugin type to remove. |
UM.PluginRegistry.PluginRegistry.setApplication | ( | self, | |
app | |||
) |
Set the central application object This is used by plugins as a central access point for other objects.
app | Application The application object to use |