mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-07 22:59:56 -05:00
4e1dfc5194
By default, `validate` can print the entire schema upon error in some failure cases. Printing just the message instead is just as informative and reduces spam while debugging.
21 lines
516 B
Python
21 lines
516 B
Python
import json
|
|
import jsonschema
|
|
import os.path
|
|
import sys
|
|
|
|
|
|
with open(sys.argv[1], "r", encoding="utf-8-sig") as f:
|
|
contents = json.load(f)
|
|
|
|
schema_file = os.path.join(
|
|
os.path.dirname(__file__),
|
|
"..", "..", "..", "Help", "manual", "presets", "schema.json")
|
|
with open(schema_file, "r", encoding="utf-8") as f:
|
|
schema = json.load(f)
|
|
|
|
try:
|
|
jsonschema.validate(contents, schema)
|
|
except (jsonschema.ValidationError, jsonschema.SchemaError) as e:
|
|
sys.stderr.write(e.message)
|
|
sys.exit(1)
|