diff options
Diffstat (limited to 'lib/python')
| -rw-r--r-- | lib/python/qmk/path.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/python/qmk/path.py b/lib/python/qmk/path.py index 1739689adf..3b8bafbd4e 100644 --- a/lib/python/qmk/path.py +++ b/lib/python/qmk/path.py @@ -177,5 +177,17 @@ class FileType(argparse.FileType): """normalize and check exists otherwise magic strings like '-' for stdin resolve to bad paths """ + # TODO: This should not return both Path and TextIOWrapper as consumers + # assume that they can call Path.as_posix without checking type + + # Handle absolute paths and relative paths to CWD norm = normpath(string) - return norm if norm.exists() else super().__call__(string) + if norm.exists(): + return norm + + # Handle relative paths to QMK_HOME + relative = Path(string) + if relative.exists(): + return relative + + return super().__call__(string) |