From 17d1d5463711eb7d06978a4dd969b61190c1f49c Mon Sep 17 00:00:00 2001 From: "Marcel M. Otte" Date: Fri, 16 Sep 2016 19:25:02 +0200 Subject: [PATCH] began working with python Rx schema validation, instead of kwalify. Also added pycharm project files for ease of use. --- .idea/misc.xml | 14 ++ .idea/modules.xml | 8 + .idea/npd.iml | 11 ++ .idea/vcs.xml | 6 + .idea/workspace.xml | 390 ++++++++++++++++++++++++++++++++++++++++++++ schema.yml | 25 +++ validate.py | 19 +++ 7 files changed, 473 insertions(+) create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/npd.iml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 schema.yml create mode 100644 validate.py diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d8a4a57 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..2d26c74 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/npd.iml b/.idea/npd.iml new file mode 100644 index 0000000..6711606 --- /dev/null +++ b/.idea/npd.iml @@ -0,0 +1,11 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..3e79ea0 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,390 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1474023323997 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/schema.yml b/schema.yml new file mode 100644 index 0000000..ef24994 --- /dev/null +++ b/schema.yml @@ -0,0 +1,25 @@ +type: //rec +required: + protocol: + type: //rec + required: + name: //str + longname: //str + osilayer: //int + fields: &fields + type: //arr + contents: { + type: //rec + required: + field: //str + desc: //str + length: //int + optional: + bitfield: //bool + optional: //bool + nextlayer: //bool + data: //bool + reference: //str + reflenght: //str + subfields: *fields + } diff --git a/validate.py b/validate.py new file mode 100644 index 0000000..b9de05e --- /dev/null +++ b/validate.py @@ -0,0 +1,19 @@ +import Rx +import sys + + +def validate(argv): + rx = Rx.Factory(register_core_types=True) + schemafile = "schema.yaml" + schema = None + data = None + with open(schemafile, "r") as f: + data = f.read() + schema = rx.make_schema(data) + # get all yml files from protocols + # validate with + schema.validate(data) + + +if __name__ == '__main__': + validate(sys.argv)