Package: dismantle
DismantleDismantleis a module created for Python programs to provide the ability to provide additional functionality using packages listed within local or remote indices and installed during runtime.Dismantle 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 DismantleDismantle is available on PyPI:$python-mpipinstalldismantleNOTE: *Dismantle officially supports Python from 3.7 upSupported Features & Best–PracticesDismantle provides the flexibility within applications allowing developers to build rich ecosystems around core applications. It does this by providing the following:Index ManagementIndex files are used to provide list of available packages and provide information on packages and
the versions of said packages available.support for multiple index files that cascadeeasy to create custom index handlers providing additional ways to define package indiceslocal index file support using json built inurl based index file support using json built inetag based caching for url based indexPackagingPackages listed in index files provide the ability to bundle features and act as a transport
mechanism for additional functionality while providing security.easy to create custom package handlers providing additional ways to define package sourceseasy to create custom package formats compression types and structuressupport for zip, tar.gz, tgz, and local directories as package formats built insupport for local and url based (http/https) package handlers built inhash validation for packages with the ability to verify package integrityExtensionsExtensions contained within packages provide a way to dynamically load modules at runtime for
Python modules as needed.  Packages can replace or extend application functionality at runtime by
replacing or adding modules in Pythons global modules manager.Categorized extension groups to filter extension types (eg. loggers, parsers, ...)Support forinitor .py based module loading.Extension activation and deactivation management.Module name collision avoidanceHierarchical module namingPluginsPlugins contained within packages provide a way to intercept function parameters and return values
in order to manipulate data on the fly.  Plugins can be used for data validation, manipilation, or
to provide additional logging or auditing functionality.Decorator based plugins with pre and post value interceptions and/or modificationMultiple plugins per function with ability to set execution orderActivation managementExample implementationsPlugin"""Simple plugin example"""fromdismantleimportpluginclassChat():@plugin.register('chat.message')defshow(self,message):print(message)@plugin.plugin('chat.message',order=-1)defmake_uppercase(message):returnmessage.upper()Extension"""Full example using all aspects."""fromdismantle.extensionimportExtensions,IExtensionfromdismantle.indeximportJsonFileIndexHandlerfromdismantle.packageimportLocalPackageHandlerclassColorExtension(IExtension):_category='color'defcolor(self)->None:...classGreenColorExtension(ColorExtension):_name='green'defcolor(self)->None:print(f'color is{self._name}')packages={}index=JsonFileIndexHandler('index.json')forpkg_metainindex:meta=index[pkg_meta]package=LocalPackageHandler(meta['name'],'foo/path')package._meta={**package._meta,**meta}package.install()packages[package.name]=packageextensions=Extensions([ColorExtension],packages,'ext_')assertextensions.types==['color']assertlist(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',]assertlist(extensions.extensions.keys())==['color']assertlist(extensions.imports.keys())==['@scope-one/package-one.extension.green','@scope-one/package-two.extension.red','@scope-one/package-three.extension.blue']