Simple Python Plugin Loader
This module provides a simple way to dynamically load other Python modules as Plugins to your current project.
Install
You can install this python module via pip:
pip install simple-plugin-loader
Otherwise the module can be downloaded from PyPI: https://pypi.org/project/simple-plugin-loader/
Usage
- Import the module:
from simple_plugin_loader import Loader
- Load your plugins/modules:
# initialize the loader loader = Loader() # load your plugins plugins = loader.load_plugins(<plugin_path>, <plugin_base_class>, <specific_plugins>, <recursive>)
- (Optional) The already loaded plugins/modules can be accessed via the
pluginsproperty of the loader instance:plugins = loader.plugins
load_plugins(...) Method
This method does the actual plugin loading.
It loads only Python modules that can be executed in the current environment. For every successfully loaded module a message is populated through the Python logging library (log level: INFO).
If a module e.g. contains syntax errors or depends on other not installed Python modules, it will be skipped. So the main program does not fail completely. An error message is populated through the Python logging library (log level: ERROR).
Arguments
<plugin_path>: str
This string represents the path (relative or absolute) to the directory from where the plugins/modules should be loaded.<plugin_base_class>: class (Default:SamplePlugin)
The Loader does not load all found modules that are in the above directory. It only loads classes that are sub-classes of the here specified class.
The default value of this argument is theSamplePluginclass. You can use this class as the base class for your plugins:from simple_plugin_loader.sample_plugin import SamplePlugin class YourPlugin(SamplePlugin): pass
<specific_plugins>: List[str] (Default:[])
This list can contain case sensitive class names, that should be loaded. Then no other plugins will be loaded. The argument<plugin_base_class>will also be ignored, so any class can be loaded.<recursive>: bool (Default:False)
Set this flag toTrueif you wish to load plugins/modules recursively to the above directory.
Return value
The method returns a dictionary that has the following structure:
- Key: The name of the plugin/module. This name is the module name of the module that contains the plugin class.
- Value: The plugin class. Not an instance!
Metadata
Release files for simple-plugin-loader 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| simple_plugin_loader-3.0.0.tar.gz | 17.1 kB | Without provenance | Details for simple_plugin_loader-3.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simple_plugin_loader-3.0.0-py3-none-any.whl | Python 3 | none | any | Details for simple_plugin_loader-3.0.0-py3-none-any.whl |
Total release size: 35.5 kB
Release files / simple_plugin_loader-3.0.0.tar.gz
| Download URL | simple_plugin_loader-3.0.0.tar.gz |
|---|---|
| Size | 17.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
effbdd6320cda1914ab10eca7fb10c2a458db20be704b26ed0be1c0c6d2042dd
|
|
BLAKE2b-256 checksum How to use checksums |
f8df9f0fc0b6e5901f15194fb948b6cd98d2f7bd6c5eedf316e350d38ba06358
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.7.17 Linux/6.2.0-1012-azure
|
Release files / simple_plugin_loader-3.0.0-py3-none-any.whl
| Download URL | simple_plugin_loader-3.0.0-py3-none-any.whl |
|---|---|
| Size | 18.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9cb94e6c0fe4c2862796f5abd43296c3b1978b7a42c01b65b3ab22f79a9a72df
|
|
BLAKE2b-256 checksum How to use checksums |
1b0620c63aac1bddd53cd260b6cf09cef33a127d116c40481e65409dc68052bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.7.17 Linux/6.2.0-1012-azure
|
Security for simple-plugin-loader 3.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.