[Pkg-isocodes-devel] [iso-codes] 03/03: Add script to validate JSON data files against their schema
Tobias Quathamer
toddy at moszumanska.debian.org
Fri Mar 4 11:08:20 UTC 2016
This is an automated email from the git hooks/post-receive script.
toddy pushed a commit to branch master
in repository iso-codes.
commit 348ab19c37873e7c54812f6916b2ba20662642f2
Author: Dr. Tobias Quathamer <toddy at debian.org>
Date: Fri Mar 4 12:07:28 2016 +0100
Add script to validate JSON data files against their schema
---
bin/validate_json_data.py | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/bin/validate_json_data.py b/bin/validate_json_data.py
new file mode 100755
index 0000000..882b588
--- /dev/null
+++ b/bin/validate_json_data.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python3
+#
+# Checks all JSON data files against their schema.
+#
+# Copyright © 2016 Dr. Tobias Quathamer <toddy at debian.org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+import json
+from jsonschema import validate
+
+standards = [
+ "639-2",
+ "639-3",
+ "639-5",
+ "3166-1",
+ "3166-2",
+ "3166-3",
+ "4217",
+ "15924",
+]
+
+for standard in standards:
+ with open("data/schema-" + standard + ".json") as schema_file:
+ schema = json.load(schema_file)
+ with open("data/iso_" + standard + ".json") as json_file:
+ validate(json.load(json_file), schema)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-isocodes/iso-codes.git
More information about the Pkg-isocodes-devel
mailing list