community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1689473 - in /comdev/reporter.apache.org: data/reformat.py prettify.py
Date Mon, 06 Jul 2015 18:40:31 GMT
Author: sebb
Date: Mon Jul  6 18:40:30 2015
New Revision: 1689473

URL: http://svn.apache.org/r1689473
Log:
Replace formatter for specific files only with one that works on any json file

Added:
    comdev/reporter.apache.org/prettify.py
Removed:
    comdev/reporter.apache.org/data/reformat.py

Added: comdev/reporter.apache.org/prettify.py
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/prettify.py?rev=1689473&view=auto
==============================================================================
--- comdev/reporter.apache.org/prettify.py (added)
+++ comdev/reporter.apache.org/prettify.py Mon Jul  6 18:40:30 2015
@@ -0,0 +1,19 @@
+# Prettify input json file: indent, sort
+import json
+import sys
+for arg in sys.argv[1:]:
+    print("Reading " + arg)
+    input = {}
+    try:
+        with open(arg, "r") as f:
+            input = json.loads(f.read())
+            f.close()
+    except:
+        pass
+
+    out = arg + ".out"
+    print("Writing " + out)
+    with open(out, "w") as f:
+        f.write(json.dumps(input, indent=1, sort_keys=True))
+        f.close()
+



Mime
View raw message