简体中文 English 繁體中文 日本語 Русский
本文为静态镜像,内容以交互版为准 在交互式文档中心打开 →

ErisPulse.loaders.adapter 模块


模块概述

ErisPulse 适配器加载器

专门用于从 PyPI 包加载和初始化适配器

提示

  1. 适配器必须通过 entry-points 机制注册到 erispulse.adapter 组
  2. 适配器类必须继承 BaseAdapter
  3. 适配器不适用懒加载

类列表

class AdapterLoader(BaseLoader)

适配器加载器

负责从 PyPI entry-points 加载适配器

提示 使用方式:

loader = AdapterLoader() adapter_objs, enabled, disabled = await loader.load(adapter_manager)

方法列表

__init__()

初始化适配器加载器


_get_entry_point_group()

获取 entry-point 组名

返回值: 入口点组名字符串


async load(manager_instance: Any)

从 entry-points 加载对象(使用 AdapterFinder)

异常: ImportError - 当加载失败时抛出


async _process_entry_point(entry_point: Any, objs: dict[str, Any], enabled_list: list[str], disabled_list: list[str], manager_instance: Any)

处理单个适配器 entry-point

返回值 (dict[str,): Any]: 更新后的适配器对象字典 list[str]: 更新后的启用适配器列表 list[str]: 更新后的禁用适配器列表 bool: 是否为新适配器

异常: ImportError - 当适配器加载失败时抛出


async register_to_manager(adapters: list[str], adapter_objs: dict[str, Any], manager_instance: Any)

将适配器注册到管理器