config.processor.cbor2

CBOR配置文件处理器

在 0.3.0 版本加入.

Classes

CBOR2SL

CBOR格式处理器

Module Contents

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

Bases: config.main.BasicLocalFileConfigSL

CBOR格式处理器

参数:
  • 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

load_file(source_file: IO[bytes], *merged_args: Any, **merged_kwargs: Any) config.basic.core.ConfigFile[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

save_file(config_file: config.abc.ABCConfigFile[Any], target_file: IO[bytes], *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
_loader_args: config.utils.FrozenArguments
_reg_alias: str | None = None
_s_open_kwargs
_saver_args: config.utils.FrozenArguments
create_dir = True
property loader_args: config.utils.FrozenArguments

加载器默认参数

property processor_reg_name: str

SL处理器的默认注册名

raises
property reg_alias: str | None

处理器的别名

property reg_name: str

处理器的注册名

property saver_args: config.utils.FrozenArguments

保存器默认参数

supported_file_classes
返回:

支持的配置文件类

在 0.2.0 版本加入.

property supported_file_patterns: tuple[str, Ellipsis]
返回:

支持的文件名匹配

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