diff --git a/.travis.yml b/.travis.yml index aef60fa3c7..0aab748960 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,4 +12,5 @@ install: - pip install pylint script: - python pylint-recursive.py + - python json-validate.py configs/*.json.* - python -m unittest discover -v -p "*_test.py" diff --git a/configs/config.json.cluster.example b/configs/config.json.cluster.example index 621177658b..ae3c3ad857 100644 --- a/configs/config.json.cluster.example +++ b/configs/config.json.cluster.example @@ -108,7 +108,7 @@ "berry_wait_max": 3, "changeball_wait_min": 2, "changeball_wait_max": 3 - }, + } } }, { diff --git a/configs/config.json.example b/configs/config.json.example index 48925efd89..5950ef0d08 100644 --- a/configs/config.json.example +++ b/configs/config.json.example @@ -108,7 +108,7 @@ "berry_wait_max": 3, "changeball_wait_min": 2, "changeball_wait_max": 3 - }, + } } }, { diff --git a/configs/config.json.map.example b/configs/config.json.map.example index 73eff3d465..ba0716eefd 100644 --- a/configs/config.json.map.example +++ b/configs/config.json.map.example @@ -108,7 +108,7 @@ "berry_wait_max": 3, "changeball_wait_min": 2, "changeball_wait_max": 3 - }, + } } }, { diff --git a/configs/config.json.optimizer.example b/configs/config.json.optimizer.example index fa1c2c3fb1..1dd826428f 100644 --- a/configs/config.json.optimizer.example +++ b/configs/config.json.optimizer.example @@ -49,7 +49,7 @@ "// would have transfered if the parameter was true": {}, "transfer": true, "// 'transfer_wait_min' and 'transfer_wait_max' are the minimum and maximum": {}, - "// "time to wait when transferring a pokemon": {}, + "// time to wait when transferring a pokemon": {}, "transfer_wait_min": 1, "transfer_wait_max": 4, "// the 'evolve' parameter activate or deactivate the evolution of pokemons": {}, @@ -166,7 +166,7 @@ "berry_wait_max": 3, "changeball_wait_min": 2, "changeball_wait_max": 3 - }, + } } }, { diff --git a/configs/config.json.path.example b/configs/config.json.path.example index acfd9db0cb..9f8f10cbde 100644 --- a/configs/config.json.path.example +++ b/configs/config.json.path.example @@ -108,7 +108,7 @@ "berry_wait_max": 3, "changeball_wait_min": 2, "changeball_wait_max": 3 - }, + } } }, { diff --git a/configs/config.json.pokemon.example b/configs/config.json.pokemon.example index 5f35a03e80..56eaf60b6a 100644 --- a/configs/config.json.pokemon.example +++ b/configs/config.json.pokemon.example @@ -108,7 +108,7 @@ "berry_wait_max": 3, "changeball_wait_min": 2, "changeball_wait_max": 3 - }, + } } }, { diff --git a/json-validate.py b/json-validate.py new file mode 100644 index 0000000000..00061ba256 --- /dev/null +++ b/json-validate.py @@ -0,0 +1,44 @@ +#! /usr/bin/env python +''' +Check whether a json file is loadable +''' + +import json +import sys + +passed = 0 +failed = 0 +errors = list() + +def check(filename): + global passed, failed + + print "CHECKING ", filename + + f = open(filename).read() + try: + _ = json.loads(f) + print "PASSED: ", filename + passed += 1 + return True + except ValueError as e: + failed += 1 + print "FAILED: ", filename + errors.append("FILE: " + filename) + errors.append(e) + return False + + return False + +if __name__ == "__main__": + for filename in sys.argv[1:]: + check(filename) + + print "Passed: " + str(passed) + " Failed: " + str(failed) + print "\n" + print "Showing errors:" + if failed > 0: + for err in errors: + print err + + sys.exit("JSON check Failed with errors")