A central object to dynamically load modules as plugins.
More...
Inherits QObject.
|
int | APIVersion = 3 |
|
| constant |
|
| str |
|
| result |
|
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.
◆ addActivePlugin()
def UM.PluginRegistry.PluginRegistry.addActivePlugin |
( |
|
self, |
|
|
|
plugin_id |
|
) |
| |
Add a plugin to the list of active plugins.
- Parameters
-
plugin_id | string The id of the plugin to add. |
◆ addPluginLocation()
def UM.PluginRegistry.PluginRegistry.addPluginLocation |
( |
|
self, |
|
|
|
location |
|
) |
| |
Add a plugin location to the list of locations to search.
- Parameters
-
location | string The location to add to the list |
◆ addType()
def UM.PluginRegistry.PluginRegistry.addType |
( |
|
cls, |
|
|
|
plugin_type |
|
) |
| |
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.
- Parameters
-
type | string The name of the plugin type to add. |
register_function | callable A callable that takes an object as parameter. |
◆ checkRequiredPlugins()
def UM.PluginRegistry.PluginRegistry.checkRequiredPlugins |
( |
|
self, |
|
|
|
required_plugins |
|
) |
| |
Check if all required plugins are loaded.
- Parameters
-
required_plugins | list List of ids of plugins that ''must'' be activated. |
◆ getActivePlugins()
def UM.PluginRegistry.PluginRegistry.getActivePlugins |
( |
|
self, |
|
|
|
List, |
|
|
|
str |
|
) |
| |
Get the list of active plugins.
◆ getAllMetaData()
def UM.PluginRegistry.PluginRegistry.getAllMetaData |
( |
|
self, |
|
|
|
kwargs, |
|
|
|
List |
|
) |
| |
Get a list of all metadata matching a certain subset of metadata.
- Parameters
-
kwargs | Keyword arguments. Possible keywords:
- filter: dict The subset of metadata that should be matched.
- active_only: Boolean, True when only active plugin metadata should be returned.
|
- See also
- getMetaData
◆ getInstance()
def UM.PluginRegistry.PluginRegistry.getInstance |
( |
|
cls, |
|
|
|
PluginRegistry |
|
) |
| |
Get the singleton instance of this class.
- Returns
- instance PluginRegistry
◆ getMetaData()
def UM.PluginRegistry.PluginRegistry.getMetaData |
( |
|
self, |
|
|
|
plugin_id |
|
) |
| |
Get the metadata for a certain plugin.
- Parameters
-
plugin_id | string The ID of the plugin |
- Returns
- dict The metadata of the plugin. Can be an empty dict.
- Exceptions
-
InvalidMetaDataError | Raised when no metadata can be found or the metadata misses the right keys. |
◆ getPluginLocations()
def UM.PluginRegistry.PluginRegistry.getPluginLocations |
( |
|
self, |
|
|
|
List |
|
) |
| |
Get the list of plugin locations.
- Returns
- list The plugin locations
◆ getPluginObject()
def UM.PluginRegistry.PluginRegistry.getPluginObject |
( |
|
self, |
|
|
|
plugin_id |
|
) |
| |
Get a plugin object.
- Parameters
-
plugin_id | string The ID of the plugin object to get. |
◆ getPluginPath()
def UM.PluginRegistry.PluginRegistry.getPluginPath |
( |
|
self, |
|
|
|
plugin_id |
|
) |
| |
Get the path to a plugin.
- Parameters
-
plugin_id | string The ID of the plugin. |
- Returns
- string The absolute path to the plugin or an empty string if the plugin could not be found.
◆ isActivePlugin()
def UM.PluginRegistry.PluginRegistry.isActivePlugin |
( |
|
self, |
|
|
|
plugin_id |
|
) |
| |
Ask whether plugin_name is an active plugin.
- Parameters
-
plugin_id | string The id of the plugin which might be active or not. |
◆ loadPlugin()
def UM.PluginRegistry.PluginRegistry.loadPlugin |
( |
|
self, |
|
|
|
plugin_id |
|
) |
| |
Load a single plugin by id.
- Parameters
-
plugin_id | string The ID of the plugin, i.e. its directory name. |
- Exceptions
-
PluginNotFoundError | Raised when the plugin could not be found. |
◆ loadPlugins()
def UM.PluginRegistry.PluginRegistry.loadPlugins |
( |
|
self, |
|
|
|
meta_data |
|
) |
| |
Load all plugins matching a certain set of metadata.
- Parameters
-
meta_data | dict The meta data that needs to be matched. |
- See also
- loadPlugin
◆ removeActivePlugin()
def UM.PluginRegistry.PluginRegistry.removeActivePlugin |
( |
|
self, |
|
|
|
plugin_id |
|
) |
| |
Remove plugin from the list of active plugins.
- Parameters
-
plugin_id | string The id of the plugin to remove. |
◆ removeType()
def UM.PluginRegistry.PluginRegistry.removeType |
( |
|
cls, |
|
|
|
plugin_type |
|
) |
| |
Remove a plugin type.
- Parameters
-
type | string The plugin type to remove. |
◆ setApplication()
def UM.PluginRegistry.PluginRegistry.setApplication |
( |
|
self, |
|
|
|
app |
|
) |
| |
Set the central application object This is used by plugins as a central access point for other objects.
- Parameters
-
app | Application The application object to use |
The documentation for this class was generated from the following file: