Fix style of some dicts

This commit is contained in:
Sébastien Helleu 2014-07-13 10:12:59 +02:00
parent ac53e98cd0
commit 890d4fa2e1
4 changed files with 58 additions and 35 deletions

View File

@ -190,9 +190,11 @@ class Buffer(QtCore.QObject):
'nicks': [] 'nicks': []
} }
else: else:
self.nicklist[parent]['nicks'].append({'prefix': prefix, self.nicklist[parent]['nicks'].append({
'prefix': prefix,
'name': name, 'name': name,
'visible': visible}) 'visible': visible,
})
def nicklist_remove_item(self, parent, group, name): def nicklist_remove_item(self, parent, group, name):
"""Remove a group/nick from nicklist.""" """Remove a group/nick from nicklist."""
@ -225,7 +227,11 @@ class Buffer(QtCore.QObject):
for group in sorted(self.nicklist): for group in sorted(self.nicklist):
for nick in sorted(self.nicklist[group]['nicks'], for nick in sorted(self.nicklist[group]['nicks'],
key=lambda n: n['name']): key=lambda n: n['name']):
prefix_color = {'': '', ' ': '', '+': 'yellow'} prefix_color = {
'': '',
' ': '',
'+': 'yellow',
}
color = prefix_color.get(nick['prefix'], 'green') color = prefix_color.get(nick['prefix'], 'green')
if color: if color:
icon = QtGui.QIcon( icon = QtGui.QIcon(

View File

@ -165,14 +165,20 @@ class Network(QtCore.QObject):
self.send_to_weechat('\n'.join(_PROTO_SYNC_CMDS)) self.send_to_weechat('\n'.join(_PROTO_SYNC_CMDS))
def status_icon(self, status): def status_icon(self, status):
icon = {self.status_disconnected: 'dialog-close.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_connecting: 'dialog-close.png',
self.status_connected: 'dialog-ok-apply.png'} self.status_connected: 'dialog-ok-apply.png',
}
return icon.get(status, '') return icon.get(status, '')
def get_options(self): def get_options(self):
return {'server': self._server, """Get connection options."""
return {
'server': self._server,
'port': self._port, 'port': self._port,
'ssl': 'on' if self._ssl else 'off', 'ssl': 'on' if self._ssl else 'off',
'password': self._password, 'password': self._password,
'lines': str(self._lines)} 'lines': str(self._lines),
}

View File

@ -127,7 +127,12 @@ class Color():
return '' return ''
def _attrcode_to_char(self, code): def _attrcode_to_char(self, code):
codes = {'\x01': '*', '\x02': '!', '\x03': '/', '\x04': '_'} codes = {
'\x01': '*',
'\x02': '!',
'\x03': '/',
'\x04': '_',
}
return codes.get(code, '') return codes.get(code, '')
def _convert_color(self, match): def _convert_color(self, match):

View File

@ -88,7 +88,8 @@ class WeechatObject:
return self._str_value(self.value) return self._str_value(self.value)
def __str__(self): def __str__(self):
self._obj_cb = {'hda': self._str_value_hdata, self._obj_cb = {
'hda': self._str_value_hdata,
'inl': self._str_value_infolist, 'inl': self._str_value_infolist,
} }
return '%s: %s' % (self.objtype, return '%s: %s' % (self.objtype,
@ -130,7 +131,8 @@ class Protocol:
"""Decode binary message received from WeeChat/relay.""" """Decode binary message received from WeeChat/relay."""
def __init__(self): def __init__(self):
self._obj_cb = {'chr': self._obj_char, self._obj_cb = {
'chr': self._obj_char,
'int': self._obj_int, 'int': self._obj_int,
'lon': self._obj_long, 'lon': self._obj_long,
'str': self._obj_str, 'str': self._obj_str,
@ -260,7 +262,8 @@ class Protocol:
item[key] = self._obj_cb[objtype]() item[key] = self._obj_cb[objtype]()
item['__path'] = pointers item['__path'] = pointers
items.append(item) items.append(item)
return {'path': list_path, return {
'path': list_path,
'keys': dict_keys, 'keys': dict_keys,
'count': count, 'count': count,
'items': items, 'items': items,
@ -286,7 +289,10 @@ class Protocol:
var_value = self._obj_cb[var_type]() var_value = self._obj_cb[var_type]()
variables[var_name] = var_value variables[var_name] = var_value
items.append(variables) items.append(variables)
return {'name': name, 'items': items} return {
'name': name,
'items': items
}
def _obj_array(self): def _obj_array(self):
"""Read an array of values in data.""" """Read an array of values in data."""