[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [compass/master] Added support for command line JSON output



commit 0ab355d61ad323f1927dcad7992508e8377d44f2
Author: Chris Wacek <cwacek@xxxxxxxxxxxxxxxxx>
Date:   Tue Jan 15 15:40:06 2013 -0500

    Added support for command line JSON output
---
 compass.py |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/compass.py b/compass.py
index 7987e49..1f8d171 100755
--- a/compass.py
+++ b/compass.py
@@ -493,6 +493,8 @@ def create_option_parser():
 
     group.add_option("-s", "--short", action="store_const",dest='short',const=70,
                      help="cut the length of the line output at 70 chars")
+    group.add_option("-j", "--json", action="store_true",
+                     help="output in JSON rather than human-readable format")
     parser.add_option_group(group)
     return parser
 
@@ -554,5 +556,8 @@ if '__main__' == __name__:
 
     sorted_results = stats.sort_and_reduce(results,options)
 
-    stats.print_selection(sorted_results,options)
+    if options.json:
+      print(json.dumps(sorted_results,cls=util.ResultEncoder))
+    else:
+      stats.print_selection(sorted_results,options)
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits