In [45]:
from jsonschema import Draft4Validator,Draft3Validator
import json
In [196]:
with open("../project.test.001/desc.json","r") as json_data:
with open("../qresp_curation/schema/v1_0.json","r") as schema_data:
try:
coll_data=json.load(json_data)
except:
print("Invalid Json File")
try:
schema_coll_data = json.load(schema_data)
except:
print("Invalid Schema File")
#Draft4Validator(schema_coll_data).validate(coll_data)
a = Draft4Validator(schema_coll_data)
for error in sorted(a.iter_errors(coll_data), key=str):
try:
print(error.absolute_path[2],"is missing in",error.absolute_path[0],error.absolute_path[1])
except IndexError:
try:
print(error.message,"in",error.absolute_path[0],error.absolute_path[1])
except IndexError:
try:
print(error.message,"in",error.absolute_path[0])
except IndexError:
print(error.message)
In [2]:
"a"+"b"
Out[2]:
In [ ]: