From 6181839d2f8212c618c6f8930223b1ea5ca9a034 Mon Sep 17 00:00:00 2001 From: rawgni Date: Wed, 17 Aug 2016 20:29:50 +0700 Subject: [PATCH 1/4] fix example config --- configs/config.json.cluster.example | 2 +- configs/config.json.example | 2 +- configs/config.json.map.example | 2 +- configs/config.json.pokemon.example | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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.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 - }, + } } }, { From 8baa4c9c401694bf81e7d99fea75f37c6f86bf41 Mon Sep 17 00:00:00 2001 From: Ingwar Wirjawan Date: Wed, 17 Aug 2016 22:28:44 +0800 Subject: [PATCH 2/4] fix config file --- configs/config.json.optimizer.example | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 - }, + } } }, { From 332aec528392c79ff2984702bd5be2e57cd76ee1 Mon Sep 17 00:00:00 2001 From: Ingwar Wirjawan Date: Wed, 17 Aug 2016 23:03:14 +0800 Subject: [PATCH 3/4] added a script to check json, and updated .travis.yml --- .travis.yml | 1 + configs/config.json.path.example | 2 +- json-validate.py | 46 ++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 json-validate.py 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.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/json-validate.py b/json-validate.py new file mode 100644 index 0000000000..848ab1eb6f --- /dev/null +++ b/json-validate.py @@ -0,0 +1,46 @@ +#! /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__": + files = sys.argv[1:] + + 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") From a96c18eff31ba278f5f27302249da0714a798d97 Mon Sep 17 00:00:00 2001 From: Ingwar Wirjawan Date: Wed, 17 Aug 2016 22:06:54 +0700 Subject: [PATCH 4/4] Update json-validate.py --- json-validate.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/json-validate.py b/json-validate.py index 848ab1eb6f..00061ba256 100644 --- a/json-validate.py +++ b/json-validate.py @@ -31,8 +31,6 @@ def check(filename): return False if __name__ == "__main__": - files = sys.argv[1:] - for filename in sys.argv[1:]: check(filename)