summaryrefslogtreecommitdiff
path: root/lib/python/qmk/path.py
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2021-02-07 21:03:27 +0000
committerQMK Bot <hello@qmk.fm>2021-02-07 21:03:27 +0000
commitd9dea7c4ec9513f07779094a900702bd0da31c30 (patch)
tree4bef40ca3409291e2ffc34248d13ac9c22278975 /lib/python/qmk/path.py
parent0e59827023859a428be789a11036d68bd6eda2bd (diff)
parentccc9c43161282bd6f37813cc85c13da1eb51b88d (diff)
downloadqmk_firmware-d9dea7c4ec9513f07779094a900702bd0da31c30.tar.gz
qmk_firmware-d9dea7c4ec9513f07779094a900702bd0da31c30.zip
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'lib/python/qmk/path.py')
-rw-r--r--lib/python/qmk/path.py10
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)