diff options
author | QMK Bot <hello@qmk.fm> | 2021-02-07 21:03:27 +0000 |
---|---|---|
committer | QMK Bot <hello@qmk.fm> | 2021-02-07 21:03:27 +0000 |
commit | d9dea7c4ec9513f07779094a900702bd0da31c30 (patch) | |
tree | 4bef40ca3409291e2ffc34248d13ac9c22278975 /lib/python/qmk/path.py | |
parent | 0e59827023859a428be789a11036d68bd6eda2bd (diff) | |
parent | ccc9c43161282bd6f37813cc85c13da1eb51b88d (diff) |
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'lib/python/qmk/path.py')
-rw-r--r-- | lib/python/qmk/path.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/python/qmk/path.py b/lib/python/qmk/path.py index 54def1d5d6..2aa1916f55 100644 --- a/lib/python/qmk/path.py +++ b/lib/python/qmk/path.py @@ -2,6 +2,7 @@ """ import logging import os +import argparse from pathlib import Path from qmk.constants import MAX_KEYBOARD_SUBFOLDERS, QMK_FIRMWARE @@ -65,3 +66,12 @@ def normpath(path): return path return Path(os.environ['ORIG_CWD']) / path + + +class FileType(argparse.FileType): + def __call__(self, string): + """normalize and check exists + otherwise magic strings like '-' for stdin resolve to bad paths + """ + norm = normpath(string) + return super().__call__(norm if norm.exists() else string) |