Defines plugin managers that can handle configuration files similar to the ini files manipulated by Python’s ConfigParser module.
ConfigurablePluginManager(configparser_instance=None, config_change_trigger=<function <lambda>>, decorated_manager=None, categories_filter=None, directories_list=None, plugin_info_ext='yapsy-plugin')¶
A plugin manager that also manages a configuration file.
The configuration file will be accessed through a
ConfigParserderivated object. The file can be used for other purpose by the application using this plugin manager as it will only add a new specific section
[Plugin Management]for itself and also new sections for some plugins that will start with
[Plugin:...](only the plugins that explicitly requires to save configuration options will have this kind of section).
when giving/building the list of plugins to activate by default, there must not be any space in the list (neither in the names nor in between)
config_change_triggerargument can be used to set a specific method to call when the configuration is altered. This will let the client application manage the way they want the configuration to be updated (e.g. write on file at each change or at precise time intervalls or whatever….)
config_change_triggeris given and if the provided
configparser_instancedoesn’t handle it implicitely, recording the changes persistently (ie writing on the config file) won’t happen.
CONFIG_SECTION_NAME= 'Plugin Management'¶
activatePluginByName(plugin_name, category_name='Default', save_state=True)¶
Activate a plugin, , and remember it (in the config file).
If you want the plugin to benefit from the configuration utility defined by this manager, it is crucial to use this method to activate a plugin and not call the plugin object’s
activatemethod. In fact, this method will also “decorate” the plugin object so that it can use this class’s methods to register its own options.
By default, the plugin’s activation is registered in the config file but if you d’ont want this set the ‘save_state’ argument to False.
deactivatePluginByName(plugin_name, category_name='Default', save_state=True)¶
Deactivate a plugin, and remember it (in the config file).
By default, the plugin’s deactivation is registered in the config file but if you d’ont want this set the
save_stateargument to False.
hasOptionFromPlugin(category_name, plugin_name, option_name)¶
To be called from a plugin object, return True if the option has already been registered.
Walk through the plugins’ places and look for plugins. Then for each plugin candidate look for its category, load it and stores it in the appropriate slot of the
readOptionFromPlugin(category_name, plugin_name, option_name)¶
To be called from a plugin object, read a given option in the name of a given plugin.
registerOptionFromPlugin(category_name, plugin_name, option_name, option_value)¶
To be called from a plugin object, register a given option in the name of a given plugin.
Set the ConfigParser instance.