Mercurial > libervia-backend
diff libervia/tui/chat.py @ 4270:0d7bb4df2343
Reformatted code base using black.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 19 Jun 2024 18:44:57 +0200 |
parents | b620a8e882e1 |
children |
line wrap: on
line diff
--- a/libervia/tui/chat.py Tue Jun 18 12:06:45 2024 +0200 +++ b/libervia/tui/chat.py Wed Jun 19 18:44:57 2024 +0200 @@ -245,7 +245,9 @@ urwid.ListBox(self.occupants_walker), footer=self.occupants_footer ) super(OccupantsWidget, self).__init__(occupants_widget) - occupants_list = sorted(list(self.parent.occupants.keys()), key=lambda o: o.lower()) + occupants_list = sorted( + list(self.parent.occupants.keys()), key=lambda o: o.lower() + ) for occupant in occupants_list: occupant_data = self.parent.occupants[occupant] self.occupants_walker.append(OccupantWidget(occupant_data)) @@ -284,8 +286,17 @@ class Chat(LiberviaTUIWidget, quick_chat.QuickChat): - def __init__(self, host, target, type_=C.CHAT_ONE2ONE, nick=None, occupants=None, - subject=None, statuses=None, profiles=None): + def __init__( + self, + host, + target, + type_=C.CHAT_ONE2ONE, + nick=None, + occupants=None, + subject=None, + statuses=None, + profiles=None, + ): self.filters = [] # list of filter callbacks to apply self.mess_walker = urwid.SimpleListWalker([]) self.mess_widgets = urwid.ListBox(self.mess_walker) @@ -294,8 +305,15 @@ self.pile = urwid.Pile([self.chat_colums]) LiberviaTUIWidget.__init__(self, self.pile, target) quick_chat.QuickChat.__init__( - self, host, target, type_, nick, occupants, subject, statuses, - profiles=profiles + self, + host, + target, + type_, + nick, + occupants, + subject, + statuses, + profiles=profiles, ) # we must adapt the behaviour with the type @@ -334,7 +352,7 @@ elif key == a_key["SHORT_NICKNAME"]: # user wants to (not) use short nick self.show_short_nick = not self.show_short_nick self.redraw() - elif (key == a_key["SUBJECT_SWITCH"]): + elif key == a_key["SUBJECT_SWITCH"]: # user wants to (un)hide group's subject or change its apperance if self.subject: self.show_title = (self.show_title + 1) % 3 @@ -448,11 +466,11 @@ # it should be done in a more user friendly way for lang, body in message.message.items(): for attachment in message.attachments: - if 'url' in attachment: - body+=f"\n{attachment['url']}" - elif 'path' in attachment: - path = Path(attachment['path']) - body+=f"\n{path.as_uri()}" + if "url" in attachment: + body += f"\n{attachment['url']}" + elif "path" in attachment: + path = Path(attachment["path"]) + body += f"\n{path.as_uri()}" else: log.warning(f'No "url" nor "path" in attachment: {attachment}') message.message[lang] = body @@ -464,8 +482,9 @@ if self.handle_user_moved(message): return - if ((self.host.selected_widget != self or not self.host.x_notify.has_focus()) - and self.focus_marker_set is not None): + if ( + self.host.selected_widget != self or not self.host.x_notify.has_focus() + ) and self.focus_marker_set is not None: if not self.focus_marker_set and not self._locked and self.mess_walker: if self.focus_marker is not None: try: @@ -604,7 +623,9 @@ except AttributeError: pass - def update_history(self, size=C.HISTORY_LIMIT_DEFAULT, filters=None, profile="@NONE@"): + def update_history( + self, size=C.HISTORY_LIMIT_DEFAULT, filters=None, profile="@NONE@" + ): del self.mess_walker[:] if filters and "search" in filters: self.mess_walker.append(