Reimplemented PluginManager class to enable plugins' access to the main window.
More...
|
def | __init__ (self, mainwindow, categories_filter=None, directories_list=None, plugin_info_ext=None, plugin_locator=None) |
| Adds 'mainwindow' to the PluginManager default constructor. More...
|
|
def | instanciateElementWithImportInfo (self, element, element_name, plugin_module_name, candidate_filepath) |
| Reimplemented method that creates plugin objects passing 'self' in constructor. More...
|
|
def | call_plugin_method (self, plugin_name, plugin_category, method_name, *args, **kwargs) |
| Calls a given method from a given plugin by its name. More...
|
|
def | plugin_from_settings (self, settings, plugin_name, plugin_category) |
| Returns the plugin object corresponding to a plugin info record in the global settings. More...
|
|
def | set_plugin_active (self, plugin_name, plugin_category, active=True) |
| Sets a plugin's active state to True or False. More...
|
|
def | update_global_settings (self, forced_update=False) |
| Updates the custom plugin settings in guisettings::CWSettings::settings. More...
|
|
def | get_plugins_of_category (self, category, active_only=True) |
| Gets the list of plugins for a given category respecting their order. More...
|
|
def | get_plugin_methods (self, category, method_name) |
| Returns the list of methods with a given name from all active plugins. More...
|
|
def | configure_plugins (self) |
| Activates or deactivates loaded plugins according to the global settings. More...
|
|
Reimplemented PluginManager class to enable plugins' access to the main window.
◆ __init__()
def pycross.utils.pluginmanager.PxPluginManager.__init__ |
( |
|
self, |
|
|
|
mainwindow, |
|
|
|
categories_filter = None , |
|
|
|
directories_list = None , |
|
|
|
plugin_info_ext = None , |
|
|
|
plugin_locator = None |
|
) |
| |
Adds 'mainwindow' to the PluginManager default constructor.
- Parameters
-
mainwindow | pycross.gui.MainWindow pointer to the app main window |
categories_filter | dict categories of plugins to be looked for as well as the way to recognise them |
directories_list | iterable list of search directories for plugins (relative or absolute paths) |
plugin_info_ext | str extension of plugin info files (without dot) |
plugin_locator | yapsy::IPluginLocator::IPluginLocator plugin locator instance |
◆ _plugin_info_to_dic()
def pycross.utils.pluginmanager.PxPluginManager._plugin_info_to_dic |
( |
|
self, |
|
|
|
plugin |
|
) |
| |
|
private |
Makes a dictionary of plugin info given a plugin object.
The resulting dict is formatted in the same way as in the global settings, corresponding to a custom plugin record in a given category.
- Parameters
-
plugin | yapsy::PluginInfo::PluginInfo the plugin object |
- Returns
dict
plugin info record
◆ call_plugin_method()
def pycross.utils.pluginmanager.PxPluginManager.call_plugin_method |
( |
|
self, |
|
|
|
plugin_name, |
|
|
|
plugin_category, |
|
|
|
method_name, |
|
|
* |
args, |
|
|
** |
kwargs |
|
) |
| |
Calls a given method from a given plugin by its name.
- Parameters
-
plugin_name | str name of plugin |
plugin_category | str name of plugin category |
method_name | str name of method to call |
*args | positional args positional args passed to the method |
*kwargs | keyword args keyword args passed to the method |
- Returns
- whatever the called method returns
- Exceptions
-
<tt>Exception</tt> | failure to locate plugin or plugin inactive or failure to locate method |
◆ configure_plugins()
def pycross.utils.pluginmanager.PxPluginManager.configure_plugins |
( |
|
self | ) |
|
Activates or deactivates loaded plugins according to the global settings.
◆ get_plugin_methods()
def pycross.utils.pluginmanager.PxPluginManager.get_plugin_methods |
( |
|
self, |
|
|
|
category, |
|
|
|
method_name |
|
) |
| |
Returns the list of methods with a given name from all active plugins.
The methods are returned from all active plugins in a given category, while respecting the plugin order in the global settings. That is, the resulting list of methods will be ordered by the plugin order in the settings.
- Parameters
-
category | str plugin category name |
method_name | str method name to look for |
- Returns
list
list of methods, each being a callable bound object
◆ get_plugins_of_category()
def pycross.utils.pluginmanager.PxPluginManager.get_plugins_of_category |
( |
|
self, |
|
|
|
category, |
|
|
|
active_only = True |
|
) |
| |
Gets the list of plugins for a given category respecting their order.
This method is added since the inherited getPluginsOfCategory
method of PluginManager
does not respect the order of the plugins (it knows nothing about the order). The plugin order is taken from the global settings (guisettings::CWSettings::settings).
- Parameters
-
category | str plugin category name |
active_only | bool only list active plugins (default) |
- Returns
list
list of plugins of type yapsy::PluginInfo::PluginInfo
◆ instanciateElementWithImportInfo()
def pycross.utils.pluginmanager.PxPluginManager.instanciateElementWithImportInfo |
( |
|
self, |
|
|
|
element, |
|
|
|
element_name, |
|
|
|
plugin_module_name, |
|
|
|
candidate_filepath |
|
) |
| |
Reimplemented method that creates plugin objects passing 'self' in constructor.
See params in yapsy docs.
◆ plugin_from_settings()
def pycross.utils.pluginmanager.PxPluginManager.plugin_from_settings |
( |
|
self, |
|
|
|
settings, |
|
|
|
plugin_name, |
|
|
|
plugin_category |
|
) |
| |
Returns the plugin object corresponding to a plugin info record in the global settings.
- Parameters
-
settings | dict pointer to global settings ['plugins']['custom'] |
plugin_name | str name of plugin |
plugin_category | str name of plugin category |
- Returns
yapsy::PluginInfo::PluginInfo
plugin object or None
on failure
◆ set_plugin_active()
def pycross.utils.pluginmanager.PxPluginManager.set_plugin_active |
( |
|
self, |
|
|
|
plugin_name, |
|
|
|
plugin_category, |
|
|
|
active = True |
|
) |
| |
Sets a plugin's active state to True or False.
- Parameters
-
plugin_name | str name of plugin |
plugin_category | str name of plugin category |
active | bool active state to set |
◆ update_global_settings()
def pycross.utils.pluginmanager.PxPluginManager.update_global_settings |
( |
|
self, |
|
|
|
forced_update = False |
|
) |
| |
Updates the custom plugin settings in guisettings::CWSettings::settings.
The function will first look for plugins contained in the current settings and update their data from the existing plugins collected by the plugin manager. Plugins that are found in settings but not in the plugin manager will be removed from settings. Then finally plugins collected by the manager but not contained in the settings will be appended to the settings, in their respective categories.
- Parameters
-
forced_update | bool if True , all current plugin settings will be cleared and plugins will be added anew from the plugin manager (default = False ) |
◆ mainwin
pycross.utils.pluginmanager.PxPluginManager.mainwin |
PxAPI
wrapper instance for app main window self.__mainwindow = mainwindow
The documentation for this class was generated from the following file: