Skip to main content

A module for plugin discovery and instantiation

Project description

Pluggen

A simple plugin system for python modules, allowing you to register plugins using class decorators. This project used to be called pyplug, but someone else obviously beat me to the name.

This project came about as a part of my toy mDNS library that needed a handy way of registering DNS record types.

Usage

Create a plugin collection by extending pluggen.Plugin:

from pluggen import Plugin

class TestCollection(Plugin):
	paths = [ 'path.to.my.plugins' ]

Then in path.to.my.plugins, create modules for your plugins and decorate them with @TestCollection.register or the more verbose @TestCollection.register(name="alt_name", ...).

Additional parameters can be set in the register method to store metadata about this particular plugin. The special parameter name can be used to give the plugin a particular name, if none is provided the class name will be used.

The name should be unique, duplicate names will be ignored.

By default the instance(name, config) method can then be used to instantiate a plugin based on its name, but you are of course free to override it and/or add any custom lookup method you wish to use.

See pydoc pluggen.Plugin for more information (or read the source, it's small)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pluggen-1.0.0b3.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

pluggen-1.0.0b3-py3-none-any.whl (3.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page