Mercurial > libervia-backend
comparison sat_frontends/jp/output_std.py @ 2624:56f94936df1e
code style reformatting using black
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 27 Jun 2018 20:14:46 +0200 |
parents | 26edcf3a30eb |
children | b156b78b8f9a |
comparison
equal
deleted
inserted
replaced
2623:49533de4540b | 2624:56f94936df1e |
---|---|
22 from sat_frontends.jp.constants import Const as C | 22 from sat_frontends.jp.constants import Const as C |
23 from sat.tools.common.ansi import ANSI as A | 23 from sat.tools.common.ansi import ANSI as A |
24 import json | 24 import json |
25 | 25 |
26 __outputs__ = ["Simple", "Json"] | 26 __outputs__ = ["Simple", "Json"] |
27 SIMPLE = u'simple' | 27 SIMPLE = u"simple" |
28 JSON = u'json' | 28 JSON = u"json" |
29 JSON_RAW = u'json_raw' | 29 JSON_RAW = u"json_raw" |
30 | 30 |
31 | 31 |
32 class Simple(object): | 32 class Simple(object): |
33 """Default outputs""" | 33 """Default outputs""" |
34 | 34 |
43 | 43 |
44 def simple_print(self, data): | 44 def simple_print(self, data): |
45 self.host.disp(unicode(data)) | 45 self.host.disp(unicode(data)) |
46 | 46 |
47 def list(self, data): | 47 def list(self, data): |
48 self.host.disp(u'\n'.join(data)) | 48 self.host.disp(u"\n".join(data)) |
49 | 49 |
50 def dict(self, data, indent=0, header_color=C.A_HEADER): | 50 def dict(self, data, indent=0, header_color=C.A_HEADER): |
51 options = self.host.parse_output_options() | 51 options = self.host.parse_output_options() |
52 self.host.check_output_options({u'no-header'}, options) | 52 self.host.check_output_options({u"no-header"}, options) |
53 show_header = not u'no-header' in options | 53 show_header = not u"no-header" in options |
54 for k, v in data.iteritems(): | 54 for k, v in data.iteritems(): |
55 if show_header: | 55 if show_header: |
56 header = A.color(header_color, k) + u': ' | 56 header = A.color(header_color, k) + u": " |
57 else: | 57 else: |
58 header = u'' | 58 header = u"" |
59 | 59 |
60 self.host.disp((u'{indent}{header}{value}'.format( | 60 self.host.disp( |
61 indent=indent*u' ', | 61 ( |
62 header=header, | 62 u"{indent}{header}{value}".format( |
63 value=v))) | 63 indent=indent * u" ", header=header, value=v |
64 ) | |
65 ) | |
66 ) | |
64 | 67 |
65 def list_dict(self, data): | 68 def list_dict(self, data): |
66 for idx, datum in enumerate(data): | 69 for idx, datum in enumerate(data): |
67 if idx: | 70 if idx: |
68 self.host.disp(u'\n') | 71 self.host.disp(u"\n") |
69 self.dict(datum) | 72 self.dict(datum) |
70 | 73 |
71 def dict_dict(self, data): | 74 def dict_dict(self, data): |
72 for key, sub_dict in data.iteritems(): | 75 for key, sub_dict in data.iteritems(): |
73 self.host.disp(A.color(C.A_HEADER, key)) | 76 self.host.disp(A.color(C.A_HEADER, key)) |