aboutsummaryrefslogtreecommitdiff
path: root/lib/python/qmk/path.py
diff options
context:
space:
mode:
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 54def1d5d..2aa1916f5 100644
--- a/lib/python/qmk/path.py
+++ b/lib/python/qmk/path.py
@@ -2,6 +2,7 @@
2""" 2"""
3import logging 3import logging
4import os 4import os
5import argparse
5from pathlib import Path 6from pathlib import Path
6 7
7from qmk.constants import MAX_KEYBOARD_SUBFOLDERS, QMK_FIRMWARE 8from qmk.constants import MAX_KEYBOARD_SUBFOLDERS, QMK_FIRMWARE
@@ -65,3 +66,12 @@ def normpath(path):
65 return path 66 return path
66 67
67 return Path(os.environ['ORIG_CWD']) / path 68 return Path(os.environ['ORIG_CWD']) / path
69
70
71class FileType(argparse.FileType):
72 def __call__(self, string):
73 """normalize and check exists
74 otherwise magic strings like '-' for stdin resolve to bad paths
75 """
76 norm = normpath(string)
77 return super().__call__(norm if norm.exists() else string)