From c67fcc7d406ab48b283f074db691aa47ffcb2f60 Mon Sep 17 00:00:00 2001 From: Benjamin Auquite Date: Sun, 18 Feb 2024 20:31:37 -0600 Subject: [PATCH] Update path.py --- Libraries/PyKotor/src/pykotor/tools/path.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Libraries/PyKotor/src/pykotor/tools/path.py b/Libraries/PyKotor/src/pykotor/tools/path.py index 1c84cf08b..98353cf57 100644 --- a/Libraries/PyKotor/src/pykotor/tools/path.py +++ b/Libraries/PyKotor/src/pykotor/tools/path.py @@ -66,6 +66,11 @@ def wrapped(self, *args, **kwargs) -> Any: - Return the result """ orig_fn = wrapped_class_type._original_methods[fn_name] # noqa: SLF001 + # Do not use. CaseAwarePath's performance depends on only resolving case when it absolutely has to. + #if fn_name == "__new__": + # path_obj = pathlib.Path(*args, **kwargs) + # if "called_from_getcase" not in kwargs and not path_obj.exists(): + # return CaseAwarePath.get_case_sensitive_path(path_obj) def parse_arg(arg: Any) -> CaseAwarePath | Any: if ( @@ -130,6 +135,7 @@ def create_case_insensitive_pathlib_class(cls: type): # TODO: move into CaseAwa "__fspath__", "__truediv__", "_init", + "__new__", "pathify", *cls_methods, } @@ -244,7 +250,7 @@ def get_case_sensitive_path(cls, path: PathElem, prefixes: list[str] | tuple[str break # return a CaseAwarePath instance - return cls._create_instance(*parts[num_differing_parts:]) + return cls._create_instance(*parts[num_differing_parts:], called_from_getcase=True) @classmethod def find_closest_match(cls, target: str, candidates: Generator[InternalPath, None, None]) -> str: