sync_resources module
资源同步工具 从资源库同步缺失的资源到项目库
- class sync_resources.ResourceSyncer(config: AppConfig, project_dirs: Dict[str, Path], source_dirs: Dict[str, Path])[源代码]
基类:
object资源同步器
- create_sync_plan(missing_files: Dict[str, Set[str]]) Tuple[Dict[str, List[Tuple[Path, Path]]], Dict[str, Set[str]]][源代码]
创建同步计划
- 参数:
missing_files -- 缺失文件字典
- 返回:
- (同步计划, 未找到的文件)
同步计划: 资源类型 -> [(源路径, 目标路径)]
未找到: 资源类型 -> {文件名}
- 返回类型:
Tuple[Dict, Dict]
- execute_sync(sync_plan: Dict[str, List[Tuple[Path, Path]]], dry_run: bool = False) Dict[str, int][源代码]
执行同步
- 参数:
sync_plan -- 同步计划
dry_run -- 是否为干跑模式
- 返回:
统计信息
- 返回类型:
Dict[str, int]
- find_in_source_library(resource_type: str, filename: str) Path | None[源代码]
在资源库中查找文件
- 参数:
resource_type -- 资源类型
filename -- 文件名(不含扩展名)
- 返回:
找到的文件路径,未找到返回 None
- 返回类型:
Optional[Path]