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)
|
||||
# We set the color for when it's the current tab or not
|
||||
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
|
||||
# background
|
||||
p = 0.4
|
||||
|
@ -615,7 +615,8 @@ class Chat:
|
|||
|
||||
def new_tab(self, jid):
|
||||
#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.set_compact_view(self.always_compact_view)
|
||||
|
|
|
@ -672,7 +672,7 @@ class PreferencesWindow:
|
|||
def update_text_tags(self):
|
||||
'''Update color tags in Opened Chat Windows'''
|
||||
for a in gajim.connections:
|
||||
for kind in ['chats', 'gc']:
|
||||
for kind in ('chats', 'gc'):
|
||||
windows = gajim.interface.windows[a][kind]
|
||||
if windows.has_key('tabbed'):
|
||||
windows['tabbed'].update_tags()
|
||||
|
@ -683,7 +683,7 @@ class PreferencesWindow:
|
|||
def update_text_font(self):
|
||||
'''Update text font in Opened Chat Windows'''
|
||||
for a in gajim.connections:
|
||||
for kind in ['chats', 'gc']:
|
||||
for kind in ('chats', 'gc'):
|
||||
windows = gajim.interface.windows[a][kind]
|
||||
if windows.has_key('tabbed'):
|
||||
windows['tabbed'].update_font()
|
||||
|
@ -717,7 +717,7 @@ class PreferencesWindow:
|
|||
self.on_preference_widget_font_set(widget, 'conversation_font')
|
||||
|
||||
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])
|
||||
|
||||
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]
|
||||
|
||||
#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]:
|
||||
gajim.interface.windows[name][kind][j].account = name
|
||||
|
||||
|
@ -1879,7 +1879,7 @@ class ServiceRegistrationWindow(DataFormWindow):
|
|||
nbrow = 0
|
||||
table = self.xml.get_widget('table')
|
||||
for name in self.infos.keys():
|
||||
if name in ['key', 'instructions', 'x', 'registered']:
|
||||
if name in ('key', 'instructions', 'x', 'registered'):
|
||||
continue
|
||||
if not name:
|
||||
continue
|
||||
|
@ -2849,7 +2849,8 @@ class FirstTimeWizardWindow:
|
|||
|
||||
def get_widgets(self, prefix):
|
||||
widgets = {}
|
||||
for widget in [ 'nick_entry',
|
||||
for widget in (
|
||||
'nick_entry',
|
||||
'server_comboboxentry',
|
||||
'pass_entry',
|
||||
'save_password_checkbutton',
|
||||
|
@ -2857,7 +2858,7 @@ class FirstTimeWizardWindow:
|
|||
'proxyport_entry',
|
||||
'proxyuser_entry',
|
||||
'proxypass_entry',
|
||||
'jid_label' ]:
|
||||
'jid_label'):
|
||||
widgets[widget] = self.xml.get_widget(prefix + widget)
|
||||
return widgets
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ class EditGroupsDialog:
|
|||
store = gtk.ListStore(str, bool)
|
||||
self.list.set_model(store)
|
||||
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
|
||||
iter = store.append()
|
||||
store.set(iter, 0, g)
|
||||
|
@ -795,8 +795,8 @@ class PopupNotificationWindow:
|
|||
close_button.modify_bg(gtk.STATE_NORMAL, red)
|
||||
eventbox.modify_bg(gtk.STATE_NORMAL, red)
|
||||
event_description_label.set_text(txt)
|
||||
elif event_type in [_('New Message'), _('New Single Message'),
|
||||
_('New Private Message')]:
|
||||
elif event_type in (_('New Message'), _('New Single Message'),
|
||||
_('New Private Message')):
|
||||
dodgerblue = gtk.gdk.color_parse('dodgerblue')
|
||||
close_button.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)
|
||||
eventbox.modify_bg(gtk.STATE_NORMAL, bg_color)
|
||||
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')
|
||||
close_button.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):
|
||||
''' Print retrieved result to the output '''
|
||||
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':
|
||||
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):
|
||||
''' return formated string from serialized vcard data '''
|
||||
if prop_dict is None or type(prop_dict) \
|
||||
not in [dict, list, tuple]:
|
||||
not in (dict, list, tuple):
|
||||
return ''
|
||||
ret_str = ''
|
||||
if type(prop_dict) in [list, tuple]:
|
||||
if type(prop_dict) in (list, tuple):
|
||||
ret_str = ''
|
||||
spacing = ' ' * level * 4
|
||||
for val in prop_dict:
|
||||
|
@ -428,7 +428,7 @@ Please specify account for sending the message.') % sys.argv[2])
|
|||
_str += '\''
|
||||
elif chr == '\"':
|
||||
_str += '\"'
|
||||
elif chr in ['u', 'x'] and is_unicode:
|
||||
elif chr in ('u', 'x') and is_unicode:
|
||||
slashes -= 1
|
||||
_str += '\\' + chr
|
||||
else:
|
||||
|
@ -469,7 +469,7 @@ Please specify account for sending the message.') % sys.argv[2])
|
|||
else:
|
||||
break
|
||||
return (_dict, next[1:])
|
||||
elif first_char in ['[', '(']: # return list
|
||||
elif first_char in ('[', '('): # return list
|
||||
_tuple = []
|
||||
if value[1] == ']':
|
||||
return ([], value[2:])
|
||||
|
@ -486,7 +486,7 @@ Please specify account for sending the message.') % sys.argv[2])
|
|||
break
|
||||
if next[0] == ',':
|
||||
value = next
|
||||
elif next[0] in [']', ')']:
|
||||
elif next[0] in (']', ')'):
|
||||
break
|
||||
return (_tuple, next[1:])
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ class Interface:
|
|||
def handle_event_error_answer(self, account, array):
|
||||
#('ERROR_ANSWER', account, (id, jid_from. errmsg, errcode))
|
||||
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
|
||||
ft = self.windows['file_transfers']
|
||||
sid = id
|
||||
|
|
|
@ -231,7 +231,7 @@ class RosterWindow:
|
|||
elif jid.find('@') <= 0: # if not '@' or '@' starts the jid ==> agent
|
||||
img = state_images[contact.show]
|
||||
else:
|
||||
if contact.sub in ['both', 'to']:
|
||||
if contact.sub in ('both', 'to'):
|
||||
img = state_images[contact.show]
|
||||
else:
|
||||
if contact.ask == 'subscribe':
|
||||
|
@ -1043,7 +1043,7 @@ class RosterWindow:
|
|||
sub_menu = gtk.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)
|
||||
item = gtk.ImageMenuItem(uf_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)
|
||||
|
||||
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)
|
||||
liststore.append([uf_show, self.jabber_state_images[show], show, True])
|
||||
# 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/')
|
||||
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)
|
||||
item = gtk.ImageMenuItem(uf_show)
|
||||
item.set_image(state_images[show])
|
||||
|
|
|
@ -268,7 +268,7 @@ class SystrayWin32(systray.Systray):
|
|||
nb = gajim.interface.roster.nb_unread
|
||||
for acct in gajim.connections:
|
||||
# in chat / groupchat windows
|
||||
for kind in ['chats', 'gc']:
|
||||
for kind in ('chats', 'gc'):
|
||||
jids = gajim.interface.windows[acct][kind]
|
||||
for jid in jids:
|
||||
if jid != 'tabbed':
|
||||
|
@ -287,7 +287,7 @@ class SystrayWin32(systray.Systray):
|
|||
nb = gajim.interface.roster.nb_unread
|
||||
for acct in gajim.connections:
|
||||
# in chat / groupchat windows
|
||||
for kind in ['chats', 'gc']:
|
||||
for kind in ('chats', 'gc'):
|
||||
for jid in gajim.interface.windows[acct][kind]:
|
||||
if jid != 'tabbed':
|
||||
nb += gajim.interface.windows[acct][kind][jid].nb_unread[jid]
|
||||
|
|
Loading…
Add table
Reference in a new issue