Plugable: A Python Plugin Framework
Badges:
This package exposes a framework for writing extensible applications.
Specifically, it allows consumers to mark an abstract class as "Plugable", using standard inheritance semantics and ABC decorators:
from abc import abstractmethod
from plugable import Plugable
class AbstractInterface(Plugable):
@abstractmethod
def example(self):
pass
Following this, you can create subclasses for differing implementations, and register them with the AbstractInterface registry, like so:
class ExampleOne(AbstractInterface, register="one"): # Integrated registration
def example(self):
print("You ran ExampleOne!")
class ExampleTwo(AbstractInterface):
def example(self):
print("You ran ExampleTwo!")
AbstractInterface.registry.register("two", ExampleTwo) # Explicit registration
Finally, you can access and consume the registered implementations, like so:
AbstractInterface.get("one").example() # You ran ExampleOne!
AbstractInterface.get("two").example() # You ran ExampleTwo!
Metadata
Release files for plugable 1.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| plugable-1.2.2.tar.gz | 3.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| plugable-1.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.0 kB
Release files / plugable-1.2.2.tar.gz
| Download URL | plugable-1.2.2.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bc0782c11255f206f606595c3065a397571e5dc91b08b2b0126ed462ef3b8cc4
|
|
BLAKE2b-256 checksum How to use checksums |
f811b89c680a1e19640f36fc70497418b4312c7f74a7aeb1a39ddfa7343c0118
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / plugable-1.2.2-py3-none-any.whl
| Download URL | plugable-1.2.2-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
97412801790acfdedf936e4255d9a467095d2cb708ff701ba37b14a751117abd
|
|
BLAKE2b-256 checksum How to use checksums |
087e3d016cf756cfebc371138bd7f25bcf5719211ccb5532d7636cd9293e873c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|