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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pluggen-1.0.0b3.tar.gz.
File metadata
- Download URL: pluggen-1.0.0b3.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2422d515758631e79e2f154581168ec065d67e8ae4d16c6cd989c0a974d87ed7
|
|
| MD5 |
8b077d3b3576e6d15678a6199fd53419
|
|
| BLAKE2b-256 |
9b0af8c1c17249efe41f74898017d3bb254bd1590dea79e850eac2fafb11f4da
|
File details
Details for the file pluggen-1.0.0b3-py3-none-any.whl.
File metadata
- Download URL: pluggen-1.0.0b3-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6af5cc37abb195a0735976b107dfe916b984a71d83831d75bce74c6a1e444f6
|
|
| MD5 |
c37e0ae0d89b1df1e718394c759ecf15
|
|
| BLAKE2b-256 |
df10d60af90e77b7572388d88ba884ccc72734d3495bb5a3ed82b7c01490c148
|