diff options
author | crupest <crupest@outlook.com> | 2024-11-11 01:12:29 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-01-20 23:41:34 +0800 |
commit | 8f4ce33d5d55401102d6ebb6d4d0d8b9136ee1ca (patch) | |
tree | 4ae61ce81e170c5208123d1b0a63bba20c6119f1 /tools/cru-py/cru/template.py | |
parent | a293e50247ff6e61cd730b6ef02c287d9264f17b (diff) | |
download | crupest-8f4ce33d5d55401102d6ebb6d4d0d8b9136ee1ca.tar.gz crupest-8f4ce33d5d55401102d6ebb6d4d0d8b9136ee1ca.tar.bz2 crupest-8f4ce33d5d55401102d6ebb6d4d0d8b9136ee1ca.zip |
HALF WORK: 2024.1.20 - 5
Diffstat (limited to 'tools/cru-py/cru/template.py')
-rw-r--r-- | tools/cru-py/cru/template.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/tools/cru-py/cru/template.py b/tools/cru-py/cru/template.py index 9f0b560..6749cab 100644 --- a/tools/cru-py/cru/template.py +++ b/tools/cru-py/cru/template.py @@ -4,7 +4,6 @@ import os.path from pathlib import Path from string import Template -from ._path import CruPath from ._iter import CruIterator from ._error import CruException @@ -82,7 +81,7 @@ class TemplateTree: wrongly handled. """ self._prefix = prefix - self._files: list[tuple[CruPath, CruTemplate]] = [] + self._files: list[tuple[Path, CruTemplate]] = [] self._source = source self._template_file_suffix = template_file_suffix self._load() @@ -92,7 +91,7 @@ class TemplateTree: return self._prefix @property - def templates(self) -> list[tuple[CruPath, CruTemplate]]: + def templates(self) -> list[tuple[Path, CruTemplate]]: return self._files @property @@ -104,13 +103,13 @@ class TemplateTree: return self._template_file_suffix @staticmethod - def _scan_files(root_path: str) -> list[CruPath]: - result: list[CruPath] = [] + def _scan_files(root_path: str) -> list[Path]: + result: list[Path] = [] for root, _dirs, files in os.walk(root_path): for file in files: path = Path(root, file) path = path.relative_to(root_path) - result.append(CruPath(path)) + result.append(Path(path)) return result def _load(self) -> None: @@ -141,7 +140,7 @@ class TemplateTree: self, destination: str, variables: Mapping[str, str], dry_run: bool ) -> None: for file, template in self.templates: - des = CruPath(destination) / file + des = Path(destination) / file if self.template_file_suffix is not None and des.name.endswith( self.template_file_suffix ): |