mirror of
https://github.com/EDCD/EDDN.git
synced 2025-04-12 07:00:04 +03:00
* It's using `sys.argv`, not `argparse`. * Thus there's no `--help`. * Supply it with: 1) Filename of a schema definition, 2) filename of a full EDDN message text to test for compliance. * No output if both schema and message load *and* the message passes the schema. Else you'll get python exception output from `jsonschema.validate()`.
18 lines
425 B
Python
18 lines
425 B
Python
import sys
|
|
|
|
import simplejson
|
|
import jsonschema
|
|
|
|
schema_filename = sys.argv[1]
|
|
message_filename = sys.argv[2]
|
|
|
|
schema_file = open(schema_filename, 'r')
|
|
schema_data = schema_file.read()
|
|
schema = simplejson.loads(schema_data)
|
|
|
|
message_file = open(message_filename, 'r')
|
|
message_data = message_file.read()
|
|
message = simplejson.loads(message_data)
|
|
|
|
jsonschema.validate(message, schema, format_checker=jsonschema.FormatChecker())
|