validate_resources module

资源完整性验证工具 检查 Excel 中引用的资源文件是否存在

class validate_resources.ResourceValidator(config: AppConfig, translator: ParamTranslator)[源代码]

基类:object

资源验证器

check_resources_exist(resources: Dict[str, Set[str]], project_dirs: Dict[str, Path]) Dict[str, Dict[str, bool]][源代码]

检查资源文件是否存在

参数:
  • resources -- 资源类型到文件名集合的映射

  • project_dirs -- 资源类型到项目目录的映射

返回:

资源类型 -> 文件名 -> 是否存在

返回类型:

Dict[str, Dict[str, bool]]

collect_resources_from_excel(excel_path: Path) Dict[str, Set[str]][源代码]

从 Excel 文件中收集所有引用的资源

参数:

excel_path -- Excel 文件路径

返回:

资源类型到文件名集合的映射

返回类型:

Dict[str, Set[str]]

generate_report(excel_path: Path, resources: Dict[str, Set[str]], check_results: Dict[str, Dict[str, bool]]) Tuple[str, Dict][源代码]

生成验证报告

参数:
  • excel_path -- Excel 文件路径

  • resources -- 收集的资源

  • check_results -- 检查结果

返回:

(报告文本, 统计信息)

返回类型:

Tuple[str, Dict]

validate_resources.main()[源代码]

主函数

validate_resources.validate_excel_file(excel_path: Path, config: AppConfig, project_dirs: Dict[str, Path])[源代码]

验证单个 Excel 文件的资源完整性

参数:
  • excel_path -- Excel 文件路径

  • config -- 应用配置

  • project_dirs -- 项目资源目录配置