Skip to main content

Python package / plugin / extension manager

Project description

Dismantle

Dismantle Python package / plugin / extension manager.

"""Simple plugin example"""
from dismantle import plugin


class Chat():
    @plugin.register('chat.message')
    def show(self, message):
        print(message)


@plugin.plugin('chat.message', order=-1)
def make_uppercase(message):
    return message.upper()
"""Full example using all aspects."""
from pathlib import Path
from dismantle.extension import Extensions, IExtension
from dismantle.index import JsonFileIndexHandler
from dismantle.package import LocalPackageHandler


class ColorExtension(IExtension):
    _category = 'color'

    def color(self) -> None:
        ...


class GreenColorExtension(ColorExtension):
    _name = 'green'

    def color(self) -> None:
        print(f'color is {self._name}')


packages = {}
index = JsonFileIndexHandler('index.json')
for pkg_meta in index:
    meta = index[pkg_meta]
    path = datadir.join(meta['path'])
    package = LocalPackageHandler(meta['name'], path)
    package._meta = {**package._meta, **meta}
    package.install()
    packages[package.name] = package
extensions = Extensions([ColorExtension], packages, 'ext_')
assert extensions.types == ['color']
assert list(extensions.category('color').keys()) == [
    '@scope-one/package-one.extension.green.GreenColorExtension',
    '@scope-one/package-two.extension.red.RedColorExtension',
    '@scope-one/package-three.extension.blue.BlueColorExtension',
]
assert list(extensions.extensions.keys()) == ['color']
assert list(extensions.imports.keys()) == [
    '@scope-one/package-one.extension.green',
    '@scope-one/package-two.extension.red',
    '@scope-one/package-three.extension.blue'
]

Dismantle allows you to provide the ability to create a plugin/extension/module for an application. It does this by checking a package index and using that index to manage package versions. Packages then contain plugins (using decorators) and extensions (using a custom module loader) to add the additional functionality to the application.

Installing Dismantle and Supported Versions

Dismantle is available on PyPI:

$ python -m pip install dismantle

Dismantle officially supports Python 3.7+.

Supported Features & Best–Practices

Dismantle is ready for the demands of providing flexibility within applications allowing developers to build rich ecosystems around core applications.

Index Management

  • easy to create custom index handlers providing additional ways to define package indexes
  • local index file support using json
  • url based index file support using json
  • etag based caching for url based index

Packaging

  • easy to create custom package handlers providing additional ways to define package sources
  • easy to create custom package formats compression types and structures
  • support for zip, tar.gz, tgz, and local directories as package formats
  • support for local and url based (http/https) package handlers
  • hash validation for packages with the ability to verify package integrity

Extensions

  • Categorized extension groups to filter extension types (eg. loggers, parsers, ...)
  • Support for init or .py based module loading.
  • Extension activation and deactivation management.
  • Module name collision avoidance
  • Hierarchical module naming

Plugins

  • Decorator based plugins with pre and post value modification
  • Multiple plugins per function with ability to set execution order
  • Activation management

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

dismantle-0.5.0.tar.gz (29.4 kB view details)

Uploaded Source

Built Distribution

dismantle-0.5.0-py3-none-any.whl (30.2 kB view details)

Uploaded Python 3

File details

Details for the file dismantle-0.5.0.tar.gz.

File metadata

  • Download URL: dismantle-0.5.0.tar.gz
  • Upload date:
  • Size: 29.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.7.7 Darwin/19.6.0

File hashes

Hashes for dismantle-0.5.0.tar.gz
Algorithm Hash digest
SHA256 12984942db18b8dd95961014aa9563972ed605a8b0db47087e09d186a070fc3d
MD5 f25d0841c9091e0990d9b55e2f0d3d81
BLAKE2b-256 e666a65840022db67a4d22e03cd036dd2e34edeb67574cfb4ad1aa8a4e3d1922

See more details on using hashes here.

File details

Details for the file dismantle-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: dismantle-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 30.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.7.7 Darwin/19.6.0

File hashes

Hashes for dismantle-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3aac4fa131de3dea347469dad27b94d8609992018f03f33118cce529ed133b83
MD5 d9d5b0f2e29e14d08518a2b6716cb078
BLAKE2b-256 6f5700b60136515985f54e550efd7a3f255388a7ba110688658f42bbe8e8abf8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page