Coverage for sel_tools/file_export/export_item.py: 100%
14 statements
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-04 21:22 +0000
« prev ^ index » next coverage.py v7.6.4, created at 2024-11-04 21:22 +0000
1"""Copy files and folders and apply postprocessing on the targets."""
3from pathlib import Path
5from sel_tools.file_export.copy_item import copy_item
6from sel_tools.file_export.file_content_remover import SolutionsRemoverVisitor
7from sel_tools.file_export.formatter import FormatterVisitor
8from sel_tools.utils.files import FileTree
11def export_items(source: Path, repo_paths: list[Path], keep_solutions: bool) -> None:
12 """Export all files of source into every repo."""
13 for repo in repo_paths:
14 # TODO maybe we need to make the repo clean
15 copy_item(source, repo)
16 visit_exported_item(repo, keep_solutions)
19def visit_exported_item(output_dir: Path, keep_solutions: bool) -> None:
20 """Apply visitors on the file tree copied."""
21 output_file_tree = FileTree(output_dir)
22 if not keep_solutions:
23 output_file_tree.accept(SolutionsRemoverVisitor())
25 output_file_tree.accept(FormatterVisitor())