轻量级Python插件系统,支持配置继承
项目描述
pluginmgr
轻量级Python插件系统,支持配置继承
使用方法
有关完整示例,请参阅 https://github.com/20c/pluginmgr/tree/master/tests/pluginmgr_test
创建管理器,例如在模块 __init__.py
文件中
import pluginmgr
# this is the namespace string that import uses
namespace = 'pluginmgr_test.plugins'
# directories to look in, string or list of strings
searchpath = 'path/to/search/in'
# determines if this should create a blank loader to import through. This
# should be enabled if there isn't a real module path for the namespace and
# disabled for sharing the namespace with static modules
# default is False
create_loader = False
plugin = pluginmgr.PluginManager(namespace, searchpath, create_loader)
创建并注册插件,请注意文件名需要与注册名称相同
from pluginmgr_test import plugin
# register a plugin named mod0
@plugin.register('mod0')
class Mod0(pluginmgr.PluginBase):
pass
查看包含所有注册插件的字典
from pluginmgr_test import plugin
# dict of all registered plugins
print(plugin.registry)
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。
源代码发行版
pluginmgr-1.2.0.tar.gz (8.9 kB 查看哈希值)
构建发行版
pluginmgr-1.2.0-py3-none-any.whl (9.5 kB 查看哈希值)
关闭
pluginmgr-1.2.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 42b48f1ea6f961b621ea20b37a350d1ae3811fc294572a3e8ea896cf2f370a66 |
|
MD5 | 4a8892bf3d2d109e922bed79d6bc69e8 |
|
BLAKE2b-256 | b7e8d9600b4a18441c3779a3726451c8d9a5a4791036a5b0b016c34a836c007c |
关闭
pluginmgr-1.2.0-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 6fef434ee20c441a1c6e44d248a7df8dccd35d5546b2aecd3f12300441ae8fcd |
|
MD5 | 2693586dc3ab0c5b6b2ee17c1f2de557 |
|
BLAKE2b-256 | 7fae30821d5f90abf21163be85636151213775d8b610a773921902496373aadd |