From 12ede4d3019a611b3b58d245d65c52bc01f37046 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sat, 13 Jan 2018 15:33:19 +0100 Subject: yapf -ir --- poezio/config.py | 7 ++++++- poezio/connection.py | 11 +++++++---- poezio/core/commands.py | 7 ++++--- poezio/core/completions.py | 9 +++++---- poezio/core/core.py | 3 +-- poezio/core/handlers.py | 11 ++++++----- poezio/logger.py | 7 +++---- poezio/multiuserchat.py | 3 ++- poezio/plugin_manager.py | 4 ++-- poezio/poezio.py | 1 + poezio/tabs/basetabs.py | 8 ++++---- poezio/tabs/conversationtab.py | 4 +--- poezio/tabs/muctab.py | 4 ++-- poezio/user.py | 3 +-- poezio/windows/bookmark_forms.py | 14 ++++++++------ poezio/windows/inputs.py | 5 ++--- poezio/windows/muc.py | 3 +-- poezio/windows/roster_win.py | 12 ++++++------ poezio/windows/text_win.py | 3 +-- 19 files changed, 63 insertions(+), 56 deletions(-) (limited to 'poezio') diff --git a/poezio/config.py b/poezio/config.py index 08920942..528debc6 100644 --- a/poezio/config.py +++ b/poezio/config.py @@ -337,7 +337,12 @@ class Config(RawConfigParser): prefix, file = path.split(self.file_name) filename = path.join(prefix, '.%s.tmp' % file) fd = os.fdopen( - os.open(filename, os.O_WRONLY | os.O_CREAT, 0o600,), 'w', + os.open( + filename, + os.O_WRONLY | os.O_CREAT, + 0o600, + ), + 'w', encoding='utf-8') for line in lines: fd.write('%s\n' % line) diff --git a/poezio/connection.py b/poezio/connection.py index 99a19c11..61837ecb 100644 --- a/poezio/connection.py +++ b/poezio/connection.py @@ -152,12 +152,15 @@ class Connection(slixmpp.ClientXMPP): info = {'name': 'poezio', 'version': options.version} if config.get('send_os_info'): info['os'] = common.get_os_info() - self.plugin['xep_0030'].set_identities( - identities={('client', 'console', None, 'Poezio')}) + self.plugin['xep_0030'].set_identities(identities={('client', + 'console', + None, + 'Poezio')}) else: info = {'name': '', 'version': ''} - self.plugin['xep_0030'].set_identities( - identities={('client', 'console', None, '')}) + self.plugin['xep_0030'].set_identities(identities={('client', + 'console', + None, '')}) self.register_plugin('xep_0092', pconfig=info) if config.get('send_time'): self.register_plugin('xep_0202') diff --git a/poezio/core/commands.py b/poezio/core/commands.py index 91d98030..a6d8bcbb 100644 --- a/poezio/core/commands.py +++ b/poezio/core/commands.py @@ -407,7 +407,8 @@ class CommandCore: tab.join() if config.get('bookmark_on_join'): - method = 'remote' if config.get('use_remote_bookmarks') else 'local' + method = 'remote' if config.get( + 'use_remote_bookmarks') else 'local' self._add_bookmark('%s/%s' % (room, nick), True, password, method) if tab == self.core.current_tab(): @@ -912,8 +913,8 @@ class CommandCore: self.core.xmpp.remove_handler('Iq %s' % iq_id) self.core.xmpp.register_handler( - Callback('Iq %s' % iq_id, - StanzaPath('iq@id=%s' % iq_id), iqfunc)) + Callback('Iq %s' % iq_id, StanzaPath('iq@id=%s' % iq_id), + iqfunc)) stanza.send() except: self.core.information('Could not send custom stanza', 'Error') diff --git a/poezio/core/completions.py b/poezio/core/completions.py index 12f0b4a1..c86e3514 100644 --- a/poezio/core/completions.py +++ b/poezio/core/completions.py @@ -51,7 +51,8 @@ class CompletionCore: if tab is not None and tab.joined: to_suggest.append(bookmark.jid) return Completion( - the_input.auto_completion, roster.jids() + to_suggest, + the_input.auto_completion, + roster.jids() + to_suggest, '', quotify=True) elif arg == 2: @@ -275,9 +276,9 @@ class CompletionCore: (roster[jid].resources for jid in roster.jids() if len(roster[jid])), []) comp = sorted(comp) - bares = sorted( - roster[contact].bare_jid for contact in roster.jids() - if len(roster[contact])) + bares = sorted(roster[contact].bare_jid + for contact in roster.jids() + if len(roster[contact])) off = sorted(jid for jid in roster.jids() if jid not in bares) comp = comp + bares + off return Completion(the_input.new_completion, comp, n, quotify=True) diff --git a/poezio/core/core.py b/poezio/core/core.py index 64ded385..9d2d0856 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -269,8 +269,7 @@ class Core(object): self.xmpp.add_event_handler('carbon_sent', self.handler.on_carbon_sent) self.xmpp.add_event_handler('http_confirm', self.handler.http_confirm) - all_stanzas = Callback('custom matcher', - connection.MatchAll(None), + all_stanzas = Callback('custom matcher', connection.MatchAll(None), self.handler.incoming_stanza) self.xmpp.register_handler(all_stanzas) if config.get('enable_avatars'): diff --git a/poezio/core/handlers.py b/poezio/core/handlers.py index f1a8bcb9..a7a0797b 100644 --- a/poezio/core/handlers.py +++ b/poezio/core/handlers.py @@ -1078,11 +1078,12 @@ class HandlerCore: roster.modified() if not logger.log_roster_change(jid.bare, 'got online'): self.core.information('Unable to write in the log file', 'Error') - resource = Resource(jid.full, { - 'priority': presence.get_priority() or 0, - 'status': presence['status'], - 'show': presence['show'], - }) + resource = Resource( + jid.full, { + 'priority': presence.get_priority() or 0, + 'status': presence['status'], + 'show': presence['show'], + }) self.core.events.trigger('normal_presence', presence, resource) name = contact.name if contact.name else jid.bare self.core.add_information_message_to_conversation_tab( diff --git a/poezio/logger.py b/poezio/logger.py index 8eff0209..6ce9ef90 100644 --- a/poezio/logger.py +++ b/poezio/logger.py @@ -38,8 +38,8 @@ class LogItem: def __init__(self, year, month, day, hour, minute, second, nb_lines, message): self.time = datetime( - int(year), - int(month), int(day), int(hour), int(minute), int(second)) + int(year), int(month), int(day), int(hour), int(minute), + int(second)) self.nb_lines = int(nb_lines) self.text = message @@ -228,8 +228,7 @@ class Logger(object): if not self._roster_logfile: try: self._roster_logfile = open( - os.path.join(log_dir, 'roster.log'), 'a', - encoding='utf-8') + os.path.join(log_dir, 'roster.log'), 'a', encoding='utf-8') except IOError: log.error( 'Unable to create the log file (%s)', diff --git a/poezio/multiuserchat.py b/poezio/multiuserchat.py index 64b84069..73a802b2 100644 --- a/poezio/multiuserchat.py +++ b/poezio/multiuserchat.py @@ -203,7 +203,8 @@ def set_user_affiliation(xmpp, return iq.send(callback=callback) try: return xmpp.plugin['xep_0045'].set_affiliation( - str(muc_jid), str(jid) if jid else None, nick, affiliation) + str(muc_jid), + str(jid) if jid else None, nick, affiliation) except: log.debug('Error setting the affiliation: %s', exc_info=True) return False diff --git a/poezio/plugin_manager.py b/poezio/plugin_manager.py index cdc5f0d0..c9e83148 100644 --- a/poezio/plugin_manager.py +++ b/poezio/plugin_manager.py @@ -108,8 +108,8 @@ class PluginManager(object): del self.core.key_func[key] for tab in list(self.tab_commands[name].keys()): for command in self.tab_commands[name][tab][:]: - self.del_tab_command(name, - getattr(tabs, tab), command[0]) + self.del_tab_command(name, getattr(tabs, tab), + command[0]) del self.tab_commands[name][tab] for tab in list(self.tab_keys[name].keys()): for key in self.tab_keys[name][tab][:]: diff --git a/poezio/poezio.py b/poezio/poezio.py index 586130c8..a3dac78e 100644 --- a/poezio/poezio.py +++ b/poezio/poezio.py @@ -37,6 +37,7 @@ Poezio is currently unable to read your input or draw its interface properly,\ so it will now exit.""") return False + def test_env(): """ Check if the environment has the right variables set diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py index 01dedb3a..135c0b84 100644 --- a/poezio/tabs/basetabs.py +++ b/poezio/tabs/basetabs.py @@ -779,11 +779,12 @@ class OneToOneTab(ChatTab): self.register_command( 'close', self.command_unquery, shortdesc='Close the tab.') self.register_command( - 'attention', self.command_attention, + 'attention', + self.command_attention, usage='[message]', shortdesc='Request the attention.', desc='Attention: Request the attention of the contact. Can also ' - 'send a message along with the attention.') + 'send a message along with the attention.') def remote_user_color(self): return dump_tuple(get_theme().COLOR_REMOTE_USER) @@ -854,8 +855,7 @@ class OneToOneTab(ChatTab): nickname=self.core.own_nick, nick_color=get_theme().COLOR_OWN_NICK, identifier=message['id'], - jid=self.core.xmpp.boundjid - ) + jid=self.core.xmpp.boundjid) self.refresh() def check_features(self): diff --git a/poezio/tabs/conversationtab.py b/poezio/tabs/conversationtab.py index 20180f73..ec0d6659 100644 --- a/poezio/tabs/conversationtab.py +++ b/poezio/tabs/conversationtab.py @@ -428,9 +428,7 @@ class DynamicConversationTab(ConversationTab): ConversationTab.__init__(self, core, jid) self.info_header = windows.DynamicConversationInfoWin() self.register_command( - 'unlock', - self.unlock_command, - shortdesc='Deprecated, do nothing.') + 'unlock', self.unlock_command, shortdesc='Deprecated, do nothing.') self.resize() def get_info_header(self): diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py index 769d7b8a..91d8b986 100644 --- a/poezio/tabs/muctab.py +++ b/poezio/tabs/muctab.py @@ -658,8 +658,8 @@ class MucTab(ChatTab): user.change_nick(new_nick) else: user.change_nick(new_nick) - deterministic = config.get_by_tabname( - 'deterministic_nick_colors', self.name) + deterministic = config.get_by_tabname('deterministic_nick_colors', + self.name) color = config.get_by_tabname(new_nick, 'muc_colors') or None if color or deterministic: user.change_color(color, deterministic) diff --git a/poezio/user.py b/poezio/user.py index ae70f6f8..b51efb14 100644 --- a/poezio/user.py +++ b/poezio/user.py @@ -55,8 +55,7 @@ class User(object): theme = get_theme() if theme.ccg_palette: # use XEP-0392 CCG - fg_color = colors.ccg_text_to_color( - theme.ccg_palette, self.nick) + fg_color = colors.ccg_text_to_color(theme.ccg_palette, self.nick) self.color = fg_color, -1 else: mod = len(theme.LIST_COLOR_NICKNAMES) diff --git a/poezio/windows/bookmark_forms.py b/poezio/windows/bookmark_forms.py index 5f5d581a..74135e54 100644 --- a/poezio/windows/bookmark_forms.py +++ b/poezio/windows/bookmark_forms.py @@ -143,9 +143,10 @@ class BookmarksWin(Win): self._bookmarks = list(bookmarks) self.lines = [] for bookmark in sorted(self._bookmarks, key=lambda x: x.jid): - self.lines.append( - (BookmarkJIDInput(bookmark), BookmarkPasswordInput(bookmark), - BookmarkAutojoinWin(bookmark), BookmarkMethodInput(bookmark))) + self.lines.append((BookmarkJIDInput(bookmark), + BookmarkPasswordInput(bookmark), + BookmarkAutojoinWin(bookmark), + BookmarkMethodInput(bookmark))) @property def current_input(self): @@ -163,9 +164,10 @@ class BookmarksWin(Win): self._current_input = 0 def add_bookmark(self, bookmark): - self.lines.append( - (BookmarkJIDInput(bookmark), BookmarkPasswordInput(bookmark), - BookmarkAutojoinWin(bookmark), BookmarkMethodInput(bookmark))) + self.lines.append((BookmarkJIDInput(bookmark), + BookmarkPasswordInput(bookmark), + BookmarkAutojoinWin(bookmark), + BookmarkMethodInput(bookmark))) self.lines[ self.current_input][self.current_horizontal_input].set_color( get_theme().COLOR_NORMAL_TEXT) diff --git a/poezio/windows/inputs.py b/poezio/windows/inputs.py index 48f60493..6956f4f6 100644 --- a/poezio/windows/inputs.py +++ b/poezio/windows/inputs.py @@ -532,9 +532,8 @@ class Input(Win): (_, x) = self._win.getyx() size = self.width - x self.addnstr(' ' * size, size, to_curses_attr(self.color)) - self.addstr(0, - poopt.wcswidth(displayed_text[:self.pos - self.view_pos]), - '') + self.addstr(0, poopt.wcswidth( + displayed_text[:self.pos - self.view_pos]), '') if self.color: self._win.attroff(to_curses_attr(self.color)) curses.curs_set(1) diff --git a/poezio/windows/muc.py b/poezio/windows/muc.py index 4251c279..ef8a89d6 100644 --- a/poezio/windows/muc.py +++ b/poezio/windows/muc.py @@ -75,8 +75,7 @@ class UserList(Win): for user in users[self.pos:self.pos + self.height]: self.draw_role_affiliation(y, user) self.draw_status_chatstate(y, user) - self.addstr(y, 2, - poopt.cut_by_columns(user.nick, self.width - 2), + self.addstr(y, 2, poopt.cut_by_columns(user.nick, self.width - 2), to_curses_attr(user.color)) if asc_sort: y -= 1 diff --git a/poezio/windows/roster_win.py b/poezio/windows/roster_win.py index 7b1e5ba7..0906d1e9 100644 --- a/poezio/windows/roster_win.py +++ b/poezio/windows/roster_win.py @@ -132,8 +132,8 @@ class RosterWin(Win): log.debug('Refresh: %s', self.__class__.__name__) self.build_roster_cache(roster) # make sure we are within bounds - self.move_cursor_up((self.roster_len + self.pos) - if self.pos >= self.roster_len else 0) + self.move_cursor_up(( + self.roster_len + self.pos) if self.pos >= self.roster_len else 0) if not self.roster_cache: self.selected_row = None self._win.erase() @@ -206,8 +206,9 @@ class RosterWin(Win): else: self.addstr(y, 0, '[-] ') contacts = " (%s/%s)" % (group.get_nb_connected_contacts(), len(group)) - self.addstr( - y, 4, self.truncate_name(group.name, len(contacts) + 4) + contacts) + self.addstr(y, 4, + self.truncate_name(group.name, + len(contacts) + 4) + contacts) if colored: self._win.attroff(to_curses_attr(get_theme().COLOR_SELECTED_ROW)) self.finish_line() @@ -320,8 +321,7 @@ class RosterWin(Win): color = get_theme().color_show(resource.presence) self.addstr(y, 4, get_theme().CHAR_STATUS, to_curses_attr(color)) if colored: - self.addstr(y, 8, - self.truncate_name(str(resource.jid), 6), + self.addstr(y, 8, self.truncate_name(str(resource.jid), 6), to_curses_attr(get_theme().COLOR_SELECTED_ROW)) else: self.addstr(y, 8, self.truncate_name(str(resource.jid), 6)) diff --git a/poezio/windows/text_win.py b/poezio/windows/text_win.py index b923b712..23fefb56 100644 --- a/poezio/windows/text_win.py +++ b/poezio/windows/text_win.py @@ -486,8 +486,7 @@ class TextWin(BaseTextWin): def write_line_separator(self, y): char = get_theme().CHAR_NEW_TEXT_SEPARATOR - self.addnstr(y, 0, - char * (self.width // len(char) - 1), self.width, + self.addnstr(y, 0, char * (self.width // len(char) - 1), self.width, to_curses_attr(get_theme().COLOR_NEW_TEXT_SEPARATOR)) def write_ack(self): -- cgit v1.2.3