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 import Loader
    
  2. Load your plugins/modules:
    # initialize the loader
    loader = Loader()
    
    # load your plugins
    plugins = 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.3.tar.gz (4.2 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.3-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for simple-plugin-loader-1.3.tar.gz
Algorithm Hash digest
SHA256 96678d9d69d67c70be14d8f21a4afab3136572e0f4db4b9f422332387983c10a
MD5 be25da499d7993a628d1a6e1ee6efc21
BLAKE2b-256 3957ccc121296d1cce98408b5817a254176303da351d4a9af0cfb616c466bd15

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for simple_plugin_loader-1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2f994c085eea97f34fc4928bfddd619cb35f04f1e09fa36b939d9bbd8569b42e
MD5 13a9cada71e9b12f4038877b603bf2a9
BLAKE2b-256 31cdb1fc94cade39fa52114edcdc1a35593fd6d327bc21e24bb19771542fdbfd

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