1
0
Fork 0

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:
Joel Challis 2021-02-07 21:02:51 +00:00 committed by GitHub
parent fc29c7a589
commit ccc9c43161
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 20 deletions

View file

@ -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)