config.abc ========== .. py:module:: config.abc .. autoapi-nested-parse:: 配置抽象基类 Attributes ---------- .. autoapisummary:: config.abc.AnyKey config.abc.PathLike config.abc.SLArgumentType Classes ------- .. autoapisummary:: config.abc.ABCConfigData config.abc.ABCConfigFile config.abc.ABCConfigPool config.abc.ABCConfigSL config.abc.ABCIndexedConfigData config.abc.ABCKey config.abc.ABCMetaParser config.abc.ABCPath config.abc.ABCProcessorHelper config.abc.ABCSLProcessorPool Module Contents --------------- .. py:class:: ABCConfigData Bases: :py:obj:`abc.ABC` 配置数据抽象基类 .. versionchanged:: 0.1.5 现在配置数据不再局限于Mapping .. py:method:: __format__(format_spec: str) -> str .. py:method:: freeze(freeze: bool | None = None) -> Self 冻结配置数据 (切换只读模式) :param freeze: 是否冻结配置数据, 为 :py:const:`None` 时进行切换 :type freeze: bool | None :return: 返回当前实例便于链式调用 :rtype: Self .. versionadded:: 0.1.5 .. py:method:: from_data(*args: Any, **kwargs: Any) -> Self :classmethod: 提供创建同类型配置数据的快捷方式 :return: 新的配置数据 :rtype: Self .. note:: 套壳 ``__init__`` 主要是为了方便内部快速创建与传入的ABCConfigData同类型的对象 例如: .. code-block:: python type(instance)(data) 可以简写为 .. code-block:: python instance.from_data(data) .. versionchanged:: 0.2.0 现在会自适应初始化参数 .. py:attribute:: __slots__ :value: () .. py:property:: data_read_only :type: bool | None :abstractmethod: 配置数据是否为只读 :return: 配置数据是否为只读 :rtype: bool | None .. versionadded:: 0.1.3 .. versionchanged:: 0.1.5 改为抽象属性 .. py:property:: read_only :type: bool | None :abstractmethod: 配置数据是否为 ``只读模式`` :return: 配置数据是否为 ``只读模式`` :rtype: bool | None .. py:class:: ABCConfigFile(initial_config: D, *, config_format: str | None = None) Bases: :py:obj:`abc.ABC` 配置文件类 :param initial_config: 配置数据 :type initial_config: D :param config_format: 配置文件的格式 :type config_format: str | None .. caution:: ``initial_config`` 参数未默认做深拷贝,可能导致非预期行为 .. versionchanged:: 0.2.0 重命名参数 ``config_data`` 为 ``initial_config`` .. py:method:: __bool__() -> bool .. py:method:: __eq__(other: Any) -> bool .. py:method:: __repr__() -> str .. py:method:: initialize(processor_pool: ABCSLProcessorPool, namespace: str, file_name: str, config_format: str, *processor_args: Any, **processor_kwargs: Any) -> Self :classmethod: :abstractmethod: 初始化一个受SL处理器支持的配置文件 :param processor_pool: 配置池 :type processor_pool: ABCSLProcessorPool :param namespace: 文件命名空间 :type namespace: str :param file_name: 文件名 :type file_name: str :param config_format: 配置文件的格式 :type config_format: str :return: 配置对象 :rtype: Self :raise UnsupportedConfigFormatError: 不支持的配置格式 .. versionadded:: 0.2.0 .. py:method:: load(processor_pool: ABCSLProcessorPool, namespace: str, file_name: str, config_format: str, *processor_args: Any, **processor_kwargs: Any) -> Self :classmethod: :abstractmethod: 从SL处理器加载配置 :param processor_pool: 配置池 :type processor_pool: ABCSLProcessorPool :param namespace: 文件命名空间 :type namespace: str :param file_name: 文件名 :type file_name: str :param config_format: 配置文件的格式 :type config_format: str :return: 配置对象 :rtype: Self :raise UnsupportedConfigFormatError: 不支持的配置格式 .. versionchanged:: 0.2.0 重命名 ``config_pool`` 为 ``processor_pool`` .. py:method:: save(processor_pool: ABCSLProcessorPool, namespace: str, file_name: str, config_format: str | None = None, *processor_args: Any, **processor_kwargs: Any) -> None :abstractmethod: 使用SL处理保存配置 :param processor_pool: 配置池 :type processor_pool: ABCSLProcessorPool :param namespace: 文件命名空间 :type namespace: str :param file_name: 文件名 :type file_name: str :param config_format: 配置文件的格式 :type config_format: str | None :raise UnsupportedConfigFormatError: 不支持的配置格式 .. versionchanged:: 0.2.0 重命名 ``config_pool`` 为 ``processor_pool`` .. py:attribute:: __hash__ :value: None .. py:attribute:: __slots__ :value: () .. py:attribute:: _config :type: D .. py:attribute:: _config_format :type: str | None :value: None .. py:property:: config :type: D :return: 配置数据 .. caution:: 未默认做深拷贝,可能导致非预期行为 .. versionchanged:: 0.2.0 重命名属性 ``data`` 为 ``config`` .. py:property:: config_format :type: str | None 配置文件的格式 .. py:class:: ABCConfigPool(root_path: str = './.config') Bases: :py:obj:`ABCSLProcessorPool` 配置池抽象类 :param root_path: 保存的根目录 :type root_path: str .. py:method:: discard(namespace: str, file_name: str | None = None) -> Self :abstractmethod: 确保配置文件不存在于配置池 :param namespace: 命名空间 :type namespace: str :param file_name: 文件名 :type file_name: str | None :return: 返回当前实例便于链式调用 :rtype: Self .. versionadded:: 0.2.0 .. py:method:: get(namespace: str) -> dict[str, ABCConfigFile[Any]] | None get(namespace: str, file_name: str) -> ABCConfigFile[Any] | None get(namespace: str, file_name: str | None = None) -> dict[str, ABCConfigFile[Any]] | ABCConfigFile[Any] | None 获取配置 如果配置不存在则返回None :param namespace: 命名空间 :type namespace: str :param file_name: 文件名 :type file_name: Optional[str] :return: 配置 :rtype: dict[str, ABCConfigFile] | ABCConfigFile | None .. py:method:: initialize(namespace: str, file_name: str, *args: Any, config_formats: str | collections.abc.Iterable[str] | None = None, **kwargs: Any) -> ABCConfigFile[Any] :abstractmethod: 初始化配置文件到指定命名空间并返回 :param namespace: 命名空间 :type namespace: str :param file_name: 文件名 :type file_name: str :param config_formats: 配置格式 :type config_formats: str | Iterable[str] | None :return: 配置对象 :rtype: ABCConfigFile .. versionadded:: 0.2.0 .. py:method:: load(namespace: str, file_name: str, *args: Any, config_formats: str | collections.abc.Iterable[str] | None = None, allow_initialize: bool = False, **kwargs: Any) -> ABCConfigFile[Any] :abstractmethod: 加载配置到指定命名空间并返回 :param namespace: 命名空间 :type namespace: str :param file_name: 文件名 :type file_name: str :param config_formats: 配置格式 :type config_formats: str | Iterable[str] | None :param allow_initialize: 是否允许初始化配置文件 :type allow_initialize: bool :return: 配置对象 :rtype: ABCConfigFile .. versionchanged:: 0.2.0 现在会像 :py:meth:`save` 一样接收并传递额外参数 删除参数 ``config_file_cls`` 重命名参数 ``allow_create`` 为 ``allow_initialize`` .. py:method:: remove(namespace: str, file_name: str | None = None) -> Self :abstractmethod: 从配置池移除配置文件 :param namespace: 命名空间 :type namespace: str :param file_name: 文件名 :type file_name: str | None :return: 返回当前实例便于链式调用 :rtype: Self .. versionchanged:: 0.2.0 返回当前实例便于链式调用 重命名 ``delete`` 为 ``remove`` .. py:method:: save(namespace: str, file_name: str, config_formats: str | collections.abc.Iterable[str] | None = None, config: ABCConfigFile[Any] | None = None, *args: Any, **kwargs: Any) -> Self :abstractmethod: 保存配置 :param namespace: 命名空间 :type namespace: str :param file_name: 文件名 :type file_name: str :param config_formats: 配置格式 :type config_formats: str | Iterable[str] | None :param config: 配置文件,可选,提供此参数相当于自动调用了一遍pool.set :type config: ABCConfigFile | None :return: 返回当前实例便于链式调用 :rtype: Self .. versionchanged:: 0.1.2 添加参数 ``config_formats`` 添加参数 ``config`` .. versionchanged:: 0.2.0 返回当前实例便于链式调用 .. py:method:: save_all(*, ignore_err: bool = False) -> dict[str, dict[str, tuple[ABCConfigFile[Any], Exception]]] | None :abstractmethod: 保存所有配置 :param ignore_err: 是否忽略保存导致的错误 :type ignore_err: bool :return: ignore_err为True时返回{Namespace: {FileName: (ConfigObj, Exception)}},否则返回None :rtype: dict[str, dict[str, tuple[ABCConfigFile, Exception]]] | None .. versionchanged:: 0.3.0 更改参数 ``ignore_err`` 为仅关键字参数 .. py:method:: set(namespace: str, file_name: str, config: ABCConfigFile[Any]) -> Self :abstractmethod: 设置配置 :param namespace: 命名空间 :type namespace: str :param file_name: 文件名 :type file_name: str :param config: 配置 :type config: ABCConfigFile :return: 返回当前实例便于链式调用 :rtype: Self .. versionchanged:: 0.2.0 返回当前实例便于链式调用 .. py:attribute:: FileNameProcessors :type: collections.OrderedDict[str | re.Pattern[str], list[str]] 文件名处理器注册表 .. caution:: 此字典是顺序敏感的,越靠前越优先被检查 数据结构: ``{文件名匹配: [处理器注册名]}`` 文件名匹配: - 为字符串时会使用 ``endswith`` 进行匹配 - 为 ``re.Pattern`` 时会使用 ``Pattern.fullmatch`` 进行匹配 .. versionchanged:: 0.2.0 重命名 ``FileExtProcessor`` 为 ``FileNameProcessors`` 现在是顺序敏感的 .. py:attribute:: SLProcessors :type: dict[str, ABCConfigSL] 处理器注册表 数据结构: ``{处理器注册名: 处理器实例}}`` .. versionchanged:: 0.2.0 重命名 ``SLProcessor`` 为 ``SLProcessors`` .. py:attribute:: __slots__ :value: () .. py:attribute:: _root_path :value: './.config' .. py:property:: helper :type: ABCProcessorHelper :abstractmethod: 处理器助手 .. py:property:: root_path :type: str 配置文件根目录 .. py:class:: ABCConfigSL(*, reg_alias: str | None = None) Bases: :py:obj:`abc.ABC` 配置SaveLoad处理器抽象类 .. versionchanged:: 0.2.0 移动 ``保存加载器参数`` 相关至 :py:class:`BasicLocalFileConfigSL` :param reg_alias: sl处理器注册别名 :type reg_alias: Optional[str] .. py:method:: __eq__(other: Any) -> bool .. py:method:: __hash__() -> int .. py:method:: initialize(processor_pool: ABCSLProcessorPool, root_path: str, namespace: str, file_name: str, *args: Any, **kwargs: Any) -> ABCConfigFile[Any] :abstractmethod: 初始化一个受SL处理器支持的配置文件 :param processor_pool: 配置池 :type processor_pool: ABCSLProcessorPool :param root_path: 保存的根目录 :type root_path: str :param namespace: 配置的命名空间 :type namespace: str :param file_name: 配置文件名 :type file_name: str :return: 配置对象 :rtype: ABCConfigFile .. versionadded:: 0.2.0 .. py:method:: load(processor_pool: ABCSLProcessorPool, root_path: str, namespace: str, file_name: str, *args: Any, **kwargs: Any) -> ABCConfigFile[Any] :abstractmethod: 加载处理器 :param processor_pool: 配置池 :type processor_pool: ABCSLProcessorPool :param root_path: 保存的根目录 :type root_path: str :param namespace: 配置的命名空间 :type namespace: str :param file_name: 配置文件名 :type file_name: str :return: 配置对象 :rtype: ABCConfigFile :raise FailedProcessConfigFileError: 处理配置文件失败 .. versionchanged:: 0.2.0 删除参数 ``config_file_cls`` 添加参数 ``processor_pool`` .. py:method:: register_to(config_pool: ABCSLProcessorPool) -> Self 注册到配置池中 :param config_pool: 配置池 :type config_pool: ABCSLProcessorPool :return: 返回当前实例便于链式调用 :rtype: Self .. versionchanged:: 0.3.0 返回当前实例便于链式调用 .. py:method:: save(processor_pool: ABCSLProcessorPool, config_file: ABCConfigFile[Any], root_path: str, namespace: str, file_name: str, *args: Any, **kwargs: Any) -> None :abstractmethod: 保存处理器 :param processor_pool: 配置池 :type processor_pool: ABCSLProcessorPool :param config_file: 待保存配置 :type config_file: ABCConfigFile :param root_path: 保存的根目录 :type root_path: str :param namespace: 配置的命名空间 :type namespace: str :param file_name: 配置文件名 :type file_name: str :raise FailedProcessConfigFileError: 处理配置文件失败 .. versionchanged:: 0.2.0 添加参数 ``processor_pool`` .. py:attribute:: __slots__ :value: () .. py:attribute:: _reg_alias :type: str | None :value: None .. py:property:: processor_reg_name :type: str :abstractmethod: SL处理器的默认注册名 .. py:property:: reg_alias :type: str | None 处理器的别名 .. py:property:: reg_name :type: str 处理器的注册名 .. py:property:: supported_file_classes :type: list[type[ABCConfigFile[Any]]] :abstractmethod: :return: 支持的配置文件类 .. versionadded:: 0.2.0 .. py:property:: supported_file_patterns :type: tuple[str | re.Pattern[Any], Ellipsis] :abstractmethod: :return: 支持的文件名匹配 .. versionchanged:: 0.2.0 重命名 ``file_ext`` 为 ``supported_file_patterns`` .. py:class:: ABCIndexedConfigData Bases: :py:obj:`ABCConfigData`, :py:obj:`config._protocols.MutableIndexed`\ [\ :py:obj:`Any`\ , :py:obj:`Any`\ ], :py:obj:`abc.ABC` 支持 ``索引`` 操作的配置数据 .. versionadded:: 0.1.5 .. versionchanged:: 0.2.0 重命名 ``ABCSupportsIndexConfigData`` 为 ``ABCIndexedConfigData`` .. py:method:: __contains__(key: Any) -> bool :abstractmethod: .. py:method:: __delitem__(index: Any) -> None :abstractmethod: .. py:method:: __format__(format_spec: str) -> str .. py:method:: __getitem__(index: Any) -> Any :abstractmethod: .. py:method:: __iter__() -> collections.abc.Iterator[Any] :abstractmethod: .. py:method:: __len__() -> int :abstractmethod: .. py:method:: __setitem__(index: Any, value: Any) -> None :abstractmethod: .. py:method:: delete(path: PathLike) -> Self :abstractmethod: 删除路径 :param path: 路径 :type path: PathLike :return: 返回当前实例便于链式调用 :rtype: Self :raise ConfigDataReadOnlyError: 配置数据为只读 :raise ConfigDataTypeError: 配置数据类型错误 :raise RequiredPathNotFoundError: 需求的键不存在 .. py:method:: exists(path: PathLike, *, ignore_wrong_type: bool = False) -> bool :abstractmethod: 判断路径是否存在 :param path: 路径 :type path: PathLike :param ignore_wrong_type: 忽略配置数据类型错误 :type ignore_wrong_type: bool :return: 路径是否存在 :rtype: bool :raise ConfigDataTypeError: 配置数据类型错误 .. py:method:: freeze(freeze: bool | None = None) -> Self 冻结配置数据 (切换只读模式) :param freeze: 是否冻结配置数据, 为 :py:const:`None` 时进行切换 :type freeze: bool | None :return: 返回当前实例便于链式调用 :rtype: Self .. versionadded:: 0.1.5 .. py:method:: from_data(*args: Any, **kwargs: Any) -> Self :classmethod: 提供创建同类型配置数据的快捷方式 :return: 新的配置数据 :rtype: Self .. note:: 套壳 ``__init__`` 主要是为了方便内部快速创建与传入的ABCConfigData同类型的对象 例如: .. code-block:: python type(instance)(data) 可以简写为 .. code-block:: python instance.from_data(data) .. versionchanged:: 0.2.0 现在会自适应初始化参数 .. py:method:: get(path: PathLike, default: ABCIndexedConfigData.get.V | None = None, *, return_raw_value: bool = False) -> ABCIndexedConfigData.get.V | Any :abstractmethod: 获取路径的值的*快照*,路径不存在时填充默认值 :param path: 路径 :type path: PathLike :param default: 默认值 :type default: V :param return_raw_value: 是否获取原始值 :type return_raw_value: bool :return: 路径的值 :rtype: V | Any :raise ConfigDataTypeError: 配置数据类型错误 例子 ---- >>> from c41811.config import MappingConfigData >>> data = MappingConfigData({"key": "value"}) 路径存在时返回值 >>> data.get("key") 'value' 路径不存在时返回默认值None >>> print(data.get("not exists")) None 自定义默认值 >>> data.get("with default", default="default value") 'default value' .. versionchanged:: 0.2.0 重命名参数 ``get_raw`` 为 ``return_raw_value`` .. py:method:: modify(path: PathLike, value: Any, *, allow_create: bool = True) -> Self :abstractmethod: 修改路径的值 :param path: 路径 :type path: PathLike :param value: 值 :type value: Any :param allow_create: 是否允许创建不存在的路径,默认为True :type allow_create: bool :return: 返回当前实例便于链式调用 :rtype: Self :raise ConfigDataReadOnlyError: 配置数据为只读 :raise ConfigDataTypeError: 配置数据类型错误 :raise RequiredPathNotFoundError: 需求的键不存在 .. caution:: ``value`` 参数未默认做深拷贝,可能导致非预期行为 .. attention:: ``allow_create`` 时,使用与 `self.data` 一样的类型新建路径 .. py:method:: retrieve(path: PathLike, *, return_raw_value: bool = False) -> Any :abstractmethod: 获取路径的值的*快照* :param path: 路径 :type path: PathLike :param return_raw_value: 是否获取原始值,为 :py:const:`False` 时,会将Mapping | Sequence转换为对应类 :type return_raw_value: bool :return: 路径的值 :rtype: Any :raise ConfigDataTypeError: 配置数据类型错误 :raise RequiredPathNotFoundError: 需求的键不存在 .. versionchanged:: 0.2.0 重命名参数 ``get_raw`` 为 ``return_raw_value`` .. py:method:: setdefault(path: PathLike, default: ABCIndexedConfigData.setdefault.V | None = None, *, return_raw_value: bool = False) -> ABCIndexedConfigData.setdefault.V | Any :abstractmethod: 如果路径不在配置数据中则填充默认值到配置数据并返回 :param path: 路径 :type path: PathLike :param default: 默认值 :type default: V :param return_raw_value: 是否获取原始值 :type return_raw_value: bool :return: 路径的值 :rtype: V | Any :raise ConfigDataReadOnlyError: 配置数据为只读 :raise ConfigDataTypeError: 配置数据类型错误 例子 ---- >>> from c41811.config import MappingConfigData >>> data = MappingConfigData({"key": "value"}) 路径存在时返回值 >>> data.setdefault("key") 'value' 路径不存在时返回默认值None并填充到原始数据 >>> print(data.setdefault("not exists")) None >>> data MappingConfigData({'key': 'value', 'not exists': None}) 自定义默认值 >>> data.setdefault("with default", default="default value") 'default value' >>> data MappingConfigData({'key': 'value', 'not exists': None, 'with default': 'default value'}) .. versionchanged:: 0.2.0 重命名参数 ``get_raw`` 为 ``return_raw_value`` 重命名 ``set_default`` 为 ``setdefault`` .. py:method:: unset(path: PathLike) -> Self :abstractmethod: 确保路径不存在 (删除路径,但是找不到路径时不会报错) :param path: 路径 :type path: PathLike :return: 返回当前实例便于链式调用 :rtype: Self :raise ConfigDataReadOnlyError: 配置数据为只读 :raise ConfigDataTypeError: 配置数据类型错误 .. versionadded:: 0.1.2 .. py:attribute:: __slots__ :value: () .. py:property:: data_read_only :type: bool | None :abstractmethod: 配置数据是否为只读 :return: 配置数据是否为只读 :rtype: bool | None .. versionadded:: 0.1.3 .. versionchanged:: 0.1.5 改为抽象属性 .. py:property:: read_only :type: bool | None :abstractmethod: 配置数据是否为 ``只读模式`` :return: 配置数据是否为 ``只读模式`` :rtype: bool | None .. py:class:: ABCKey(key: K, meta: str | None = None) Bases: :py:obj:`abc.ABC` 用于获取配置的键 :param key: 键名 :type key: K :param meta: 元信息 :type meta: str | None .. py:method:: __contains_inner_element__(data: D) -> bool :abstractmethod: 是否包含内层元素 :param data: 配置数据 :type data: D :return: 是否包含内层配置数据 :rtype: bool .. versionadded:: 0.1.4 .. py:method:: __deepcopy__(memo: dict[Any, Any]) -> Self .. py:method:: __delete_inner_element__(data: D) -> None :abstractmethod: 删除内层元素 :param data: 配置数据 :type data: D .. versionadded:: 0.1.4 .. py:method:: __eq__(other: Any) -> bool .. py:method:: __get_inner_element__(data: D) -> D :abstractmethod: 获取内层元素 :param data: 配置数据 :type data: D :return: 内层配置数据 :rtype: D .. versionadded:: 0.1.4 .. py:method:: __hash__() -> int .. py:method:: __repr__() -> str .. py:method:: __set_inner_element__(data: D, value: Any) -> None :abstractmethod: 设置内层元素 :param data: 配置数据 :type data: D :param value: 值 :type value: Any .. versionadded:: 0.1.4 .. py:method:: __str__() -> str .. py:method:: __supports__(data: Any) -> tuple[Any, Ellipsis] :abstractmethod: 检查此键是否支持该配置数据 返回缺失的协议 :param data: 配置数据 :type data: Any :return: 此键缺失支持的数据类型 :rtype: tuple .. versionadded:: 0.1.4 .. py:method:: __supports_modify__(data: Any) -> tuple[Any, Ellipsis] :abstractmethod: 检查此键是否支持修改该配置数据 返回缺失的协议 :param data: 配置数据 :type data: Any :return: 此键缺失支持的数据类型 :rtype: tuple .. versionadded:: 0.1.4 .. py:method:: unparse() -> str :abstractmethod: 还原为可被解析的字符串 .. versionadded:: 0.1.1 .. py:attribute:: __slots__ :value: () .. py:attribute:: _key .. py:attribute:: _meta :type: str | None :value: None .. py:property:: key :type: K 键 .. py:property:: meta :type: str | None 元信息 .. versionadded:: 0.2.0 .. py:class:: ABCMetaParser Bases: :py:obj:`abc.ABC` 元信息解析器抽象类 .. versionadded:: 0.2.0 .. py:method:: convert_config2meta(meta_config: D) -> M :abstractmethod: 解析元配置 :param meta_config: 元配置 :type meta_config: D :return: 元数据 :rtype: M .. py:method:: convert_meta2config(meta: M) -> D :abstractmethod: 解析元数据 :param meta: 元数据 :type meta: M :return: 元配置 :rtype: D .. py:method:: validator(meta: M, *args: Any) -> M :abstractmethod: 元数据验证器 .. py:attribute:: __slots__ :value: () .. py:class:: ABCPath(keys: collections.abc.Iterable[K]) Bases: :py:obj:`abc.ABC`, :py:obj:`collections.abc.Iterable`\ [\ :py:obj:`ABCPath.K`\ ] 用于获取数据的路径 :param keys: 路径的键 :type keys: Iterable[K] .. py:method:: __bool__() -> bool .. py:method:: __contains__(item: Any) -> bool .. py:method:: __deepcopy__(memo: dict[Any, Any]) -> Self .. py:method:: __eq__(other: Any) -> bool .. py:method:: __getitem__(item: slice) -> Self __getitem__(item: int) -> K .. py:method:: __hash__() -> int .. py:method:: __iter__() -> collections.abc.Iterator[K] .. py:method:: __len__() -> int .. py:method:: __repr__() -> str .. py:method:: __subclasshook__(C) :classmethod: .. py:method:: unparse() -> str :abstractmethod: 还原为可被解析的字符串 .. versionadded:: 0.1.1 .. py:attribute:: __class_getitem__ .. py:attribute:: __slots__ :value: () .. py:attribute:: _keys .. py:property:: keys :type: tuple[K, Ellipsis] 键列表 .. note:: 返回的是深拷贝副本,修改不会影响路径 .. versionadded:: 0.2.0 .. py:class:: ABCProcessorHelper Bases: :py:obj:`abc.ABC` 辅助SL处理器 .. versionadded:: 0.2.0 .. py:method:: calc_path(root_path: str, namespace: str, file_name: str | None = None) -> str :staticmethod: 处理配置文件对应的文件路径 file_name为None时,返回文件所在的目录 :param root_path: 保存的根目录 :type root_path: str :param namespace: 配置的命名空间 :type namespace: str :param file_name: 配置文件名 :type file_name: str | None :return: 配置文件路径 :rtype: str .. py:attribute:: __slots__ :value: () .. py:class:: ABCSLProcessorPool(root_path: str = './.config') Bases: :py:obj:`abc.ABC` SL处理器池 :param root_path: 保存的根目录 :type root_path: str .. py:attribute:: FileNameProcessors :type: collections.OrderedDict[str | re.Pattern[str], list[str]] 文件名处理器注册表 .. caution:: 此字典是顺序敏感的,越靠前越优先被检查 数据结构: ``{文件名匹配: [处理器注册名]}`` 文件名匹配: - 为字符串时会使用 ``endswith`` 进行匹配 - 为 ``re.Pattern`` 时会使用 ``Pattern.fullmatch`` 进行匹配 .. versionchanged:: 0.2.0 重命名 ``FileExtProcessor`` 为 ``FileNameProcessors`` 现在是顺序敏感的 .. py:attribute:: SLProcessors :type: dict[str, ABCConfigSL] 处理器注册表 数据结构: ``{处理器注册名: 处理器实例}}`` .. versionchanged:: 0.2.0 重命名 ``SLProcessor`` 为 ``SLProcessors`` .. py:attribute:: __slots__ :value: () .. py:attribute:: _root_path :value: './.config' .. py:property:: helper :type: ABCProcessorHelper :abstractmethod: 处理器助手 .. py:property:: root_path :type: str 配置文件根目录 .. py:type:: AnyKey :canonical: ABCKey[Any, Any] .. versionadded:: 0.2.0 .. py:type:: PathLike :canonical: str | ABCPath[AnyKey] .. versionadded:: 0.2.0 .. py:type:: SLArgumentType :canonical: Sequence[Any] | Mapping[str, Any] | tuple[Sequence[Any], Mapping[str, Any]] | None .. versionchanged:: 0.3.0 重命名 ``SLArgument`` 为 ``SLArgumentType``