From 455bbf211cdb98a4f1cdd59ed6f19dd88391c749 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 7 May 2024 15:27:33 +0200 Subject: [PATCH] Enclose space part --- kiwixbuild/utils.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/kiwixbuild/utils.py b/kiwixbuild/utils.py index 30ae679..1cd4aea 100644 --- a/kiwixbuild/utils.py +++ b/kiwixbuild/utils.py @@ -39,12 +39,17 @@ def xrun_find(name): return output[:-1].decode() -regex_space = re.compile(r"((? str: + if " " in part: + return f"'{part}'" + return part def escape_path(path: Path): - path = str(path) - return regex_space.sub(r"\ ", path) + path = Path(path) + parts = [enclose(p) for p in path.parts] + path = Path(*parts) + return str(path) class Defaultdict(defaultdict): @@ -83,7 +88,7 @@ class PathArray(list): super().__init__(value.split(self.separator)) def __str__(self): - return self.separator.join((escape_path(str(v)) for v in self)) + return self.separator.join((escape_path(v) for v in self)) def remove_duplicates(iterable, key_function=None):