Library to manage plugins/extensions in your applications.
Pluginloader is a library to allow an easy way to load plugins. They can be managed by interfaces or just method validators.
Two options: to install it in your system/project:
pip install pluginloader
You can load all plugins in a file, just doing:
loader = PluginLoader() plugins = loader.load_file('plugins.py')
With those simple lines you will have in the variable
plugins a dictionary with each class inside the plugins.py file as key and a factory as value.
Let’s see an example. Using the plugins.py file:
class Foo(object): pass
We can have an object of that class just with:
loader = PluginLoader() plugins = loader.load_file('plugins.py') instance1 = plugins['Foo']() instance2 = plugins['Foo']()
Simple and easy.
This is a simple module with a simple API. It just contains one class,
PluginLoader, with these public methods:
load_file(filename, onlyif=None, context=None)
Loads all plugins in a file.
load_directory(path, onlyif=None, recursive=False))
Loads all plugins in a directory.
Links will always be ignored.