changeset 2194:322948499db0

jp (output dict): added color and no-header option
author Goffi <goffi@goffi.org>
date Mon, 13 Mar 2017 23:15:06 +0100
parents 33b82250eadd
children d65275ac39b3
files frontends/src/jp/output_std.py
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/jp/output_std.py	Mon Mar 13 23:14:00 2017 +0100
+++ b/frontends/src/jp/output_std.py	Mon Mar 13 23:15:06 2017 +0100
@@ -20,6 +20,7 @@
 
 
 from sat_frontends.jp.constants import Const as C
+from sat.tools.common.ansi import ANSI as A
 import json
 
 __outputs__ = ["Simple", "Json"]
@@ -45,8 +46,16 @@
         self.host.disp(u'\n'.join(data))
 
     def dict(self, data):
-        for k, v in data:
-            self.host.disp((u'{key}: {value}'.format(key=k, value=v)))
+        options = self.host.parse_output_options()
+        self.host.check_output_options({u'no-header'}, options)
+        show_header = not u'no-header' in options
+        for k, v in data.iteritems():
+            if show_header:
+                header = A.color(A.BOLD, A.FG_YELLOW, k) + u': '
+            else:
+                header = u''
+
+            self.host.disp((u'{header}{value}'.format(header=header, value=v)))
 
 
 class Json(object):