Registry / workflow / yapsy
library1.12.2pypypi✓ verified 67d ago

Yapsy is a simple, reusable plugin system for Python applications. It provides a base class for plugins and a plugin manager that discovers and loads plugins from directories. The latest version is 1.12.2, with sporadic releases.

pip install yapsy
INSTALL
IMPORT
SIG · YAPSY
Y
yapsy
workflowpythonv1.12.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

IPlugin
from yapsy.IPlugin import IPlugin
from yapsy import IPlugin
IPlugin is in the yapsy.IPlugin submodule, not top-level.
PluginManagerSingleton
from yapsy.PluginManager import PluginManagerSingleton
from yapsy import PluginManagerSingleton
Common mistake: PluginManagerSingleton is inside PluginManager module.

Defines a plugin class, uses the singleton plugin manager to discover and activate plugins from a 'plugins' directory.

from yapsy.IPlugin import IPlugin from yapsy.PluginManager import PluginManagerSingleton class MyPlugin(IPlugin): def activate(self): print("Plugin activated") def deactivate(self): print("Plugin deactivated") if __name__ == "__main__": pm = PluginManagerSingleton.get() pm.setPluginPlaces(["plugins"]) pm.collectPlugins() pm.activatePluginByName("MyPlugin") pm.deactivatePluginByName("MyPlugin")
Debug
Known issues
gotchaPlugin constructor (__init__) is called before plugin info (name, version, etc.) is set. Do not rely on plugin metadata in __init__; use activate() instead.
fix
Override activate() instead of __init__ to access plugin manager or metadata.
affects: all
deprecatedThe use of PluginManager without arguments is deprecated in favor of PluginManagerSingleton or custom locations.
fix
Use PluginManagerSingleton.get() or pass plugin_places explicitly.
affects: <1.12
Errors
Common errors & fixes
yapsy.IPlugin.IPlugin is not instantiated correctly
Trying to instantiate IPlugin base class directly or forgetting to inherit.
fix
Ensure your plugin class inherits from yapsy.IPlugin.IPlugin and implements activate()/deactivate().
AttributeError: 'NoneType' object has no attribute 'getPluginByName'
PluginManagerSingleton.get() returned None because plugins were not collected yet.
fix
Call pm.collectPlugins() before trying to get a plugin by name.
Upgrade
Version history
1.12.2latest on PyPI · released Jul 27, 2019
Audit
Dependencies

No dependency data recorded yet.

Agent activity
41 hits · last 30 days
node
36
Amazon
1
Resources
yapsy — pip install yapsy · libregistry