diff options
author | Erovia <Erovia@users.noreply.github.com> | 2022-02-28 20:02:39 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-28 20:02:39 +0000 |
commit | fbfd5312b995a32af690c183cad0dc988f695e89 (patch) | |
tree | bf241a475ec51b79d6427ac422f197b6d3720661 /lib/python/qmk/path.py | |
parent | 779c7debcfff1a4a3ad578a0c12bdd50cba11039 (diff) |
CLI: Validate JSON keymap input (#16261)
* Fix schema validator
It should use the passed schema.
* Add required attributes to keymap schema
* Rework subcommands to validate the JSON keymaps
The 'compile', 'flash' and 'json2c' subcommands were reworked to add
JSON keymap validation so error is reported for non-JSON and
non-compliant-JSON inputs.
* Fix required fields in keymap schema
* Add tests
* Fix compiling keymaps directly from keymap directory
* Schema should not require version for now.
Diffstat (limited to 'lib/python/qmk/path.py')
-rw-r--r-- | lib/python/qmk/path.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/python/qmk/path.py b/lib/python/qmk/path.py index dfb8371f84..9b94abbc12 100644 --- a/lib/python/qmk/path.py +++ b/lib/python/qmk/path.py @@ -70,9 +70,13 @@ def normpath(path): class FileType(argparse.FileType): + def __init__(self, encoding='UTF-8'): + # Use UTF8 by default for stdin + return super().__init__(encoding=encoding) + 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) + return norm if norm.exists() else super().__call__(string) |