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': []
}
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(

View File

@ -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),
}

View File

@ -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):

View File

@ -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."""