fix: Better validation for taxonomy files
parent
c7a13ea0bc
commit
ac93571dbc
|
@ -0,0 +1,18 @@
|
|||
import sys
|
||||
import glob
|
||||
import json
|
||||
from jsonschema import validate
|
||||
|
||||
schema = json.load(open("schema.json", "r"))
|
||||
|
||||
for taxonomy_file in glob.glob('./*/machinetag.json'):
|
||||
print("Checking {}".format(taxonomy_file))
|
||||
taxonomy = json.load(open(taxonomy_file, "r"))
|
||||
validate(instance=taxonomy, schema=schema)
|
||||
|
||||
if "values" in taxonomy:
|
||||
predicates = [predicate["value"] for predicate in taxonomy["predicates"]]
|
||||
for value in taxonomy["values"]:
|
||||
if value["predicate"] not in predicates:
|
||||
print("ERROR: Predicate `{}` is missing".format(value["predicate"]))
|
||||
sys.exit(1)
|
|
@ -20,11 +20,6 @@ if ! [ $((directories-2)) -eq $manifest_entries ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
for dir in */machinetag.json
|
||||
do
|
||||
echo -n "${dir}: "
|
||||
jsonschema -i ${dir} schema.json
|
||||
echo ''
|
||||
done
|
||||
python3 validate_all.py
|
||||
|
||||
jsonschema -i mapping/mapping.json schema_mapping.json
|
||||
|
|
Loading…
Reference in New Issue