2016-12-29 23:27:33 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
import json, sys, glob
|
|
|
|
from os import path
|
|
|
|
from jsonschema import Draft3Validator
|
|
|
|
|
|
|
|
print('-- validate json file')
|
|
|
|
|
|
|
|
jsonFileName = sys.argv[1]
|
|
|
|
schemaFileName = sys.argv[2]
|
|
|
|
|
|
|
|
try:
|
|
|
|
with open(schemaFileName) as schemaFile:
|
|
|
|
with open(jsonFileName) as jsonFile:
|
2017-02-16 07:33:58 +01:00
|
|
|
j = json.loads(jsonFile.read())
|
|
|
|
validator = Draft3Validator(json.loads(schemaFile.read()))
|
2016-12-29 23:27:33 +01:00
|
|
|
validator.validate(j)
|
2017-02-09 20:10:57 +01:00
|
|
|
except Exception as e:
|
2016-12-29 23:27:33 +01:00
|
|
|
print('validation error: '+jsonFileName + ' '+schemaFileName+' ('+str(e)+')')
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
sys.exit(0)
|