config.main

主要部分

Attributes

Classes

BasicChainConfigSL

基础连锁配置文件SL处理器

BasicCompressedConfigSL

基础压缩配置文件SL处理器

BasicConfigSL

基础配置SL管理器 提供了一些实用功能

BasicLocalFileConfigSL

基础本地配置文件SL处理器

ConfigPool

配置池

ConfigRequirementDecorator

配置获取器,可作装饰器使用

RequiredPath

对需求的键进行存在检查、类型检查、填充默认值

Functions

raises(→ collections.abc.Generator[None, Any, None])

包装意料内的异常

Module Contents

class BasicChainConfigSL(*, reg_alias: str | None = None, create_dir: bool = True)

Bases: BasicConfigSL, abc.ABC

基础连锁配置文件SL处理器

小心

会临时在配置文件池中添加文件以传递SL操作

在 0.2.0 版本加入.

参数:
  • reg_alias (Optional[str]) -- 处理器别名

  • create_dir (bool) -- 是否创建目录

__eq__(other: Any) bool
__hash__() int
after_save(config_pool: config.abc.ABCConfigPool, config_file: config.abc.ABCConfigFile[Any], file_path: str, root_path: str, namespace: str, file_name: str) None

保存后处理

参数:
  • config_pool (ABCConfigPool) -- 配置池

  • config_file (ABCConfigFile[Any]) -- 配置文件

  • file_path (str) -- 文件路径

  • root_path (str) -- 根路径

  • namespace (str) -- 命名空间

  • file_name (str) -- 文件名

before_load(config_pool: config.abc.ABCConfigPool, file_path: str, root_path: str, namespace: str, file_name: str) None

加载前处理

参数:
  • config_pool (ABCConfigPool) -- 配置池

  • file_path (str) -- 文件路径

  • root_path (str) -- 根路径

  • namespace (str) -- 命名空间

  • file_name (str) -- 文件名

filename_formatter(file_name: str) str

格式化文件名以传递给其他SL处理器

参数:

file_name (str) -- 配置文件名

返回:

格式化后的文件名

返回类型:

str

默认实现:
  • 遍历 BasicCompressedConfigSL

  • 如果为 strfile_name.endswith 成立则返回移除后缀后的结果

  • 如果为 re.PatternPattern.fullmatch(file_name) 成立则返回 Pattern.sub(file_name, "")

  • 直接返回

initialize(processor_pool: config.abc.ABCSLProcessorPool, root_path: str, namespace: str, file_name: str, *args: Any, **kwargs: Any) config.abc.ABCConfigFile[Any]

初始化一个受SL处理器支持的配置文件

参数:
  • processor_pool (ABCSLProcessorPool) -- 配置池

  • root_path (str) -- 保存的根目录

  • namespace (str) -- 配置的命名空间

  • file_name (str) -- 配置文件名

返回:

配置对象

返回类型:

ABCConfigFile

在 0.2.0 版本加入.

load(processor_pool: config.abc.ABCSLProcessorPool, root_path: str, namespace: str, file_name: str, *args: Any, **kwargs: Any) config.abc.ABCConfigFile[Any]

加载处理器

参数:
  • processor_pool (ABCSLProcessorPool) -- 配置池

  • root_path (str) -- 保存的根目录

  • namespace (str) -- 配置的命名空间

  • file_name (str) -- 配置文件名

返回:

配置对象

返回类型:

ABCConfigFile

抛出:

FailedProcessConfigFileError -- 处理配置文件失败

在 0.2.0 版本发生变更: 删除参数 config_file_cls

添加参数 processor_pool

load_file(config_pool: config.abc.ABCConfigPool, namespace: str, file_name: str, *args: Any, **kwargs: Any) config.abc.ABCConfigFile[Any]

加载指定命名空间的配置

参数:
  • config_pool (ABCConfigPool) -- 配置池

  • namespace (str) -- 命名空间

  • file_name (str) -- 文件名

返回:

配置文件

返回类型:

ABCConfigFile[Any]

小心

传递SL处理前没有清理已经缓存在配置池里的配置文件,返回的可能不是最新数据

namespace_formatter(namespace: str, file_name: str) str

格式化命名空间以传递给其他SL处理器

参数:
  • namespace (str) -- 配置的命名空间

  • file_name (str) -- 配置文件名

返回:

格式化后的命名空间

返回类型:

str

register_to(config_pool: config.abc.ABCSLProcessorPool | None = None) Self

注册到配置池中

参数:

config_pool (ABCSLProcessorPool | None) -- 配置池

返回:

返回当前实例便于链式调用

返回类型:

Self

在 0.3.0 版本发生变更: 返回当前实例便于链式调用

save(processor_pool: config.abc.ABCSLProcessorPool, config_file: config.abc.ABCConfigFile[Any], root_path: str, namespace: str, file_name: str, *args: Any, **kwargs: Any) None

保存处理器

参数:
  • processor_pool (ABCSLProcessorPool) -- 配置池

  • config_file (ABCConfigFile) -- 待保存配置

  • root_path (str) -- 保存的根目录

  • namespace (str) -- 配置的命名空间

  • file_name (str) -- 配置文件名

抛出:

FailedProcessConfigFileError -- 处理配置文件失败

在 0.2.0 版本发生变更: 添加参数 processor_pool

save_file(config_pool: config.abc.ABCConfigPool, config_file: config.abc.ABCConfigFile[Any], namespace: str, file_name: str, *args: Any, **kwargs: Any) None

保存指定命名空间的配置

参数:
__slots__ = ()
_cleanup_registry: bool = True

自动清理为了传递SL处理所加入配置池的配置文件

_reg_alias: str | None = None
create_dir = True
property processor_reg_name: str
Abstractmethod:

SL处理器的默认注册名

raises
property reg_alias: str | None

处理器的别名

property reg_name: str

处理器的注册名

property supported_file_classes: list[type[ABCConfigFile[Any]]]
Abstractmethod:

返回:

支持的配置文件类

在 0.2.0 版本加入.

property supported_file_patterns: tuple[str | re.Pattern[Any], Ellipsis]
Abstractmethod:

返回:

支持的文件名匹配

在 0.2.0 版本发生变更: 重命名 file_extsupported_file_patterns

class BasicCompressedConfigSL(*, reg_alias: str | None = None, create_dir: bool = True)

Bases: BasicCachedConfigSL, abc.ABC

基础压缩配置文件SL处理器

在 0.2.0 版本加入.

参数:
  • reg_alias (Optional[str]) -- 处理器别名

  • create_dir (bool) -- 是否创建目录

__eq__(other: Any) bool
__hash__() int
after_save(config_pool: config.abc.ABCConfigPool, config_file: config.abc.ABCConfigFile[Any], file_path: str, root_path: str, namespace: str, file_name: str) None

保存后处理

参数:
  • config_pool (ABCConfigPool) -- 配置池

  • config_file (ABCConfigFile[Any]) -- 配置文件

  • file_path (str) -- 文件路径

  • root_path (str) -- 根路径

  • namespace (str) -- 命名空间

  • file_name (str) -- 文件名

before_load(config_pool: config.abc.ABCConfigPool, file_path: str, root_path: str, namespace: str, file_name: str) None

加载前处理

参数:
  • config_pool (ABCConfigPool) -- 配置池

  • file_path (str) -- 文件路径

  • root_path (str) -- 根路径

  • namespace (str) -- 命名空间

  • file_name (str) -- 文件名

abstractmethod compress_file(file_path: str, extract_dir: str) None

压缩文件

参数:
  • file_path (str) -- 压缩文件路径

  • extract_dir (str) -- 解压目录

abstractmethod extract_file(file_path: str, extract_dir: str) None

解压文件

参数:
  • file_path (str) -- 压缩文件路径

  • extract_dir (str) -- 解压目录

filename_formatter(file_name: str) str

格式化文件名以传递给其他SL处理器

参数:

file_name (str) -- 配置文件名

返回:

格式化后的文件名

返回类型:

str

默认实现:
  • 遍历 BasicCompressedConfigSL

  • 如果为 strfile_name.endswith 成立则返回移除后缀后的结果

  • 如果为 re.PatternPattern.fullmatch(file_name) 成立则返回 Pattern.sub(file_name, "")

  • 直接返回

initialize(processor_pool: config.abc.ABCSLProcessorPool, root_path: str, namespace: str, file_name: str, *args: Any, **kwargs: Any) config.abc.ABCConfigFile[Any]

初始化一个受SL处理器支持的配置文件

参数:
  • processor_pool (ABCSLProcessorPool) -- 配置池

  • root_path (str) -- 保存的根目录

  • namespace (str) -- 配置的命名空间

  • file_name (str) -- 配置文件名

返回:

配置对象

返回类型:

ABCConfigFile

在 0.2.0 版本加入.

load(processor_pool: config.abc.ABCSLProcessorPool, root_path: str, namespace: str, file_name: str, *args: Any, **kwargs: Any) config.abc.ABCConfigFile[Any]

加载处理器

参数:
  • processor_pool (ABCSLProcessorPool) -- 配置池

  • root_path (str) -- 保存的根目录

  • namespace (str) -- 配置的命名空间

  • file_name (str) -- 配置文件名

返回:

配置对象

返回类型:

ABCConfigFile

抛出:

FailedProcessConfigFileError -- 处理配置文件失败

在 0.2.0 版本发生变更: 删除参数 config_file_cls

添加参数 processor_pool

load_file(config_pool: config.abc.ABCConfigPool, namespace: str, file_name: str, *args: Any, **kwargs: Any) config.abc.ABCConfigFile[Any]

加载指定命名空间的配置

参数:
  • config_pool (ABCConfigPool) -- 配置池

  • namespace (str) -- 命名空间

  • file_name (str) -- 文件名

返回:

配置文件

返回类型:

ABCConfigFile[Any]

小心

传递SL处理前没有清理已经缓存在配置池里的配置文件,返回的可能不是最新数据

namespace_formatter(namespace: str, file_name: str) str

格式化命名空间以传递给其他SL处理器

参数:
  • namespace (str) -- 配置的命名空间

  • file_name (str) -- 配置文件名

返回:

格式化后的命名空间

返回类型:

str

register_to(config_pool: config.abc.ABCSLProcessorPool | None = None) Self

注册到配置池中

参数:

config_pool (ABCSLProcessorPool | None) -- 配置池

返回:

返回当前实例便于链式调用

返回类型:

Self

在 0.3.0 版本发生变更: 返回当前实例便于链式调用

save(processor_pool: config.abc.ABCSLProcessorPool, config_file: config.abc.ABCConfigFile[Any], root_path: str, namespace: str, file_name: str, *args: Any, **kwargs: Any) None

保存处理器

参数:
  • processor_pool (ABCSLProcessorPool) -- 配置池

  • config_file (ABCConfigFile) -- 待保存配置

  • root_path (str) -- 保存的根目录

  • namespace (str) -- 配置的命名空间

  • file_name (str) -- 配置文件名

抛出:

FailedProcessConfigFileError -- 处理配置文件失败

在 0.2.0 版本发生变更: 添加参数 processor_pool

save_file(config_pool: config.abc.ABCConfigPool, config_file: config.abc.ABCConfigFile[Any], namespace: str, file_name: str, *args: Any, **kwargs: Any) None

保存指定命名空间的配置

参数:
__slots__ = ()
_cleanup_registry: bool = True

自动清理为了传递SL处理所加入配置池的配置文件

_reg_alias: str | None = None
create_dir = True
property namespace_suffix: str

命名空间后缀

property processor_reg_name: str
Abstractmethod:

SL处理器的默认注册名

raises
property reg_alias: str | None

处理器的别名

property reg_name: str

处理器的注册名

property supported_file_classes: list[type[ABCConfigFile[Any]]]
Abstractmethod:

返回:

支持的配置文件类

在 0.2.0 版本加入.

property supported_file_patterns: tuple[str | re.Pattern[Any], Ellipsis]
Abstractmethod:

返回:

支持的文件名匹配

在 0.2.0 版本发生变更: 重命名 file_extsupported_file_patterns

class BasicConfigSL(*, reg_alias: str | None = None)

Bases: config.abc.ABCConfigSL, abc.ABC

基础配置SL管理器 提供了一些实用功能

在 0.2.0 版本发生变更: 重命名 BaseConfigSLBasicConfigSL

参数:

reg_alias (Optional[str]) -- sl处理器注册别名

__eq__(other: Any) bool
__hash__() int
initialize(processor_pool: config.abc.ABCSLProcessorPool, root_path: str, namespace: str, file_name: str, *args: Any, **kwargs: Any) config.abc.ABCConfigFile[Any]

初始化一个受SL处理器支持的配置文件

参数:
  • processor_pool (ABCSLProcessorPool) -- 配置池

  • root_path (str) -- 保存的根目录

  • namespace (str) -- 配置的命名空间

  • file_name (str) -- 配置文件名

返回:

配置对象

返回类型:

ABCConfigFile

在 0.2.0 版本加入.

abstractmethod load(processor_pool: ABCSLProcessorPool, root_path: str, namespace: str, file_name: str, *args: Any, **kwargs: Any) ABCConfigFile[Any]

加载处理器

参数:
  • processor_pool (ABCSLProcessorPool) -- 配置池

  • root_path (str) -- 保存的根目录

  • namespace (str) -- 配置的命名空间

  • file_name (str) -- 配置文件名

返回:

配置对象

返回类型:

ABCConfigFile

抛出:

FailedProcessConfigFileError -- 处理配置文件失败

在 0.2.0 版本发生变更: 删除参数 config_file_cls

添加参数 processor_pool

register_to(config_pool: config.abc.ABCSLProcessorPool | None = None) Self

注册到配置池中

参数:

config_pool (ABCSLProcessorPool | None) -- 配置池

返回:

返回当前实例便于链式调用

返回类型:

Self

在 0.3.0 版本发生变更: 返回当前实例便于链式调用

abstractmethod save(processor_pool: ABCSLProcessorPool, config_file: ABCConfigFile[Any], root_path: str, namespace: str, file_name: str, *args: Any, **kwargs: Any) None

保存处理器

参数:
  • processor_pool (ABCSLProcessorPool) -- 配置池

  • config_file (ABCConfigFile) -- 待保存配置

  • root_path (str) -- 保存的根目录

  • namespace (str) -- 配置的命名空间

  • file_name (str) -- 配置文件名

抛出:

FailedProcessConfigFileError -- 处理配置文件失败

在 0.2.0 版本发生变更: 添加参数 processor_pool

__slots__ = ()
_reg_alias: str | None = None
property processor_reg_name: str
Abstractmethod:

SL处理器的默认注册名

property reg_alias: str | None

处理器的别名

property reg_name: str

处理器的注册名

property supported_file_classes: list[type[ABCConfigFile[Any]]]
Abstractmethod:

返回:

支持的配置文件类

在 0.2.0 版本加入.

property supported_file_patterns: tuple[str | re.Pattern[Any], Ellipsis]
Abstractmethod:

返回:

支持的文件名匹配

在 0.2.0 版本发生变更: 重命名 file_extsupported_file_patterns

class BasicLocalFileConfigSL(s_arg: config.abc.SLArgumentType = None, l_arg: config.abc.SLArgumentType = None, *, reg_alias: str | None = None, create_dir: bool = True)

Bases: BasicConfigSL, abc.ABC

基础本地配置文件SL处理器

在 0.2.0 版本发生变更: 重命名从 BaseLocalFileConfigSLBasicLocalFileConfigSL

参数:
  • s_arg (SLArgumentType) -- 保存器默认参数

  • l_arg (SLArgumentType) -- 加载器默认参数

  • reg_alias (Optional[str]) -- sl处理器注册别名

  • create_dir (bool) -- 是否允许创建目录

在 0.2.0 版本发生变更: 保存加载器参数 相关从 BasicConfigSL 移动到此类

__eq__(other: Any) bool
__hash__() int
initialize(processor_pool: config.abc.ABCSLProcessorPool, root_path: str, namespace: str, file_name: str, *args: Any, **kwargs: Any) config.abc.ABCConfigFile[Any]

初始化一个受SL处理器支持的配置文件

参数:
  • processor_pool (ABCSLProcessorPool) -- 配置池

  • root_path (str) -- 保存的根目录

  • namespace (str) -- 配置的命名空间

  • file_name (str) -- 配置文件名

返回:

配置对象

返回类型:

ABCConfigFile

在 0.2.0 版本加入.

load(processor_pool: config.abc.ABCSLProcessorPool, root_path: str, namespace: str, file_name: str, *args: Any, **kwargs: Any) config.abc.ABCConfigFile[Any]

加载处理器

参数:
  • processor_pool (ABCSLProcessorPool) -- 配置池

  • root_path (str) -- 保存的根目录

  • namespace (str) -- 配置的命名空间

  • file_name (str) -- 配置文件名

返回:

配置对象

返回类型:

ABCConfigFile

抛出:

FailedProcessConfigFileError -- 处理配置文件失败

在 0.2.0 版本发生变更: 现在操作是原子的(操作过程发生异常会回滚操作)

现在操作是理论上是多线/进程安全的

删除参数 config_file_cls

添加参数 processor_pool

abstractmethod load_file(source_file: Any, *merged_args: Any, **merged_kwargs: Any) config.abc.ABCConfigFile[Any]

从文件加载配置

参数:
  • source_file (Any) -- 源文件对象

  • merged_args -- 合并后的位置参数

  • merged_kwargs -- 合并后的关键字参数

返回:

本地配置文件对象

返回类型:

ABCConfigFile

抛出:

FailedProcessConfigFileError -- 处理配置文件失败

在 0.2.0 版本发生变更: 删除参数 config_file_cls

更改 source_file 参数类型为 Any

register_to(config_pool: config.abc.ABCSLProcessorPool | None = None) Self

注册到配置池中

参数:

config_pool (ABCSLProcessorPool | None) -- 配置池

返回:

返回当前实例便于链式调用

返回类型:

Self

在 0.3.0 版本发生变更: 返回当前实例便于链式调用

save(processor_pool: config.abc.ABCSLProcessorPool, config_file: config.abc.ABCConfigFile[Any], root_path: str, namespace: str, file_name: str, *args: Any, **kwargs: Any) None

保存处理器 (原子操作 多线/进程安全)

参数:
  • processor_pool (ABCSLProcessorPool) -- 配置池

  • config_file (ABCConfigFile) -- 待保存配置

  • root_path (str) -- 保存的根目录

  • namespace (str) -- 配置的命名空间

  • file_name (str) -- 配置文件名

抛出:

FailedProcessConfigFileError -- 处理配置文件失败

在 0.2.0 版本发生变更: 现在操作是原子的(操作过程发生异常会回滚操作)

现在操作是理论上是多线/进程安全的

添加参数 processor_pool

abstractmethod save_file(config_file: config.abc.ABCConfigFile[Any], target_file: Any, *merged_args: Any, **merged_kwargs: Any) None

将配置保存到文件

参数:
  • config_file (ABCConfigFile) -- 配置文件

  • target_file (Any) -- 目标文件对象

  • merged_args -- 合并后的位置参数

  • merged_kwargs -- 合并后的关键字参数

抛出:

FailedProcessConfigFileError -- 处理配置文件失败

在 0.2.0 版本发生变更: 更改 target_file 参数类型为 Any

__slots__ = ()
_l_open_kwargs: dict[str, Any]
_loader_args: config.utils.FrozenArguments
_reg_alias: str | None = None
_s_open_kwargs: dict[str, Any]
_saver_args: config.utils.FrozenArguments
create_dir = True
property loader_args: config.utils.FrozenArguments

加载器默认参数

property processor_reg_name: str
Abstractmethod:

SL处理器的默认注册名

raises
property reg_alias: str | None

处理器的别名

property reg_name: str

处理器的注册名

property saver_args: config.utils.FrozenArguments

保存器默认参数

property supported_file_classes: list[type[ABCConfigFile[Any]]]
Abstractmethod:

返回:

支持的配置文件类

在 0.2.0 版本加入.

property supported_file_patterns: tuple[str | re.Pattern[Any], Ellipsis]
Abstractmethod:

返回:

支持的文件名匹配

在 0.2.0 版本发生变更: 重命名 file_extsupported_file_patterns

class ConfigPool

Bases: config.basic.core.BasicConfigPool

配置池

require(namespace: str, file_name: str, validator: Any, validator_factory: Any = ValidatorTypes.DEFAULT, static_config: Any | None = None, **kwargs: Any) ConfigRequirementDecorator

获取配置

参数:
返回:

详见 ConfigRequirementDecorator

返回类型:

ConfigRequirementDecorator

在 0.2.0 版本发生变更: 删除声明于 ABCConfigPool

class ConfigRequirementDecorator(config_pool: config.abc.ABCConfigPool, namespace: str, file_name: str, required: RequiredPath[Any, ConfigRequirementDecorator.__init__.D], *, validate_only: bool = True, config_formats: str | collections.abc.Iterable[str] | None = None, allow_initialize: bool = True, config_cacher: collections.abc.Callable[[collections.abc.Callable[Ellipsis, ConfigRequirementDecorator.__init__.D], VarArg(), KwArg()], ConfigRequirementDecorator.__init__.D] | None = None, filter_kwargs: dict[str, Any] | None = None)

配置获取器,可作装饰器使用

在 0.2.0 版本发生变更: 重命名 RequireConfigDecoratorConfigRequirementDecorator

在 0.3.0 版本发生变更: 修正配置加载逻辑,现在会在每一次获取配置数据时尝试加载而不是仅在初始化时尝试加载

参数:
  • config_pool (ConfigPool) -- 所在的配置池

  • namespace -- 详见 ConfigPool.load()

  • file_name -- 详见 ConfigPool.load()

  • required (RequiredPath[Any, D]) -- 需求的键

  • validate_only (bool) -- 如果为 True 则返回配置池中完整的配置数据(按引用传递),否则返回验证后的数据(按值传递), 此选项有助于避免意外修改配置池中的数据

  • config_formats -- 详见 ConfigPool.load()

  • allow_initialize -- 详见 ConfigPool.load()

  • config_cacher (Callable[[Callable[..., D], VarArg(), KwArg()], D] | None) -- 缓存配置的装饰器,默认为None,即不缓存

  • filter_kwargs (dict[str, Any] | None) -- RequiredPath.filter() 要绑定的默认参数,这会导致 static_config 失效

抛出:

UnsupportedConfigFormatError -- 不支持的配置格式

在 0.2.0 版本发生变更: 重命名参数 cache_configconfig_cacher

重命名参数 allow_createallow_initialize

在 0.3.0 版本加入: 添加参数 validate_only

__call__(func: collections.abc.Callable[[config.abc.ABCConfigData, Any], Any]) collections.abc.Callable[Ellipsis, Any]

通过装饰器提供配置数据注入,配置数据将会注入到 self (如果为方法而不是函数)后的第一个参数

参数:

func (Callable[[ABCConfigData, Any], Any]) -- 需要装饰的函数

返回:

装饰后的函数

返回类型:

Callable[..., Any]

_wrapped_filter(**kwargs: Any) config.abc.ABCConfigData
check(*, ignore_cache: bool = False, **filter_kwargs: Any) Any

手动检查配置

参数:
  • ignore_cache (bool) -- 是否忽略缓存

  • filter_kwargs -- RequiredConfig.filter的参数

返回:

得到的配置数据

返回类型:

Any

_config_cacher: collections.abc.Callable[[collections.abc.Callable[Ellipsis, ConfigRequirementDecorator.__init__.D], VarArg(), KwArg()], ConfigRequirementDecorator.__init__.D]
_config_loader: collections.abc.Callable[[], config.abc.ABCConfigFile[ConfigRequirementDecorator.__init__.D]]
_filter_kwargs = None
_required
_validate_only = True
class RequiredPath(validator: V, validator_factory: ValidatorFactoryType[V, D] | config.validators.ValidatorTypes | 'custom' | 'pydantic' | 'component' | None = ValidatorTypes.DEFAULT, static_config: config.validators.ValidatorOptions | None = None)

对需求的键进行存在检查、类型检查、填充默认值

参数:
  • validator (Any) -- 数据验证器

  • validator_factory (ValidatorFactoryType[V, D] | validators.ValidatorTypes | Literal["custom", "pydantic", "component"] | None) -- 数据验证器工厂

  • static_config (ValidatorOptions | None) -- 静态配置

小技巧

提供 static_config 参数可以避免在 filter() 中反复调用 validator_factory 以提高性能 ( filter() 未传入验证器选项参数时优化生效,如果传入了则回退到默认行为)

filter(data: D | config.utils.Ref[D], *, allow_modify: bool | None = None, skip_missing: bool | None = None, **extra: Any) D

检查过滤需求的键

参数:
  • data (D | Ref[D]) -- 要过滤的原始数据

  • allow_modify (bool | None) -- 是否允许值不存在时修改 data 参数对象填充默认值(即使为False仍然会在结果中填充默认值,但不会修改 data 参数对象)

  • skip_missing (bool | None) -- 忽略丢失的键

  • extra (Any) -- 额外参数

返回:

处理后的配置数据*快照*

返回类型:

D

抛出:

注意

返回的配置数据是 *快照*

小心

提供了任意配置参数(allow_modify, skip_missing, ...)时,这次调用将完全舍弃 static_config 使用当前提供的配置参数

这会导致调用 validator_factory 产生额外开销(如果你提供 static_config 参数是为了避免反复调用 validator_factory 的话)

在 0.2.0 版本发生变更: 重命名参数 ignore_missingskip_missing

data 参数支持 Ref

ValidatorFactories: ClassVar[dict[config.validators.ValidatorTypes, ValidatorFactoryType[Any, Any]]]

验证器工厂注册表

在 0.2.0 版本发生变更: 现在待验证的配置数据必须由 Ref 包装后传入

_validator
_validator_factory: ValidatorFactoryType[V, D]
raises(excs: type[Exception] | tuple[type[Exception], Ellipsis] = Exception) collections.abc.Generator[None, Any, None]

包装意料内的异常

提供给子类的便捷方法

参数:

excs (type[Exception] | tuple[type[Exception], ...]) -- 意料内的异常

抛出:

FailedProcessConfigFileError -- 当触发了对应的异常时

在 0.1.4 版本加入.

在 0.2.0 版本发生变更: 提取为函数

DefaultConfigPool

默认配置池

get

DefaultConfigPool . get()

load

DefaultConfigPool . load()

requireConfig

DefaultConfigPool . require()

save

DefaultConfigPool . save()

saveAll

DefaultConfigPool . save_all()

set_

DefaultConfigPool . set()