Skip to main content
Documentation Status Travis-CI Build Status Coverage Status
PyPI Package latest release Supported versions Supported implementations
Fedora version support EPEL version support

Overview

Pluginlib makes creating plugins for your project simple.

Step 1: Define plugin parent classes

All plugins are subclasses of parent classes. To create a parent class, use the @Parent_ decorator.

The @Parent_ decorator can take a plugin type for accessing child plugins of the parent. If a plugin type isn’t given, the class name will be used.

The @Parent_ decorator can also take a group keyword which restricts plugins to a specific plugin group. group should be specified if plugins for different projects could be accessed in an single program, such as with libraries and frameworks. For more information, see the Plugin Groups section.

Methods required in child plugins should be labeled as abstract methods. Plugins without these methods or with parameters that don’t match, will not be loaded. For more information, see the Abstract Methods section.

"""
sample.py
"""
import pluginlib

@pluginlib.Parent('parser')
class Parser(object):

    @pluginlib.abstractmethod
    def parse(self, string):
        pass

Step 2: Define plugin classes

To create a plugin, subclass a parent class and include any required methods.

Plugins can be customized through optional class attributes:

_alias_

Changes the name of the plugin which defaults to the class name.

_version_

Sets the version of the plugin. Defaults to the module __version__ or None If multiple plugins with the same type and name are loaded, the plugin with the highest version is used. For more information, see the Versions section.

_skipload_

Specifies the plugin should not be loaded. This is useful when a plugin is a parent class for additional plugins or when a plugin should only be loaded under certain conditions. For more information see the Conditional Loading section.

"""
sample_plugins.py
"""
import json
import sample

class JSON(sample.Parser):

    _alias_ = 'json'

    def parse(self, string):
        return json.loads(string)

Step 3: Load plugins

Plugins are loaded when the module they are in is imported. PluginLoader will load modules from specified locations and provides access to them.

PluginLoader can load plugins from several locations.
  • A program’s standard library

  • Entry points

  • A list of modules

  • A list of filesystem paths

Plugins can also be filtered through blacklists and type filters. See the Blacklists and Type Filters sections for more information.

Plugins are accessible through the PluginLoader.plugins property, a nested dictionary accessible through dot notation. For other ways to access plugins, see the Accessing Plugins section.

import pluginlib
import sample

loader = pluginlib.PluginLoader(modules=['sample_plugins'])
plugins = loader.plugins
parser = plugins.parser.json()
print(parser.parse('{"json": "test"}'))

Metadata

Release files for pluginlib 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pluginlib 0.6.0
File Size Uploaded
pluginlib-0.6.0.tar.gz 140.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pluginlib 0.6.0
File Interpreter ABI Platform
pluginlib-0.6.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 167.7 kB

Release files / pluginlib-0.6.0.tar.gz

Download URL pluginlib-0.6.0.tar.gz
Size 140.9 kB
Tags Source
SHA-256 checksum
How to use checksums
82ed3396939c8182052639c60f03d024c45c2d0b20d7b4e68b24074b033fe135
BLAKE2b-256 checksum
How to use checksums
bd04369ff1559608f128a51b2846155c328be63eeee5b85ed3d19e651a29215e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.9.1 pkginfo/1.3.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.19.6 CPython/3.6.6

Release files / pluginlib-0.6.0-py2.py3-none-any.whl

Download URL pluginlib-0.6.0-py2.py3-none-any.whl
Size 26.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
3c535da217df5e1b74d7c833e8646c8457e2af1d10a7af032632051c7186c8f1
BLAKE2b-256 checksum
How to use checksums
428267c32d8c2edab84e23f09b89eedc4e953de159d832011e821aea28740bbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.9.1 pkginfo/1.3.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.19.6 CPython/3.6.6

Release history Release notifications | RSS feed

0.11.0

2 release files

0.10.0

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.2

2 release files

0.6.1

2 release files

This release

0.6.0 This release

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page