summaryrefslogtreecommitdiffstats
path: root/lib/python/qmk/json_schema.py
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2022-02-28 20:03:22 +0000
committerQMK Bot <hello@qmk.fm>2022-02-28 20:03:22 +0000
commit36e47cb3aaa6380764ab23e2b0308bf689156aa7 (patch)
treef762d5f9f497432cb4dca6fa016c254f1065de9b /lib/python/qmk/json_schema.py
parent3c7c9bdd8614cd332b4db7ab6d05429d513ba11d (diff)
parentfbfd5312b995a32af690c183cad0dc988f695e89 (diff)
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'lib/python/qmk/json_schema.py')
-rw-r--r--lib/python/qmk/json_schema.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/python/qmk/json_schema.py b/lib/python/qmk/json_schema.py
index ffc7c6bcd1..2b48782fbb 100644
--- a/lib/python/qmk/json_schema.py
+++ b/lib/python/qmk/json_schema.py
@@ -16,7 +16,11 @@ def json_load(json_file):
Note: file must be a Path object.
"""
try:
- return hjson.load(json_file.open(encoding='utf-8'))
+ # Get the IO Stream for Path objects
+ # Not necessary if the data is provided via stdin
+ if isinstance(json_file, Path):
+ json_file = json_file.open(encoding='utf-8')
+ return hjson.load(json_file)
except (json.decoder.JSONDecodeError, hjson.HjsonDecodeError) as e:
cli.log.error('Invalid JSON encountered attempting to load {fg_cyan}%s{fg_reset}:\n\t{fg_red}%s', json_file, e)
@@ -62,7 +66,7 @@ def create_validator(schema):
"""Creates a validator for the given schema id.
"""
schema_store = compile_schema_store()
- resolver = jsonschema.RefResolver.from_schema(schema_store['qmk.keyboard.v1'], store=schema_store)
+ resolver = jsonschema.RefResolver.from_schema(schema_store[schema], store=schema_store)
return jsonschema.Draft7Validator(schema_store[schema], resolver=resolver).validate