Home | Trees | Indices | Help |
|
---|
|
Yapsy's main purpose is to offer a way to easily design a plugin system in Python, and motivated by the fact that many other Python plugin system are either too complicated for a basic use or depend on a lot of libraries. Yapsy only depends on Python's standard library.
Yapsy basically defines two core classes:
The PluginManager will load plugins that enforce the Plugin Description Policy, and offers the most simple methods to activate and deactivate the loaded plugins.
It may also classify the plugins in various categories, but this behaviour is optional and if not specified elseway all plugins are stored in the same default category.
The provided classes have been designed in order to be as easy as possible to extend.
When using Yapsy in your own software, you'll probably want to build derived classes of the IPlugin class as it is a mere interface with no specific functionality.
Your software's plugins should then inherit your very own plugin class (itself derived from IPlugin).
Where and how to code these plugins is explained in the section about Plugin Description Policy .
When creating a PluginManager instance, one should provide it with a list of directories where plugins may be found. In each directory, a plugin should contain the following elements:
myplugin.yapsy-plugin
A plugin info file identical to the one previously described.myplugin
A directory ontaining an actual Python plugin (ie with a __init__.py file that makes it importable). The upper namespace of the plugin should present a class inheriting the IPlugin interface (the same remarks apply here as in the previous case).
myplugin.yapsy-plugin
A plugin info file which is identified thanks to its extension, see the Plugin Info File Format to see what should be in this file.
The extension is customisable at the PluginManager's instanciation, since one may usually prefer the extension to bear the application name rather than Yapsy's.
myplugin.py
The source of the plugin. This file should at least define a class inheriting the IPlugin interface. This class will be instanciated at plugin loading and it will be notified the activation/deactivation events.
The plugin info file gathers, as its name suggests, some basic information about the plugin. On one hand it gives crucial information needed to be able to load the plugin. On the other hand it provided some documentation like information like the plugin author's name and a short description fo the plugin functionality.
Here is an example of what such a file should contain:
[Core] Name = Simple Plugin Module = SimplePlugin [Documentation] Author = Thibauld Version = 0.1 Website = http://yapsy.sourceforge.net Description = A simple plugin usefull for basic testing
The classes defined by Yapsy have been build with the minimum number of functionalities needed for them to achieve their purpose. This has been done in order to make it as easy as possible to extend this class and adapt them to any specific need.
However, some basic extension have been implemented. Each extension (by inheritance) of the PluginManager intends to add only one functionality as in the following instance:
PluginManagerSingleton
Adds the behaviour of a singleton to the PluginManager class.
ConfigurablePluginManager
Implements a PluginManager that is able to use a configuration file through an interface compatible with the standard ConfigParser module.
VersionedPluginManager
Able to manage several versions of a same plugin.
AutoInstallPluginManager
Automatically copy the plugin files to the right plugin directory.
See PluginManagerDecorator 's subclasses for more.
Yapsy 's development has been motivated by the MathBench project but it is now used in other (more advanced) projects like peppy.
Its development is hosted on Sourceforge.
The work is placed under the simplified BSD license in order to make it as easy as possible to be reused in other projects. Please note that the icon is not under the same license but under the Creative Common Attribution-ShareAlike license.
Any suggestion and help are much welcome !
Other Python plugin systems already existed before Yapsy. Yapsy's creation is by no mean a sign that these others plugin systems sucks :) It is just the results of me being slighlty lazy and as I had already a good idea of how a simple plugin system should look like, I wanted to implement my own [1].
[1] | All the more because it seems that my modest design ideas slightly differ from what has been done in other libraries. |
Project hosted by SourceForge
|
|||
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Wed Apr 9 12:17:52 2008 | http://epydoc.sourceforge.net |