Skip to main content

Dynamically load other python modules to your project

Project description

Simple Python Plugin Loader

PyPI package PyPI version

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

  1. Import the module:
    from plugin_loader.loader import Loader
    
  2. Load your plugins/modules:
    # initialize the loader
    loader = Loader()
    
    # load your plugins
    plugins = self.loader.load_plugins(<plugin_path>, <plugin_base_class, <recursive>)
    
  3. (Optional) The already loaded plugins/modules can be accessed via the plugins property 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 the SamplePlugin class. 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 to True if 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


Download files

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

Source Distribution

simple-plugin-loader-1.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simple_plugin_loader-1.1-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file simple-plugin-loader-1.1.tar.gz.

File metadata

  • Download URL: simple-plugin-loader-1.1.tar.gz
  • Upload date:
  • Size: 4.1 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.1.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.5.9

File hashes

Hashes for simple-plugin-loader-1.1.tar.gz
Algorithm Hash digest
SHA256 7d18be9b400a4ed498d5bf728f32cdcb9d4cba7f01a06d6fedf7efeb445333d2
MD5 879fb41b17a9041a7a65435297bb2415
BLAKE2b-256 9fb1f0add8bf6b735b542d1bebce2c9bc4a314c34d5b7da005a72774cb200d48

See more details on using hashes here.

File details

Details for the file simple_plugin_loader-1.1-py3-none-any.whl.

File metadata

  • Download URL: simple_plugin_loader-1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.8 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.1.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.5.9

File hashes

Hashes for simple_plugin_loader-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 34a5ec151b83da79fe97b20c8b802355ab3c06f57dd96a0e7de373fe81045d89
MD5 f02e940c67081bcbf35427dbb6642771
BLAKE2b-256 75ab77448b3226b4fd4e8f10df1e3e41b1542a04ba8625c96b8306747729f0ca

See more details on using hashes here.

Supported by

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