Dynamically load other python modules to your project
Project description
Simple Python Plugin Loader
This module provides a simple way to dynamically load other Python modules as Plugins to your current project.
Usage
- Import the module:
from plugin_loader.loader import Loader
- Load your plugins/modules:
# initialize the loader loader = Loader() # load your plugins plugins = self.loader.load_plugins(<plugin_path>, <plugin_base_class, <recursive>)
- (Optional) The already loaded plugins/modules can be accessed via the
pluginsproperty of the loader instance:plugins = loader.plugins
load_plugins(...) Method
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 plugin_loader.sample_plugin import SamplePlugin class YourPlugin(SamplePlugin): pass
<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!
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 simple-plugin-loader-1.0.tar.gz.
File metadata
- Download URL: simple-plugin-loader-1.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.5.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f1ea9a6fa23f0e7b22f6d09ccb82e4706b664836ea706c3ea056e6b706157a9
|
|
| MD5 |
1034fec5be74486bb9dff4d2b6d7d9ee
|
|
| BLAKE2b-256 |
e211a8cb762591ac93d971632f0ee2f1cb292e176ffee2bfe80e7ff7ae5f53d8
|
File details
Details for the file simple_plugin_loader-1.0-py3-none-any.whl.
File metadata
- Download URL: simple_plugin_loader-1.0-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.5.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
add43da0abbda4da34e64e47da4f716886d1f6dcae8cbdecb978ce468c688a77
|
|
| MD5 |
a87e0d0460bbf82c6bfce95db4b1b1a3
|
|
| BLAKE2b-256 |
60047730d1dc1978fef3cd8cde2d1cdf808fb65649945a3e14bce6ddbc4ccce5
|