Mercurial > libervia-backend
comparison libervia/cli/output_std.py @ 4270:0d7bb4df2343
Reformatted code base using black.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 19 Jun 2024 18:44:57 +0200 |
parents | 47401850dec6 |
children | 5fd6a4dc2122 |
comparison
equal
deleted
inserted
replaced
4269:64a85ce8be70 | 4270:0d7bb4df2343 |
---|---|
77 self.dict(sub_dict, indent=4, header_color=C.A_SUBHEADER) | 77 self.dict(sub_dict, indent=4, header_color=C.A_SUBHEADER) |
78 | 78 |
79 def messages(self, data): | 79 def messages(self, data): |
80 # TODO: handle lang, and non chat message (normal, headline) | 80 # TODO: handle lang, and non chat message (normal, headline) |
81 for mess_data in data: | 81 for mess_data in data: |
82 (uid, timestamp, from_jid, to_jid, message, subject, mess_type, | 82 (uid, timestamp, from_jid, to_jid, message, subject, mess_type, extra) = ( |
83 extra) = mess_data | 83 mess_data |
84 time_str = date_utils.date_fmt(timestamp, "auto_day", | 84 ) |
85 tz_info=date_utils.TZ_LOCAL) | 85 time_str = date_utils.date_fmt( |
86 timestamp, "auto_day", tz_info=date_utils.TZ_LOCAL | |
87 ) | |
86 from_jid = jid.JID(from_jid) | 88 from_jid = jid.JID(from_jid) |
87 if mess_type == C.MESS_TYPE_GROUPCHAT: | 89 if mess_type == C.MESS_TYPE_GROUPCHAT: |
88 nick = from_jid.resource | 90 nick = from_jid.resource |
89 else: | 91 else: |
90 nick = from_jid.node | 92 nick = from_jid.node |
93 nick_color = A.BOLD + A.FG_BLUE | 95 nick_color = A.BOLD + A.FG_BLUE |
94 else: | 96 else: |
95 nick_color = A.BOLD + A.FG_YELLOW | 97 nick_color = A.BOLD + A.FG_YELLOW |
96 message = list(message.values())[0] if message else "" | 98 message = list(message.values())[0] if message else "" |
97 | 99 |
98 self.host.disp(A.color( | 100 self.host.disp( |
99 A.FG_CYAN, '['+time_str+'] ', | 101 A.color( |
100 nick_color, nick, A.RESET, A.BOLD, '> ', | 102 A.FG_CYAN, |
101 A.RESET, message)) | 103 "[" + time_str + "] ", |
104 nick_color, | |
105 nick, | |
106 A.RESET, | |
107 A.BOLD, | |
108 "> ", | |
109 A.RESET, | |
110 message, | |
111 ) | |
112 ) | |
102 | 113 |
103 | 114 |
104 class Json(object): | 115 class Json(object): |
105 """outputs in json format""" | 116 """outputs in json format""" |
106 | 117 |