Skip to content

Commit

Permalink
Update path.py
Browse files Browse the repository at this point in the history
  • Loading branch information
th3w1zard1 committed Feb 19, 2024
1 parent 1b64422 commit c67fcc7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Libraries/PyKotor/src/pykotor/tools/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -130,6 +135,7 @@ def create_case_insensitive_pathlib_class(cls: type): # TODO: move into CaseAwa
"__fspath__",
"__truediv__",
"_init",
"__new__",
"pathify",
*cls_methods,
}
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit c67fcc7

Please sign in to comment.