code optimization: tupples not lists in stuff like: 'if foo in [abc]' etc
This commit is contained in:
parent
1f1d87019f
commit
ca60bacdb5
8 changed files with 28 additions and 26 deletions
|
@ -210,7 +210,7 @@ class Chat:
|
||||||
color = gtk.gdk.colormap_get_system().alloc_color(color)
|
color = gtk.gdk.colormap_get_system().alloc_color(color)
|
||||||
# We set the color for when it's the current tab or not
|
# We set the color for when it's the current tab or not
|
||||||
nickname.modify_fg(gtk.STATE_NORMAL, color)
|
nickname.modify_fg(gtk.STATE_NORMAL, color)
|
||||||
if chatstate in ['inactive', 'gone']:
|
if chatstate in ('inactive', 'gone'):
|
||||||
# Adjust color to be lighter against the darker inactive
|
# Adjust color to be lighter against the darker inactive
|
||||||
# background
|
# background
|
||||||
p = 0.4
|
p = 0.4
|
||||||
|
@ -615,7 +615,8 @@ class Chat:
|
||||||
|
|
||||||
def new_tab(self, jid):
|
def new_tab(self, jid):
|
||||||
#FIXME: text formating buttons will be hidden in 0.8 release
|
#FIXME: text formating buttons will be hidden in 0.8 release
|
||||||
for w in ['bold_togglebutton', 'italic_togglebutton', 'underline_togglebutton']:
|
for w in ('bold_togglebutton', 'italic_togglebutton',
|
||||||
|
'underline_togglebutton'):
|
||||||
self.xmls[jid].get_widget(w).set_no_show_all(True)
|
self.xmls[jid].get_widget(w).set_no_show_all(True)
|
||||||
|
|
||||||
self.set_compact_view(self.always_compact_view)
|
self.set_compact_view(self.always_compact_view)
|
||||||
|
|
|
@ -672,7 +672,7 @@ class PreferencesWindow:
|
||||||
def update_text_tags(self):
|
def update_text_tags(self):
|
||||||
'''Update color tags in Opened Chat Windows'''
|
'''Update color tags in Opened Chat Windows'''
|
||||||
for a in gajim.connections:
|
for a in gajim.connections:
|
||||||
for kind in ['chats', 'gc']:
|
for kind in ('chats', 'gc'):
|
||||||
windows = gajim.interface.windows[a][kind]
|
windows = gajim.interface.windows[a][kind]
|
||||||
if windows.has_key('tabbed'):
|
if windows.has_key('tabbed'):
|
||||||
windows['tabbed'].update_tags()
|
windows['tabbed'].update_tags()
|
||||||
|
@ -683,7 +683,7 @@ class PreferencesWindow:
|
||||||
def update_text_font(self):
|
def update_text_font(self):
|
||||||
'''Update text font in Opened Chat Windows'''
|
'''Update text font in Opened Chat Windows'''
|
||||||
for a in gajim.connections:
|
for a in gajim.connections:
|
||||||
for kind in ['chats', 'gc']:
|
for kind in ('chats', 'gc'):
|
||||||
windows = gajim.interface.windows[a][kind]
|
windows = gajim.interface.windows[a][kind]
|
||||||
if windows.has_key('tabbed'):
|
if windows.has_key('tabbed'):
|
||||||
windows['tabbed'].update_font()
|
windows['tabbed'].update_font()
|
||||||
|
@ -717,7 +717,7 @@ class PreferencesWindow:
|
||||||
self.on_preference_widget_font_set(widget, 'conversation_font')
|
self.on_preference_widget_font_set(widget, 'conversation_font')
|
||||||
|
|
||||||
def on_reset_colors_button_clicked(self, widget):
|
def on_reset_colors_button_clicked(self, widget):
|
||||||
for i in ['inmsgcolor', 'outmsgcolor', 'statusmsgcolor']:
|
for i in ('inmsgcolor', 'outmsgcolor', 'statusmsgcolor'):
|
||||||
gajim.config.set(i, gajim.interface.default_values[i])
|
gajim.config.set(i, gajim.interface.default_values[i])
|
||||||
|
|
||||||
self.xml.get_widget('incoming_msg_colorbutton').set_color(\
|
self.xml.get_widget('incoming_msg_colorbutton').set_color(\
|
||||||
|
@ -1283,7 +1283,7 @@ _('To change the account name, you must be disconnected.')).get_response()
|
||||||
gajim.events_for_ui[name] = gajim.events_for_ui[self.account]
|
gajim.events_for_ui[name] = gajim.events_for_ui[self.account]
|
||||||
|
|
||||||
#upgrade account variable in opened windows
|
#upgrade account variable in opened windows
|
||||||
for kind in ['infos', 'chats', 'gc', 'gc_config']:
|
for kind in ('infos', 'chats', 'gc', 'gc_config'):
|
||||||
for j in gajim.interface.windows[name][kind]:
|
for j in gajim.interface.windows[name][kind]:
|
||||||
gajim.interface.windows[name][kind][j].account = name
|
gajim.interface.windows[name][kind][j].account = name
|
||||||
|
|
||||||
|
@ -1879,7 +1879,7 @@ class ServiceRegistrationWindow(DataFormWindow):
|
||||||
nbrow = 0
|
nbrow = 0
|
||||||
table = self.xml.get_widget('table')
|
table = self.xml.get_widget('table')
|
||||||
for name in self.infos.keys():
|
for name in self.infos.keys():
|
||||||
if name in ['key', 'instructions', 'x', 'registered']:
|
if name in ('key', 'instructions', 'x', 'registered'):
|
||||||
continue
|
continue
|
||||||
if not name:
|
if not name:
|
||||||
continue
|
continue
|
||||||
|
@ -2849,7 +2849,8 @@ class FirstTimeWizardWindow:
|
||||||
|
|
||||||
def get_widgets(self, prefix):
|
def get_widgets(self, prefix):
|
||||||
widgets = {}
|
widgets = {}
|
||||||
for widget in [ 'nick_entry',
|
for widget in (
|
||||||
|
'nick_entry',
|
||||||
'server_comboboxentry',
|
'server_comboboxentry',
|
||||||
'pass_entry',
|
'pass_entry',
|
||||||
'save_password_checkbutton',
|
'save_password_checkbutton',
|
||||||
|
@ -2857,7 +2858,7 @@ class FirstTimeWizardWindow:
|
||||||
'proxyport_entry',
|
'proxyport_entry',
|
||||||
'proxyuser_entry',
|
'proxyuser_entry',
|
||||||
'proxypass_entry',
|
'proxypass_entry',
|
||||||
'jid_label' ]:
|
'jid_label'):
|
||||||
widgets[widget] = self.xml.get_widget(prefix + widget)
|
widgets[widget] = self.xml.get_widget(prefix + widget)
|
||||||
return widgets
|
return widgets
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ class EditGroupsDialog:
|
||||||
store = gtk.ListStore(str, bool)
|
store = gtk.ListStore(str, bool)
|
||||||
self.list.set_model(store)
|
self.list.set_model(store)
|
||||||
for g in gajim.groups[self.account].keys():
|
for g in gajim.groups[self.account].keys():
|
||||||
if g in [_('Transports'), _('not in the roster')]:
|
if g in (_('Transports'), _('not in the roster')):
|
||||||
continue
|
continue
|
||||||
iter = store.append()
|
iter = store.append()
|
||||||
store.set(iter, 0, g)
|
store.set(iter, 0, g)
|
||||||
|
@ -795,8 +795,8 @@ class PopupNotificationWindow:
|
||||||
close_button.modify_bg(gtk.STATE_NORMAL, red)
|
close_button.modify_bg(gtk.STATE_NORMAL, red)
|
||||||
eventbox.modify_bg(gtk.STATE_NORMAL, red)
|
eventbox.modify_bg(gtk.STATE_NORMAL, red)
|
||||||
event_description_label.set_text(txt)
|
event_description_label.set_text(txt)
|
||||||
elif event_type in [_('New Message'), _('New Single Message'),
|
elif event_type in (_('New Message'), _('New Single Message'),
|
||||||
_('New Private Message')]:
|
_('New Private Message')):
|
||||||
dodgerblue = gtk.gdk.color_parse('dodgerblue')
|
dodgerblue = gtk.gdk.color_parse('dodgerblue')
|
||||||
close_button.modify_bg(gtk.STATE_NORMAL, dodgerblue)
|
close_button.modify_bg(gtk.STATE_NORMAL, dodgerblue)
|
||||||
eventbox.modify_bg(gtk.STATE_NORMAL, dodgerblue)
|
eventbox.modify_bg(gtk.STATE_NORMAL, dodgerblue)
|
||||||
|
@ -818,7 +818,7 @@ class PopupNotificationWindow:
|
||||||
close_button.modify_bg(gtk.STATE_NORMAL, bg_color)
|
close_button.modify_bg(gtk.STATE_NORMAL, bg_color)
|
||||||
eventbox.modify_bg(gtk.STATE_NORMAL, bg_color)
|
eventbox.modify_bg(gtk.STATE_NORMAL, bg_color)
|
||||||
event_description_label.set_text(txt)
|
event_description_label.set_text(txt)
|
||||||
elif event_type in [_('File Transfer Completed'), _('File Transfer Stopped')]:
|
elif event_type in (_('File Transfer Completed'), _('File Transfer Stopped')):
|
||||||
bg_color = gtk.gdk.color_parse('yellowgreen')
|
bg_color = gtk.gdk.color_parse('yellowgreen')
|
||||||
close_button.modify_bg(gtk.STATE_NORMAL, bg_color)
|
close_button.modify_bg(gtk.STATE_NORMAL, bg_color)
|
||||||
eventbox.modify_bg(gtk.STATE_NORMAL, bg_color)
|
eventbox.modify_bg(gtk.STATE_NORMAL, bg_color)
|
||||||
|
|
|
@ -224,7 +224,7 @@ the contact list of this account'), False)
|
||||||
def print_result(self, res):
|
def print_result(self, res):
|
||||||
''' Print retrieved result to the output '''
|
''' Print retrieved result to the output '''
|
||||||
if res is not None:
|
if res is not None:
|
||||||
if self.command in ['open_chat', 'send_message']:
|
if self.command in ('open_chat', 'send_message'):
|
||||||
if self.command == 'send_message':
|
if self.command == 'send_message':
|
||||||
self.argv_len -= 2
|
self.argv_len -= 2
|
||||||
|
|
||||||
|
@ -327,10 +327,10 @@ Please specify account for sending the message.') % sys.argv[2])
|
||||||
def print_info(self, level, prop_dict):
|
def print_info(self, level, prop_dict):
|
||||||
''' return formated string from serialized vcard data '''
|
''' return formated string from serialized vcard data '''
|
||||||
if prop_dict is None or type(prop_dict) \
|
if prop_dict is None or type(prop_dict) \
|
||||||
not in [dict, list, tuple]:
|
not in (dict, list, tuple):
|
||||||
return ''
|
return ''
|
||||||
ret_str = ''
|
ret_str = ''
|
||||||
if type(prop_dict) in [list, tuple]:
|
if type(prop_dict) in (list, tuple):
|
||||||
ret_str = ''
|
ret_str = ''
|
||||||
spacing = ' ' * level * 4
|
spacing = ' ' * level * 4
|
||||||
for val in prop_dict:
|
for val in prop_dict:
|
||||||
|
@ -428,7 +428,7 @@ Please specify account for sending the message.') % sys.argv[2])
|
||||||
_str += '\''
|
_str += '\''
|
||||||
elif chr == '\"':
|
elif chr == '\"':
|
||||||
_str += '\"'
|
_str += '\"'
|
||||||
elif chr in ['u', 'x'] and is_unicode:
|
elif chr in ('u', 'x') and is_unicode:
|
||||||
slashes -= 1
|
slashes -= 1
|
||||||
_str += '\\' + chr
|
_str += '\\' + chr
|
||||||
else:
|
else:
|
||||||
|
@ -469,7 +469,7 @@ Please specify account for sending the message.') % sys.argv[2])
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
return (_dict, next[1:])
|
return (_dict, next[1:])
|
||||||
elif first_char in ['[', '(']: # return list
|
elif first_char in ('[', '('): # return list
|
||||||
_tuple = []
|
_tuple = []
|
||||||
if value[1] == ']':
|
if value[1] == ']':
|
||||||
return ([], value[2:])
|
return ([], value[2:])
|
||||||
|
@ -486,7 +486,7 @@ Please specify account for sending the message.') % sys.argv[2])
|
||||||
break
|
break
|
||||||
if next[0] == ',':
|
if next[0] == ',':
|
||||||
value = next
|
value = next
|
||||||
elif next[0] in [']', ')']:
|
elif next[0] in (']', ')'):
|
||||||
break
|
break
|
||||||
return (_tuple, next[1:])
|
return (_tuple, next[1:])
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@ class Interface:
|
||||||
def handle_event_error_answer(self, account, array):
|
def handle_event_error_answer(self, account, array):
|
||||||
#('ERROR_ANSWER', account, (id, jid_from. errmsg, errcode))
|
#('ERROR_ANSWER', account, (id, jid_from. errmsg, errcode))
|
||||||
id, jid_from, errmsg, errcode = array
|
id, jid_from, errmsg, errcode = array
|
||||||
if unicode(errcode) in ['403', '406'] and id:
|
if unicode(errcode) in ('403', '406') and id:
|
||||||
# show the error dialog
|
# show the error dialog
|
||||||
ft = self.windows['file_transfers']
|
ft = self.windows['file_transfers']
|
||||||
sid = id
|
sid = id
|
||||||
|
|
|
@ -231,7 +231,7 @@ class RosterWindow:
|
||||||
elif jid.find('@') <= 0: # if not '@' or '@' starts the jid ==> agent
|
elif jid.find('@') <= 0: # if not '@' or '@' starts the jid ==> agent
|
||||||
img = state_images[contact.show]
|
img = state_images[contact.show]
|
||||||
else:
|
else:
|
||||||
if contact.sub in ['both', 'to']:
|
if contact.sub in ('both', 'to'):
|
||||||
img = state_images[contact.show]
|
img = state_images[contact.show]
|
||||||
else:
|
else:
|
||||||
if contact.ask == 'subscribe':
|
if contact.ask == 'subscribe':
|
||||||
|
@ -1043,7 +1043,7 @@ class RosterWindow:
|
||||||
sub_menu = gtk.Menu()
|
sub_menu = gtk.Menu()
|
||||||
status_menuitem.set_submenu(sub_menu)
|
status_menuitem.set_submenu(sub_menu)
|
||||||
|
|
||||||
for show in ['online', 'chat', 'away', 'xa', 'dnd', 'invisible']:
|
for show in ('online', 'chat', 'away', 'xa', 'dnd', 'invisible'):
|
||||||
uf_show = helpers.get_uf_show(show, use_mnemonic = True)
|
uf_show = helpers.get_uf_show(show, use_mnemonic = True)
|
||||||
item = gtk.ImageMenuItem(uf_show)
|
item = gtk.ImageMenuItem(uf_show)
|
||||||
icon = state_images[show]
|
icon = state_images[show]
|
||||||
|
@ -2382,7 +2382,7 @@ _('If "%s" accepts this request you will know his status.') %jid)
|
||||||
|
|
||||||
self.status_combobox.set_row_separator_func(self.iter_is_separator)
|
self.status_combobox.set_row_separator_func(self.iter_is_separator)
|
||||||
|
|
||||||
for show in ['online', 'chat', 'away', 'xa', 'dnd', 'invisible']:
|
for show in ('online', 'chat', 'away', 'xa', 'dnd', 'invisible'):
|
||||||
uf_show = helpers.get_uf_show(show)
|
uf_show = helpers.get_uf_show(show)
|
||||||
liststore.append([uf_show, self.jabber_state_images[show], show, True])
|
liststore.append([uf_show, self.jabber_state_images[show], show, True])
|
||||||
# Add a Separator (self.iter_is_separator() checks on string SEPARATOR)
|
# Add a Separator (self.iter_is_separator() checks on string SEPARATOR)
|
||||||
|
|
|
@ -131,7 +131,7 @@ class Systray:
|
||||||
path = os.path.join(gajim.DATA_DIR, 'iconsets/' + iconset + '/16x16/')
|
path = os.path.join(gajim.DATA_DIR, 'iconsets/' + iconset + '/16x16/')
|
||||||
state_images = gajim.interface.roster.load_iconset(path)
|
state_images = gajim.interface.roster.load_iconset(path)
|
||||||
|
|
||||||
for show in ['online', 'chat', 'away', 'xa', 'dnd', 'invisible']:
|
for show in ('online', 'chat', 'away', 'xa', 'dnd', 'invisible'):
|
||||||
uf_show = helpers.get_uf_show(show, use_mnemonic = True)
|
uf_show = helpers.get_uf_show(show, use_mnemonic = True)
|
||||||
item = gtk.ImageMenuItem(uf_show)
|
item = gtk.ImageMenuItem(uf_show)
|
||||||
item.set_image(state_images[show])
|
item.set_image(state_images[show])
|
||||||
|
|
|
@ -268,7 +268,7 @@ class SystrayWin32(systray.Systray):
|
||||||
nb = gajim.interface.roster.nb_unread
|
nb = gajim.interface.roster.nb_unread
|
||||||
for acct in gajim.connections:
|
for acct in gajim.connections:
|
||||||
# in chat / groupchat windows
|
# in chat / groupchat windows
|
||||||
for kind in ['chats', 'gc']:
|
for kind in ('chats', 'gc'):
|
||||||
jids = gajim.interface.windows[acct][kind]
|
jids = gajim.interface.windows[acct][kind]
|
||||||
for jid in jids:
|
for jid in jids:
|
||||||
if jid != 'tabbed':
|
if jid != 'tabbed':
|
||||||
|
@ -287,7 +287,7 @@ class SystrayWin32(systray.Systray):
|
||||||
nb = gajim.interface.roster.nb_unread
|
nb = gajim.interface.roster.nb_unread
|
||||||
for acct in gajim.connections:
|
for acct in gajim.connections:
|
||||||
# in chat / groupchat windows
|
# in chat / groupchat windows
|
||||||
for kind in ['chats', 'gc']:
|
for kind in ('chats', 'gc'):
|
||||||
for jid in gajim.interface.windows[acct][kind]:
|
for jid in gajim.interface.windows[acct][kind]:
|
||||||
if jid != 'tabbed':
|
if jid != 'tabbed':
|
||||||
nb += gajim.interface.windows[acct][kind][jid].nb_unread[jid]
|
nb += gajim.interface.windows[acct][kind][jid].nb_unread[jid]
|
||||||
|
|
Loading…
Add table
Reference in a new issue