Package yapsy :: Module PluginManager :: Class PluginManager
[hide private]

Class PluginManager

source code

object --+
         |
        PluginManager

Manage several plugins by ordering them in several categories.

The mechanism for searching and loading the plugins is already implemented in this class so that it can be used directly (hence it can be considered as a bit more than a mere interface)

The file describing a plugin should be written in the sytax compatible with Python's ConfigParser module as in the following example:

[Core Information]
Name= My plugin Name
Module=the_name_of_the_pluginto_load_with_no_py_ending

[Documentation]
Description=What my plugin broadly does
Author= My very own name
Website= My very own website
Version=the_version_number_of_the_plugin


Instance Methods [hide private]
 
__init__(self, categories_filter={'Default': <class 'yapsy.IPlugin.IPlugin'>}, directories_list=None, plugin_info_ext='yapsy-plugin')
Initialize the mapping of the categories and set the list of directories where plugins may be.
source code
 
setCategoriesFilter(self, categories_filter)
Set the categories of plugins to be looked for as well as the way to recognise them.
source code
 
setPluginInfoClass(self, picls)
Set the class that holds PluginInfo.
source code
 
getPluginInfoClass(self)
Get the class that holds PluginInfo.
source code
 
setPluginPlaces(self, directories_list)
Set the list of directories where to look for plugin places.
source code
 
setPluginInfoExtension(self, plugin_info_ext)
Set the extension that identifies a plugin info file.
source code
 
getCategories(self)
Return the list of all categories.
source code
 
getPluginsOfCategory(self, category_name)
Return the list of all plugins belonging to a category.
source code
 
_gatherCorePluginInfo(self, directory, filename)
Gather the core information (name, and module to be loaded) about a plugin described by it's info file (found at 'directory/filename').
source code
 
gatherBasicPluginInfo(self, directory, filename)
Gather some basic documentation about the plugin described by it's info file (found at 'directory/filename').
source code
 
locatePlugins(self)
Walk through the plugins' places and look for plugins.
source code
 
loadPlugins(self, callback=None)
Load the candidate plugins that have been identified through a previous call to locatePlugins.
source code
 
collectPlugins(self)
Walk through the plugins' places and look for plugins.
source code
 
getPluginByName(self, name, category='Default')
Get the plugin correspoding to a given category and name
source code
 
activatePluginByName(self, name, category='Default')
Activate a plugin corresponding to a given category + name.
source code
 
deactivatePluginByName(self, name, category='Default')
Desactivate a plugin corresponding to a given category + name.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, categories_filter={'Default': <class 'yapsy.IPlugin.IPlugin'>}, directories_list=None, plugin_info_ext='yapsy-plugin')
(Constructor)

source code 

Initialize the mapping of the categories and set the list of directories where plugins may be. This can also be set by direct call the methods:

  • setCategoriesFilter for categories_filter
  • setPluginPlaces for directories_list
  • setPluginInfoExtension for plugin_info_ext

You may look at these function's documentation for the meaning of each corresponding arguments.

Overrides: object.__init__

setCategoriesFilter(self, categories_filter)

source code 

Set the categories of plugins to be looked for as well as the way to recognise them.

The categories_filter first defines the various categories in which the plugins will be stored via its keys and it also defines the interface tha has to be inherited by the actual plugin class belonging to each category.

setPluginInfoClass(self, picls)

source code 
Set the class that holds PluginInfo. The class should inherit from PluginInfo.

getPluginInfoClass(self)

source code 
Get the class that holds PluginInfo. The class should inherit from PluginInfo.

setPluginInfoExtension(self, plugin_info_ext)

source code 

Set the extension that identifies a plugin info file.

The plugin_info_ext is the extension that will have the informative files describing the plugins and that are used to actually detect the presence of a plugin (see collectPlugins).

_gatherCorePluginInfo(self, directory, filename)

source code 

Gather the core information (name, and module to be loaded) about a plugin described by it's info file (found at 'directory/filename').

Return an instance of self.plugin_info_cls and the config_parser used to gather the core data in a tuple, if the required info could be localised, else return (None,None).

Note

This is supposed to be used internally by subclasses and decorators.

gatherBasicPluginInfo(self, directory, filename)

source code 

Gather some basic documentation about the plugin described by it's info file (found at 'directory/filename').

Return an instance of self.plugin_info_cls gathering the required informations.

See also:

self._gatherCorePluginInfo

locatePlugins(self)

source code 

Walk through the plugins' places and look for plugins.

Return the number of plugins found.

loadPlugins(self, callback=None)

source code 

Load the candidate plugins that have been identified through a previous call to locatePlugins. For each plugin candidate look for its category, load it and store it in the appropriate slot of the category_mapping.

If a callback function is specified, call it before every load attempt. The plugin_info instance is passed as an argument to the callback.

collectPlugins(self)

source code 
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 category_mapping.