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:
parent
fc29c7a589
commit
ccc9c43161
4 changed files with 16 additions and 20 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue