diff options
author | Joel Challis <[email protected]> | 2021-02-07 21:02:51 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-02-07 21:02:51 +0000 |
commit | ccc9c43161282bd6f37813cc85c13da1eb51b88d (patch) | |
tree | 92fc97bb2489ba92e2ab95597e4e88c7fcd8bbb9 /lib/python/qmk/path.py | |
parent | fc29c7a589837c2d1e4173d59d2849f89d3cb72b (diff) | |
download | qmk_firmware-ccc9c43161282bd6f37813cc85c13da1eb51b88d.tar.gz qmk_firmware-ccc9c43161282bd6f37813cc85c13da1eb51b88d.zip |
Allow flash/compile to accept relative json paths (#11767)
* Allow flash/compile to accept relative paths
* Review suggestions
* Review comments
* Put back exists check otherwise stdin fails
* fix lint
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) |