Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
jschema_play
from jsonschema import validate
schema = {
"definitions": {
"data_key": {
"properties": {
"external": {
"type": "string",
"pattern": "^[A-Z]+:?"
},
"source": {
"type": "string",
"pattern": "^[A-Z]+:"
}
},
"required": [
"source"
],
"type": "object"
}
},
"properties": {
"keys": {
"additionalProperties": {
"$ref": "#/definitions/data_key"
},
"type": "object"
},
"uuid": {
"type": "string"
}
},
"type": "object"
}
test = {
"uid": '789',
"keys": {
"chan1": {"source": "PV:XF:23ID1-ES{Sclr:1}.S1"},
"chan2": {"source": "PV:XF:23ID1-ES{Sclr:1}.S2"},
"chan3": {"source": "PV:XF:23ID1-ES{Sclr:1}.S3"},
"chan4": {"source": "PV:XF:23ID1-ES{Sclr:1}.S4"},
"chan5": {"source": "PV:XF:23ID1-ES{Sclr:1}.S5"},
"chan6": {"source": "PV:XF:23ID1-ES{Sclr:1}.S6"},
"chan7": {"source": "PV:XF:23ID1-ES{Sclr:1}.S7"},
"chan8": {"source": "PV:XF:23ID1-ES{Sclr:1}.S8"},
"pimte": {"source": "CCD:name_of_detector", "external": "FILESTORE"},
},
"begin_run_event": '789',
"time": 789.456,
}
validate(test, schema)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment