config.processor.tarfile¶
Tar压缩配置文件处理器
在 0.2.0 版本加入.
Classes¶
压缩类型数据结构 |
|
压缩类型 |
|
tar格式处理器 |
Module Contents¶
- class TarCompressionTypes¶
Bases:
TarCompressionType,enum.ReprEnum压缩类型
- BZIP2 = ('bzip2', 'bz2')¶
- GZIP = ('gzip', 'gz')¶
- LZMA = ('lzma', 'xz')¶
- ONLY_STORAGE = ('only-storage', None)¶
- class TarFileSL(*, reg_alias: str | None = None, create_dir: bool = True, compression: TarCompressionTypes | str | None = TarCompressionTypes.ONLY_STORAGE, compress_level: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | int | None = None, extraction_filter: ExtractionFilter | None = 'data')¶
Bases:
config.main.BasicCompressedConfigSLtar格式处理器
- 参数:
reg_alias (str | None) -- sl处理器注册别名
create_dir (bool) -- 是否创建目录
compression (TarCompressionTypes | str | None) -- 压缩类型
compress_level (Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | int | None) -- 压缩等级
extraction_filter (ExtractionFilter | None) -- 解压过滤器
- 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处理器
- 默认实现:
遍历
BasicCompressedConfigSL如果为
str且file_name.endswith成立则返回移除后缀后的结果如果为
re.Pattern且Pattern.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) -- 配置文件名
- 返回:
配置对象
- 返回类型:
在 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) -- 配置文件名
- 返回:
配置对象
- 返回类型:
- 抛出:
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处理前没有清理已经缓存在配置池里的配置文件,返回的可能不是最新数据
- 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¶
保存指定命名空间的配置
- 参数:
config_pool (ABCConfigPool) -- 配置池
config_file (ABCConfigFile) -- 配置文件
namespace (str) -- 命名空间
file_name (str) -- 文件名
- __slots__ = ()¶
- _compression: TarCompressionType¶
- _short_name = ''¶
- create_dir = True¶
- raises¶
- supported_file_classes¶
- 返回:
支持的配置文件类
在 0.2.0 版本加入.