Can anyone provide a minimal working example using the Yapsy plugin framework?
Here's a very simple example. It has three files:
You could add more plugins to the plugins directory, and this script would loop around them all.
There's another more complicated example at http://lateral.netmanagers.com.ar/weblog/posts/BB923.html (archived).
yapsy-example.py
from yapsy.PluginManager import PluginManager
def main():
# Load the plugins from the plugin directory.
manager = PluginManager()
manager.setPluginPlaces(["plugins"])
manager.collectPlugins()
# Loop round the plugins and print their names.
for plugin in manager.getAllPlugins():
plugin.plugin_object.print_name()
if __name__ == "__main__":
main()
plugins\plugin1.py
from yapsy.IPlugin import IPlugin
class PluginOne(IPlugin):
def print_name(self):
print "This is plugin 1"
plugins\plugin1.yapsy-plugin
[Core]
Name = Plugin 1
Module = plugin1
[Documentation]
Author = John Smith
Version = 0.1
Website = http://lotsofplugins.com
Description = My first plugin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With