Skip to content

Commit

Permalink
expanduser for all relative paths to simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
martclanor committed Jan 9, 2025
1 parent 86be08a commit 391c4d8
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions flopy/mbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,12 @@ def _resolve(exe_name, checked=set()):
if exe := which(str(exe_name)):
return which(str(Path(exe).resolve()))

# exe_name has "~", expand first before returning absolute path
if "~" in exe_name and (
exe := which(str(Path(exe_name).expanduser().resolve()))
):
return exe

# exe_name is relative path
if not Path(exe_name).is_absolute() and (
exe := which(str(Path(exe_name).resolve()), mode=0)
): # mode=0 effectively allows which() to find exe without suffix in windows
exe := which(str(Path(exe_name).expanduser().resolve()), mode=0)
):
# expanduser() in case of ~ in path
# mode=0 effectively allows which() to find exe without suffix in windows
return exe

# try adding/removing .exe suffix
Expand Down

0 comments on commit 391c4d8

Please sign in to comment.