Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
th3w1zard1 committed Feb 19, 2024
1 parent abd5b49 commit b864635
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Libraries/PyKotor/src/pykotor/tools/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,14 @@ def wrapped(self, *args, **kwargs) -> Any:
orig_fn = wrapped_class_type._original_methods[fn_name] # noqa: SLF001

def parse_arg(arg: Any) -> CaseAwarePath | Any:
if arg is CaseAwarePath:
return CaseAwarePath
if arg.__class__ is CaseAwarePath:
return arg if pathlib.Path(arg).exists() else CaseAwarePath.get_case_sensitive_path(arg)
if not hasattr(arg, "__bases__") and arg.__class__ in CaseAwarePath.__base__.__bases__ and pathlib.Path.exists(arg):
if (
not hasattr(arg, "__bases__")
and (
arg.__class__ in {*CaseAwarePath.__bases__, CaseAwarePath}
or CaseAwarePath in {*arg.__class__.__bases__, arg.__class__}
)
and not pathlib.Path(arg).exists()
):
return CaseAwarePath.get_case_sensitive_path(arg)
return arg

Expand Down

0 comments on commit b864635

Please sign in to comment.