From bfa7160f2e64242ae51e10fb71101146f21ca318 Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Sat, 14 Jan 2017 21:11:49 -0800 Subject: [PATCH] Added script to check for RPi/AVR variable consistency --- scripts/check-config-vars.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 scripts/check-config-vars.py diff --git a/scripts/check-config-vars.py b/scripts/check-config-vars.py new file mode 100755 index 0000000..5b9c484 --- /dev/null +++ b/scripts/check-config-vars.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +'''Check that the configuration variable template used on the RPi matches the +variables used in the AVR''' + +import sys +import json + +templ = json.load(open('src/resources/config-template.json', 'r')) +vars = json.load(open('avr/build/vars.json', 'r')) + + +def check(section): + errors = 0 + + for name, entry in section.items(): + if 'type' in entry: + ok = False + + if 'code' in entry and not entry['code'] in vars: + print('"%s" with code "%s" not found' % (name, entry['code'])) + + else: ok = True + + if not ok: errors += 1 + + else: errors += check(entry) + + return errors + + +errors = check(templ) +print('\n%d errors' % errors) +sys.exit(errors != 0) -- 2.27.0