From 890d4fa2e1722058903e2b5ca7e27e2dbdd9e6b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 13 Jul 2014 10:12:59 +0200 Subject: [PATCH] Fix style of some dicts --- qweechat/buffer.py | 14 +++++++--- qweechat/network.py | 22 ++++++++++------ qweechat/weechat/color.py | 7 ++++- qweechat/weechat/protocol.py | 50 ++++++++++++++++++++---------------- 4 files changed, 58 insertions(+), 35 deletions(-) diff --git a/qweechat/buffer.py b/qweechat/buffer.py index 8c5398a..50b6675 100644 --- a/qweechat/buffer.py +++ b/qweechat/buffer.py @@ -190,9 +190,11 @@ class Buffer(QtCore.QObject): 'nicks': [] } else: - self.nicklist[parent]['nicks'].append({'prefix': prefix, - 'name': name, - 'visible': visible}) + self.nicklist[parent]['nicks'].append({ + 'prefix': prefix, + 'name': name, + 'visible': visible, + }) def nicklist_remove_item(self, parent, group, name): """Remove a group/nick from nicklist.""" @@ -225,7 +227,11 @@ class Buffer(QtCore.QObject): for group in sorted(self.nicklist): for nick in sorted(self.nicklist[group]['nicks'], key=lambda n: n['name']): - prefix_color = {'': '', ' ': '', '+': 'yellow'} + prefix_color = { + '': '', + ' ': '', + '+': 'yellow', + } color = prefix_color.get(nick['prefix'], 'green') if color: icon = QtGui.QIcon( diff --git a/qweechat/network.py b/qweechat/network.py index 064c45e..2495a5e 100644 --- a/qweechat/network.py +++ b/qweechat/network.py @@ -165,14 +165,20 @@ class Network(QtCore.QObject): self.send_to_weechat('\n'.join(_PROTO_SYNC_CMDS)) def status_icon(self, status): - icon = {self.status_disconnected: 'dialog-close.png', - self.status_connecting: 'dialog-close.png', - self.status_connected: 'dialog-ok-apply.png'} + """Return the name of icon for a given status.""" + icon = { + self.status_disconnected: 'dialog-close.png', + self.status_connecting: 'dialog-close.png', + self.status_connected: 'dialog-ok-apply.png', + } return icon.get(status, '') def get_options(self): - return {'server': self._server, - 'port': self._port, - 'ssl': 'on' if self._ssl else 'off', - 'password': self._password, - 'lines': str(self._lines)} + """Get connection options.""" + return { + 'server': self._server, + 'port': self._port, + 'ssl': 'on' if self._ssl else 'off', + 'password': self._password, + 'lines': str(self._lines), + } diff --git a/qweechat/weechat/color.py b/qweechat/weechat/color.py index 1fb72be..a777c71 100644 --- a/qweechat/weechat/color.py +++ b/qweechat/weechat/color.py @@ -127,7 +127,12 @@ class Color(): return '' def _attrcode_to_char(self, code): - codes = {'\x01': '*', '\x02': '!', '\x03': '/', '\x04': '_'} + codes = { + '\x01': '*', + '\x02': '!', + '\x03': '/', + '\x04': '_', + } return codes.get(code, '') def _convert_color(self, match): diff --git a/qweechat/weechat/protocol.py b/qweechat/weechat/protocol.py index 71fabd1..005a05d 100644 --- a/qweechat/weechat/protocol.py +++ b/qweechat/weechat/protocol.py @@ -88,9 +88,10 @@ class WeechatObject: return self._str_value(self.value) def __str__(self): - self._obj_cb = {'hda': self._str_value_hdata, - 'inl': self._str_value_infolist, - } + self._obj_cb = { + 'hda': self._str_value_hdata, + 'inl': self._str_value_infolist, + } return '%s: %s' % (self.objtype, self._obj_cb.get(self.objtype, self._str_value_other)()) @@ -130,19 +131,20 @@ class Protocol: """Decode binary message received from WeeChat/relay.""" def __init__(self): - self._obj_cb = {'chr': self._obj_char, - 'int': self._obj_int, - 'lon': self._obj_long, - 'str': self._obj_str, - 'buf': self._obj_buffer, - 'ptr': self._obj_ptr, - 'tim': self._obj_time, - 'htb': self._obj_hashtable, - 'hda': self._obj_hdata, - 'inf': self._obj_info, - 'inl': self._obj_infolist, - 'arr': self._obj_array, - } + self._obj_cb = { + 'chr': self._obj_char, + 'int': self._obj_int, + 'lon': self._obj_long, + 'str': self._obj_str, + 'buf': self._obj_buffer, + 'ptr': self._obj_ptr, + 'tim': self._obj_time, + 'htb': self._obj_hashtable, + 'hda': self._obj_hdata, + 'inf': self._obj_info, + 'inl': self._obj_infolist, + 'arr': self._obj_array, + } def _obj_type(self): """Read type in data (3 chars).""" @@ -260,11 +262,12 @@ class Protocol: item[key] = self._obj_cb[objtype]() item['__path'] = pointers items.append(item) - return {'path': list_path, - 'keys': dict_keys, - 'count': count, - 'items': items, - } + return { + 'path': list_path, + 'keys': dict_keys, + 'count': count, + 'items': items, + } def _obj_info(self): """Read an info in data.""" @@ -286,7 +289,10 @@ class Protocol: var_value = self._obj_cb[var_type]() variables[var_name] = var_value items.append(variables) - return {'name': name, 'items': items} + return { + 'name': name, + 'items': items + } def _obj_array(self): """Read an array of values in data."""