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
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user