Unverified Commit 12ede4d3 authored by mathieui's avatar mathieui

yapf -ir

parent 6fe2f208
......@@ -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)
......
......@@ -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')
......
......@@ -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')
......
......@@ -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)
......
......@@ -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'):
......
......@@ -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(
......
......@@ -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)',
......
......@@ -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
......
......@@ -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][:]:
......
......@@ -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
......
......@@ -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):
......
......@@ -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):
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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
......
......@@ -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))
......
......@@ -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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment