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.2.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.2-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: simple-plugin-loader-1.2.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.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.5.9

File hashes

Hashes for simple-plugin-loader-1.2.tar.gz
Algorithm Hash digest
SHA256 436e7dfd70a07baf0ea20d661d1e11c4b20fc44c0fe21bc8c3f05a6bdbb56d0b
MD5 4a5c7b9963cb403e3e1ddde7d3fddb27
BLAKE2b-256 f6481f2489dd006d1ad522b266330b9ae78004f1e06655a64d9a6c243fbf88d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: simple_plugin_loader-1.2-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.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.5.9

File hashes

Hashes for simple_plugin_loader-1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 59893fdff0ad43c217793d5da771ea271cf6c491a891fdcd852c0bb7c79fed6b
MD5 dd0bd2a65df1c09ec05ed1e21f0c8238
BLAKE2b-256 0dd888495177f339cb67192cef75f350293d0a5a4f946c746681883b5b572db9

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