From ed748fdda3f494300dd76638745805d77e2b52ce Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Sat, 11 Oct 2008 09:42:59 +0000 Subject: [thorstenp] replace list with tuple in for and if --- src/common/optparser.py | 4 ++-- src/common/xmpp/auth.py | 2 +- src/common/xmpp/auth_nb.py | 2 +- src/common/xmpp/dispatcher.py | 2 +- src/common/xmpp/dispatcher_nb.py | 4 ++-- src/common/xmpp/protocol.py | 4 ++-- src/common/xmpp/session.py | 2 +- src/dialogs.py | 20 ++++++++++---------- src/groupchat_control.py | 2 +- src/htmltextview.py | 4 ++-- src/roster_window.py | 28 ++++++++++++++-------------- 11 files changed, 37 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/common/optparser.py b/src/common/optparser.py index 5c4f05da2..7ddf060b3 100644 --- a/src/common/optparser.py +++ b/src/common/optparser.py @@ -291,8 +291,8 @@ class OptionsParser: proxies = proxies_str.split(',') for i in range(0, len(proxies)): proxies[i] = proxies[i].strip() - for wrong_proxy in ['proxy65.jabber.autocom.pl', - 'proxy65.jabber.ccc.de']: + for wrong_proxy in ('proxy65.jabber.autocom.pl', + 'proxy65.jabber.ccc.de'): if wrong_proxy in proxies: proxies.remove(wrong_proxy) if not 'transfer.jabber.freenet.de' in proxies: diff --git a/src/common/xmpp/auth.py b/src/common/xmpp/auth.py index f524e2e11..550b479db 100644 --- a/src/common/xmpp/auth.py +++ b/src/common/xmpp/auth.py @@ -195,7 +195,7 @@ class SASL(PlugIn): resp['response']=response resp['charset']='utf-8' sasl_data='' - for key in ['charset','username','realm','nonce','nc','cnonce','digest-uri','response','qop']: + for key in ('charset','username','realm','nonce','nc','cnonce','digest-uri','response','qop'): if key in ['nc','qop','response','charset']: sasl_data+="%s=%s,"%(key,resp[key]) else: sasl_data+='%s="%s",'%(key,resp[key]) ########################################3333 diff --git a/src/common/xmpp/auth_nb.py b/src/common/xmpp/auth_nb.py index 399298452..2e09bcf1d 100644 --- a/src/common/xmpp/auth_nb.py +++ b/src/common/xmpp/auth_nb.py @@ -239,7 +239,7 @@ class SASL(PlugIn): resp['response'] = response resp['charset'] = 'utf-8' sasl_data='' - for key in ['charset', 'username', 'realm', 'nonce', 'nc', 'cnonce', 'digest-uri', 'response', 'qop']: + for key in ('charset', 'username', 'realm', 'nonce', 'nc', 'cnonce', 'digest-uri', 'response', 'qop'): if key in ['nc','qop','response','charset']: sasl_data += "%s=%s," % (key,resp[key]) else: diff --git a/src/common/xmpp/dispatcher.py b/src/common/xmpp/dispatcher.py index e2ae23c1e..d8fb4a58b 100644 --- a/src/common/xmpp/dispatcher.py +++ b/src/common/xmpp/dispatcher.py @@ -209,7 +209,7 @@ class Dispatcher(PlugIn): def returnStanzaHandler(self,conn,stanza): """ Return stanza back to the sender with error set. """ - if stanza.getType() in ['get','set']: + if stanza.getType() in ('get','set'): conn.send(Error(stanza,ERR_FEATURE_NOT_IMPLEMENTED)) def streamErrorHandler(self,conn,error): diff --git a/src/common/xmpp/dispatcher_nb.py b/src/common/xmpp/dispatcher_nb.py index ab865157d..98cd77770 100644 --- a/src/common/xmpp/dispatcher_nb.py +++ b/src/common/xmpp/dispatcher_nb.py @@ -243,7 +243,7 @@ class Dispatcher(PlugIn): def returnStanzaHandler(self,conn,stanza): ''' Return stanza back to the sender with error set. ''' - if stanza.getType() in ['get','set']: + if stanza.getType() in ('get','set'): conn.send(Error(stanza,ERR_FEATURE_NOT_IMPLEMENTED)) def streamErrorHandler(self,conn,error): @@ -404,7 +404,7 @@ class Dispatcher(PlugIn): def send(self, stanza, is_message = False, now = False): ''' Serialise stanza and put it on the wire. Assign an unique ID to it before send. Returns assigned ID.''' - if type(stanza) in [type(''), type(u'')]: + if type(stanza) in (type(''), type(u'')): return self._owner.Connection.send(stanza, now = now) if not isinstance(stanza, Protocol): _ID=None diff --git a/src/common/xmpp/protocol.py b/src/common/xmpp/protocol.py index 3570cdbab..800bf4a0d 100644 --- a/src/common/xmpp/protocol.py +++ b/src/common/xmpp/protocol.py @@ -173,9 +173,9 @@ not-authorized -- -- -- The authentication failed because the initiating entit temporary-auth-failure -- -- -- The authentication failed because of a temporary error condition within the receiving entity; sent in reply to an element or element.""" ERRORS,_errorcodes={},{} -for ns,errname,errpool in [(NS_XMPP_STREAMS,'STREAM',xmpp_stream_error_conditions), +for ns,errname,errpool in ((NS_XMPP_STREAMS,'STREAM',xmpp_stream_error_conditions), (NS_STANZAS ,'ERR' ,xmpp_stanza_error_conditions), - (NS_SASL ,'SASL' ,sasl_error_conditions)]: + (NS_SASL ,'SASL' ,sasl_error_conditions)): for err in errpool.split('\n')[1:]: cond,code,typ,text=err.split(' -- ') name=errname+'_'+cond.upper().replace('-','_') diff --git a/src/common/xmpp/session.py b/src/common/xmpp/session.py index 392692a28..7f034db07 100644 --- a/src/common/xmpp/session.py +++ b/src/common/xmpp/session.py @@ -97,7 +97,7 @@ class Session: self._session_state=SESSION_NOT_AUTHED self.waiting_features=[] - for feature in [NS_TLS,NS_SASL,NS_BIND,NS_SESSION]: + for feature in (NS_TLS,NS_SASL,NS_BIND,NS_SESSION): if feature in owner.features: self.waiting_features.append(feature) self.features=[] self.feature_in_process=None diff --git a/src/dialogs.py b/src/dialogs.py index 7411f764b..31ca52d3d 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -2530,7 +2530,7 @@ class PrivacyListWindow: # Add Widgets - for widget_to_add in ['title_hbox', 'privacy_lists_title_label', + for widget_to_add in ('title_hbox', 'privacy_lists_title_label', 'list_of_rules_label', 'add_edit_rule_label', 'delete_open_buttons_hbox', 'privacy_list_active_checkbutton', 'privacy_list_default_checkbutton', 'list_of_rules_combobox', 'delete_open_buttons_hbox', @@ -2544,7 +2544,7 @@ class PrivacyListWindow: 'new_rule_button', 'save_rule_button', 'privacy_list_refresh_button', 'privacy_list_close_button', 'edit_send_status_checkbutton', 'add_edit_vbox', 'privacy_list_active_checkbutton', - 'privacy_list_default_checkbutton']: + 'privacy_list_default_checkbutton'): self.__dict__[widget_to_add] = self.xml.get_widget(widget_to_add) self.privacy_lists_title_label.set_label( @@ -2825,10 +2825,10 @@ class PrivacyListsWindow: self.xml = gtkgui_helpers.get_glade('privacy_lists_window.glade') self.window = self.xml.get_widget('privacy_lists_first_window') - for widget_to_add in ['list_of_privacy_lists_combobox', + for widget_to_add in ('list_of_privacy_lists_combobox', 'delete_privacy_list_button', 'open_privacy_list_button', 'new_privacy_list_button', 'new_privacy_list_entry', - 'privacy_lists_refresh_button', 'close_privacy_lists_window_button']: + 'privacy_lists_refresh_button', 'close_privacy_lists_window_button'): self.__dict__[widget_to_add] = self.xml.get_widget( widget_to_add) @@ -3285,7 +3285,7 @@ class AdvancedNotificationsWindow: else: self.special_status_rb.set_active(True) values = value.split() - for v in ['online', 'away', 'xa', 'dnd', 'invisible']: + for v in ('online', 'away', 'xa', 'dnd', 'invisible'): if v in values: self.__dict__[v + '_cb'].set_active(True) else: @@ -3305,7 +3305,7 @@ class AdvancedNotificationsWindow: 'sound_file') self.sound_entry.set_text(value) # sound, popup, auto_open, systray, roster - for option in ['sound', 'popup', 'auto_open', 'systray', 'roster']: + for option in ('sound', 'popup', 'auto_open', 'systray', 'roster'): value = gajim.config.get_per('notifications', str(self.active_num), option) if value == 'yes': @@ -3342,7 +3342,7 @@ class AdvancedNotificationsWindow: status = '' else: status = _('when I am ') - for st in ['online', 'away', 'xa', 'dnd', 'invisible']: + for st in ('online', 'away', 'xa', 'dnd', 'invisible'): if self.__dict__[st + '_cb'].get_active(): status += helpers.get_uf_show(st) + ' ' model[iter][1] = "When %s for %s %s %s" % (event, recipient_type, @@ -3475,7 +3475,7 @@ class AdvancedNotificationsWindow: if self.active_num < 0: return status = '' - for st in ['online', 'away', 'xa', 'dnd', 'invisible']: + for st in ('online', 'away', 'xa', 'dnd', 'invisible'): if self.__dict__[st + '_cb'].get_active(): status += st + ' ' if status: @@ -3491,14 +3491,14 @@ class AdvancedNotificationsWindow: gajim.config.set_per('notifications', str(self.active_num), 'status', 'all') # 'All status' clicked - for st in ['online', 'away', 'xa', 'dnd', 'invisible']: + for st in ('online', 'away', 'xa', 'dnd', 'invisible'): self.__dict__[st + '_cb'].hide() self.special_status_rb.show() else: self.set_status_config() # 'special status' clicked - for st in ['online', 'away', 'xa', 'dnd', 'invisible']: + for st in ('online', 'away', 'xa', 'dnd', 'invisible'): self.__dict__[st + '_cb'].show() self.special_status_rb.hide() diff --git a/src/groupchat_control.py b/src/groupchat_control.py index e4f258f68..9f89dbb92 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -1447,7 +1447,7 @@ class GroupchatControl(ChatControlBase): else: nick1 = nick0 nicks = gajim.contacts.get_nick_list(self.account, self.room_jid) - for nick in [nick0, nick1]: + for nick in (nick0, nick1): if nick in nicks: self.on_send_pm(nick = nick) self.clear(self.msg_textview) diff --git a/src/htmltextview.py b/src/htmltextview.py index 2849461c5..773ebb8bc 100644 --- a/src/htmltextview.py +++ b/src/htmltextview.py @@ -528,10 +528,10 @@ class HtmlHandler(xml.sax.handler.ContentHandler): # build a dictionary mapping styles to methods, for greater speed __style_methods = dict() - for style in ['background-color', 'color', 'font-family', 'font-size', + for style in ('background-color', 'color', 'font-family', 'font-size', 'font-style', 'font-weight', 'margin-left', 'margin-right', 'text-align', 'text-decoration', 'white-space', 'display', - 'width', 'height' ]: + 'width', 'height' ): try: method = locals()['_parse_style_%s' % style.replace('-', '_')] except KeyError: diff --git a/src/roster_window.py b/src/roster_window.py index 234484d02..91fcdcc67 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -2070,9 +2070,9 @@ class RosterWindow: for jid in gajim.contacts.get_jid_list(account): lcontact = gajim.contacts.get_contacts(account, jid) ctrl = gajim.interface.msg_win_mgr.get_gc_control(jid, account) - for contact in [c for c in lcontact if ((c.show != 'offline' or - c.is_transport()) and not ctrl)]: - self.chg_contact_status(contact, 'offline', '', account) + for contact in lcontact: + if (contact.show != 'offline' or contact.is_transport()) and not ctrl: + self.chg_contact_status(contact, 'offline', '', account) self.actions_menu_needs_rebuild = True self.update_status_combobox() # Force the rebuild now since the on_activates on the menu itself does @@ -4675,9 +4675,9 @@ class RosterWindow: if connected_accounts == 0: # no connected accounts, make the menuitems insensitive - for item in [new_chat_menuitem, join_gc_menuitem,\ + for item in (new_chat_menuitem, join_gc_menuitem,\ add_new_contact_menuitem, service_disco_menuitem,\ - single_message_menuitem]: + single_message_menuitem): item.set_sensitive(False) else: # we have one or more connected accounts for item in (new_chat_menuitem, join_gc_menuitem, @@ -4903,9 +4903,9 @@ class RosterWindow: # make some items insensitive if account is offline if gajim.connections[account].connected < 2: - for widget in [add_contact_menuitem, service_discovery_menuitem, + for widget in (add_contact_menuitem, service_discovery_menuitem, join_group_chat_menuitem, execute_command_menuitem, pep_menuitem, - start_chat_menuitem]: + start_chat_menuitem): widget.set_sensitive(False) else: xml = gtkgui_helpers.get_glade('zeroconf_context_menu.glade') @@ -5069,7 +5069,7 @@ class RosterWindow: send_custom_status_menuitem.set_submenu(status_menuitems) iconset = gajim.config.get('iconset') path = os.path.join(helpers.get_iconset_path(iconset), '16x16') - for s in ['online', 'chat', 'away', 'xa', 'dnd', 'offline']: + for s in ('online', 'chat', 'away', 'xa', 'dnd', 'offline'): # icon MUST be different instance for every item state_images = gtkgui_helpers.load_iconset(path) status_menuitem = gtk.ImageMenuItem(helpers.get_uf_show(s)) @@ -5266,8 +5266,8 @@ class RosterWindow: # Unsensitive many items when account is offline if gajim.connections[account].connected < 2: - for widget in [start_chat_menuitem, rename_menuitem, - edit_groups_menuitem, send_file_menuitem]: + for widget in (start_chat_menuitem, rename_menuitem, + edit_groups_menuitem, send_file_menuitem): widget.set_sensitive(False) event_button = gtkgui_helpers.get_possible_button_event(event) @@ -5369,7 +5369,7 @@ class RosterWindow: send_custom_status_menuitem.set_submenu(status_menuitems) iconset = gajim.config.get('iconset') path = os.path.join(helpers.get_iconset_path(iconset), '16x16') - for s in ['online', 'chat', 'away', 'xa', 'dnd', 'offline']: + for s in ('online', 'chat', 'away', 'xa', 'dnd', 'offline'): # icon MUST be different instance for every item state_images = gtkgui_helpers.load_iconset(path) status_menuitem = gtk.ImageMenuItem(helpers.get_uf_show(s)) @@ -5473,11 +5473,11 @@ class RosterWindow: # Unsensitive many items when account is offline if gajim.connections[account].connected < 2: - for widget in [start_chat_menuitem, send_single_message_menuitem, + for widget in (start_chat_menuitem, send_single_message_menuitem, rename_menuitem, edit_groups_menuitem, send_file_menuitem, subscription_menuitem, add_to_roster_menuitem, remove_from_roster_menuitem, execute_command_menuitem, - send_custom_status_menuitem]: + send_custom_status_menuitem): widget.set_sensitive(False) if gajim.connections[account] and gajim.connections[account].\ @@ -5661,7 +5661,7 @@ class RosterWindow: send_custom_status_menuitem.set_submenu(status_menuitems) iconset = gajim.config.get('iconset') path = os.path.join(helpers.get_iconset_path(iconset), '16x16') - for s in ['online', 'chat', 'away', 'xa', 'dnd', 'offline']: + for s in ('online', 'chat', 'away', 'xa', 'dnd', 'offline'): # icon MUST be different instance for every item state_images = gtkgui_helpers.load_iconset(path) status_menuitem = gtk.ImageMenuItem(helpers.get_uf_show(s)) -- cgit v1.2.3