diff options
author | crupest <crupest@outlook.com> | 2024-11-11 01:12:29 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-01-09 18:01:15 +0800 |
commit | 47ebda69daa34ea7992b6bbadf46de98dd17a390 (patch) | |
tree | 8d169d75c9bd9a48f47383f245e371e57ea2eb8f /tools/cru-py/cru/template.py | |
parent | 43892b892cfdc4e15f7ab191c42ccb32279fd7f6 (diff) | |
download | crupest-47ebda69daa34ea7992b6bbadf46de98dd17a390.tar.gz crupest-47ebda69daa34ea7992b6bbadf46de98dd17a390.tar.bz2 crupest-47ebda69daa34ea7992b6bbadf46de98dd17a390.zip |
HALF WORK: 2024.1.9
Diffstat (limited to 'tools/cru-py/cru/template.py')
-rw-r--r-- | tools/cru-py/cru/template.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/cru-py/cru/template.py b/tools/cru-py/cru/template.py index a02ea0e..a07ca23 100644 --- a/tools/cru-py/cru/template.py +++ b/tools/cru-py/cru/template.py @@ -1,6 +1,7 @@ from collections.abc import Mapping import os import os.path +from pathlib import Path from string import Template from ._iter import CruIterator @@ -99,13 +100,13 @@ class TemplateTree: @staticmethod def _scan_files(root_path: str) -> list[str]: - files: list[str] = [] + result: list[str] = [] for root, _dirs, files in os.walk(root_path): for file in files: - path = os.path.join(root, file) - path = os.path.relpath(path, root_path) - files.append(path) - return files + path = Path(root, file) + path = path.relative_to(root_path) + result.append(str(path.as_posix())) + return result def _load(self) -> None: files = self._scan_files(self.source) |