Skip to main content

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

  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.0.tar.gz (3.8 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.0-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

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

Hashes for simple-plugin-loader-1.0.tar.gz
Algorithm Hash digest
SHA256 8f1ea9a6fa23f0e7b22f6d09ccb82e4706b664836ea706c3ea056e6b706157a9
MD5 1034fec5be74486bb9dff4d2b6d7d9ee
BLAKE2b-256 e211a8cb762591ac93d971632f0ee2f1cb292e176ffee2bfe80e7ff7ae5f53d8

See more details on using hashes here.

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

Hashes for simple_plugin_loader-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 add43da0abbda4da34e64e47da4f716886d1f6dcae8cbdecb978ce468c688a77
MD5 a87e0d0460bbf82c6bfce95db4b1b1a3
BLAKE2b-256 60047730d1dc1978fef3cd8cde2d1cdf808fb65649945a3e14bce6ddbc4ccce5

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