Skip to main content

Python Plugin Management, simplified

Project description

Build Status Coverage Status Code Climate

python plugin management, simplified.

Library under development and contains rough edges/unfinished functionality. While not anticipated, API may be subject to changes.

Quickstart

from pluginmanager import PluginInterface

plugin_interface = PluginInterface()
plugin_interface.set_plugin_directories('my/fancy/plugin/path')
plugin_interface.collect_plugins()

plugins = plugin_interface.get_instances()

Installation

pip install pluginmanager

-or-

pip install git+https://github.com/benhoff/pluginmanager.git

Custom Plugins

The quickstart will only work if you subclass IPlugin for your custom plugins (or register your custom class with IPlugin, or use the ‘get_plugins’ method on PluginInterface.)

import pluginmanager
class MyCustomPlugin(pluginmanager.IPlugin):
    pass

IPlugin comes with three instance variables: active: bool, configuration: dict, name: str

and one class variable: CONFIGURATION_TEMPLATE: dict

At the very least, you should give your custom implementations a ‘name’. If a name is not given and the parent class initializer is called, a name will be written to the instance if the attribute doesn’t exist. FYI.

IPlugin has 5 methods: activate, deactivate, get_configuration_template, check_configuration, and configure

Reimplement (or not) as needed.

If the default implementation of IPlugin doesn’t fit your needs, register your class as subclass of IPlugin.

IPlugin.register(YourClassHere)

Architecture

pluginmanager was designed to be as extensible as possible while also being easy to use. There are three layers of access.

Interfaces:

public facing

Managers:

extended or replaced

Filters:

implementation specific

Interfaces

Interfaces were used to provide a simple programmer interface while maintaining the ability to separate out the concerns of the implementation. The main interface is the PluginInterface, which is designed to be as stateless as possible, and have interjectable options, where applicable.

PluginInterface provides the cability to instantiate two other interfaces, the BlacklistInterface and FilterInterface. These interfaces provide universal access to the blacklisting (selectively implemented) and filtering APIs respectively.

Managers

There are four managers which make up the core of the library.

DirectoryManager:

Maintains directory state. Responsbile for recursively searching through directories

FileManager:

Can maintain filepath state. Does maintain file filter state. Responsible for applying file filters to filepaths passed gotten from directories

ModuleManager:

Loads modules from source code. Keeps track of loaded modules. Maintains module filter state. Responsible for applying module filters to modules to get out plugins.

PluginManager:

Instantiates plugins. Maintains plugin state.

Filters

Filters are designed to offer implementation-level extensiblity. Want to only return only files start with “plugin”? Create a filter for it. Or use some of the provided filters to provide the desired implementation.

NOTE: Final implementation of filters and how they interact with the library is currently a WIP and should be considered unstable.

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

pluginmanager-0.1.1.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

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

pluginmanager-0.1.1-py3-none-any.whl (69.7 kB view details)

Uploaded Python 3

File details

Details for the file pluginmanager-0.1.1.tar.gz.

File metadata

  • Download URL: pluginmanager-0.1.1.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pluginmanager-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fc2f0b50817567f3b3be5a8dcf8ee7d427593100afd5b8b104f87d8cc92a2379
MD5 b79cd8c34260def9c771afb150844a77
BLAKE2b-256 6ef942c6d131a997282641d290ab67c6be5890c80f1619e2d7a216191ab74041

See more details on using hashes here.

File details

Details for the file pluginmanager-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pluginmanager-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f4b8c81872a9624efb0061dd60ab2c13a7b2fff3412f0a4a212db0f02605346a
MD5 d139cb2daf3073bc862a4781204f9e38
BLAKE2b-256 ed4dbd984a0c74437e5f2254cccab9a22d581640f6dcd3c3e22e9470800bc483

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