[thorstenp] replace list with tuple in for and if

This commit is contained in:
Yann Leboulanger 2008-10-11 09:42:59 +00:00
parent ba12a63d55
commit ed748fdda3
11 changed files with 37 additions and 37 deletions

View file

@ -291,8 +291,8 @@ class OptionsParser:
proxies = proxies_str.split(',') proxies = proxies_str.split(',')
for i in range(0, len(proxies)): for i in range(0, len(proxies)):
proxies[i] = proxies[i].strip() proxies[i] = proxies[i].strip()
for wrong_proxy in ['proxy65.jabber.autocom.pl', for wrong_proxy in ('proxy65.jabber.autocom.pl',
'proxy65.jabber.ccc.de']: 'proxy65.jabber.ccc.de'):
if wrong_proxy in proxies: if wrong_proxy in proxies:
proxies.remove(wrong_proxy) proxies.remove(wrong_proxy)
if not 'transfer.jabber.freenet.de' in proxies: if not 'transfer.jabber.freenet.de' in proxies:

View file

@ -195,7 +195,7 @@ class SASL(PlugIn):
resp['response']=response resp['response']=response
resp['charset']='utf-8' resp['charset']='utf-8'
sasl_data='' 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]) if key in ['nc','qop','response','charset']: sasl_data+="%s=%s,"%(key,resp[key])
else: sasl_data+='%s="%s",'%(key,resp[key]) else: sasl_data+='%s="%s",'%(key,resp[key])
########################################3333 ########################################3333

View file

@ -239,7 +239,7 @@ class SASL(PlugIn):
resp['response'] = response resp['response'] = response
resp['charset'] = 'utf-8' resp['charset'] = 'utf-8'
sasl_data='' 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']: if key in ['nc','qop','response','charset']:
sasl_data += "%s=%s," % (key,resp[key]) sasl_data += "%s=%s," % (key,resp[key])
else: else:

View file

@ -209,7 +209,7 @@ class Dispatcher(PlugIn):
def returnStanzaHandler(self,conn,stanza): def returnStanzaHandler(self,conn,stanza):
""" Return stanza back to the sender with <feature-not-implemennted/> error set. """ """ Return stanza back to the sender with <feature-not-implemennted/> error set. """
if stanza.getType() in ['get','set']: if stanza.getType() in ('get','set'):
conn.send(Error(stanza,ERR_FEATURE_NOT_IMPLEMENTED)) conn.send(Error(stanza,ERR_FEATURE_NOT_IMPLEMENTED))
def streamErrorHandler(self,conn,error): def streamErrorHandler(self,conn,error):

View file

@ -243,7 +243,7 @@ class Dispatcher(PlugIn):
def returnStanzaHandler(self,conn,stanza): def returnStanzaHandler(self,conn,stanza):
''' Return stanza back to the sender with <feature-not-implemennted/> error set. ''' ''' Return stanza back to the sender with <feature-not-implemennted/> error set. '''
if stanza.getType() in ['get','set']: if stanza.getType() in ('get','set'):
conn.send(Error(stanza,ERR_FEATURE_NOT_IMPLEMENTED)) conn.send(Error(stanza,ERR_FEATURE_NOT_IMPLEMENTED))
def streamErrorHandler(self,conn,error): def streamErrorHandler(self,conn,error):
@ -404,7 +404,7 @@ class Dispatcher(PlugIn):
def send(self, stanza, is_message = False, now = False): 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. ''' Serialise stanza and put it on the wire. Assign an unique ID to it before send.
Returns assigned ID.''' 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) return self._owner.Connection.send(stanza, now = now)
if not isinstance(stanza, Protocol): if not isinstance(stanza, Protocol):
_ID=None _ID=None

View file

@ -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 <auth/> element or <response/> element.""" temporary-auth-failure -- -- -- The authentication failed because of a temporary error condition within the receiving entity; sent in reply to an <auth/> element or <response/> element."""
ERRORS,_errorcodes={},{} 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_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:]: for err in errpool.split('\n')[1:]:
cond,code,typ,text=err.split(' -- ') cond,code,typ,text=err.split(' -- ')
name=errname+'_'+cond.upper().replace('-','_') name=errname+'_'+cond.upper().replace('-','_')

View file

@ -97,7 +97,7 @@ class Session:
self._session_state=SESSION_NOT_AUTHED self._session_state=SESSION_NOT_AUTHED
self.waiting_features=[] 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) if feature in owner.features: self.waiting_features.append(feature)
self.features=[] self.features=[]
self.feature_in_process=None self.feature_in_process=None

View file

@ -2530,7 +2530,7 @@ class PrivacyListWindow:
# Add Widgets # 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', 'list_of_rules_label', 'add_edit_rule_label', 'delete_open_buttons_hbox',
'privacy_list_active_checkbutton', 'privacy_list_default_checkbutton', 'privacy_list_active_checkbutton', 'privacy_list_default_checkbutton',
'list_of_rules_combobox', 'delete_open_buttons_hbox', 'list_of_rules_combobox', 'delete_open_buttons_hbox',
@ -2544,7 +2544,7 @@ class PrivacyListWindow:
'new_rule_button', 'save_rule_button', 'privacy_list_refresh_button', 'new_rule_button', 'save_rule_button', 'privacy_list_refresh_button',
'privacy_list_close_button', 'edit_send_status_checkbutton', 'privacy_list_close_button', 'edit_send_status_checkbutton',
'add_edit_vbox', 'privacy_list_active_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.__dict__[widget_to_add] = self.xml.get_widget(widget_to_add)
self.privacy_lists_title_label.set_label( self.privacy_lists_title_label.set_label(
@ -2825,10 +2825,10 @@ class PrivacyListsWindow:
self.xml = gtkgui_helpers.get_glade('privacy_lists_window.glade') self.xml = gtkgui_helpers.get_glade('privacy_lists_window.glade')
self.window = self.xml.get_widget('privacy_lists_first_window') 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', 'delete_privacy_list_button', 'open_privacy_list_button',
'new_privacy_list_button', 'new_privacy_list_entry', '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( self.__dict__[widget_to_add] = self.xml.get_widget(
widget_to_add) widget_to_add)
@ -3285,7 +3285,7 @@ class AdvancedNotificationsWindow:
else: else:
self.special_status_rb.set_active(True) self.special_status_rb.set_active(True)
values = value.split() values = value.split()
for v in ['online', 'away', 'xa', 'dnd', 'invisible']: for v in ('online', 'away', 'xa', 'dnd', 'invisible'):
if v in values: if v in values:
self.__dict__[v + '_cb'].set_active(True) self.__dict__[v + '_cb'].set_active(True)
else: else:
@ -3305,7 +3305,7 @@ class AdvancedNotificationsWindow:
'sound_file') 'sound_file')
self.sound_entry.set_text(value) self.sound_entry.set_text(value)
# sound, popup, auto_open, systray, roster # 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), value = gajim.config.get_per('notifications', str(self.active_num),
option) option)
if value == 'yes': if value == 'yes':
@ -3342,7 +3342,7 @@ class AdvancedNotificationsWindow:
status = '' status = ''
else: else:
status = _('when I am ') 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(): if self.__dict__[st + '_cb'].get_active():
status += helpers.get_uf_show(st) + ' ' status += helpers.get_uf_show(st) + ' '
model[iter][1] = "When %s for %s %s %s" % (event, recipient_type, model[iter][1] = "When %s for %s %s %s" % (event, recipient_type,
@ -3475,7 +3475,7 @@ class AdvancedNotificationsWindow:
if self.active_num < 0: if self.active_num < 0:
return return
status = '' status = ''
for st in ['online', 'away', 'xa', 'dnd', 'invisible']: for st in ('online', 'away', 'xa', 'dnd', 'invisible'):
if self.__dict__[st + '_cb'].get_active(): if self.__dict__[st + '_cb'].get_active():
status += st + ' ' status += st + ' '
if status: if status:
@ -3491,14 +3491,14 @@ class AdvancedNotificationsWindow:
gajim.config.set_per('notifications', str(self.active_num), 'status', gajim.config.set_per('notifications', str(self.active_num), 'status',
'all') 'all')
# 'All status' clicked # '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.__dict__[st + '_cb'].hide()
self.special_status_rb.show() self.special_status_rb.show()
else: else:
self.set_status_config() self.set_status_config()
# 'special status' clicked # '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.__dict__[st + '_cb'].show()
self.special_status_rb.hide() self.special_status_rb.hide()

View file

@ -1447,7 +1447,7 @@ class GroupchatControl(ChatControlBase):
else: else:
nick1 = nick0 nick1 = nick0
nicks = gajim.contacts.get_nick_list(self.account, self.room_jid) 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: if nick in nicks:
self.on_send_pm(nick = nick) self.on_send_pm(nick = nick)
self.clear(self.msg_textview) self.clear(self.msg_textview)

View file

@ -528,10 +528,10 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
# build a dictionary mapping styles to methods, for greater speed # build a dictionary mapping styles to methods, for greater speed
__style_methods = dict() __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', 'font-style', 'font-weight', 'margin-left', 'margin-right',
'text-align', 'text-decoration', 'white-space', 'display', 'text-align', 'text-decoration', 'white-space', 'display',
'width', 'height' ]: 'width', 'height' ):
try: try:
method = locals()['_parse_style_%s' % style.replace('-', '_')] method = locals()['_parse_style_%s' % style.replace('-', '_')]
except KeyError: except KeyError:

View file

@ -2070,9 +2070,9 @@ class RosterWindow:
for jid in gajim.contacts.get_jid_list(account): for jid in gajim.contacts.get_jid_list(account):
lcontact = gajim.contacts.get_contacts(account, jid) lcontact = gajim.contacts.get_contacts(account, jid)
ctrl = gajim.interface.msg_win_mgr.get_gc_control(jid, account) ctrl = gajim.interface.msg_win_mgr.get_gc_control(jid, account)
for contact in [c for c in lcontact if ((c.show != 'offline' or for contact in lcontact:
c.is_transport()) and not ctrl)]: if (contact.show != 'offline' or contact.is_transport()) and not ctrl:
self.chg_contact_status(contact, 'offline', '', account) self.chg_contact_status(contact, 'offline', '', account)
self.actions_menu_needs_rebuild = True self.actions_menu_needs_rebuild = True
self.update_status_combobox() self.update_status_combobox()
# Force the rebuild now since the on_activates on the menu itself does # Force the rebuild now since the on_activates on the menu itself does
@ -4675,9 +4675,9 @@ class RosterWindow:
if connected_accounts == 0: if connected_accounts == 0:
# no connected accounts, make the menuitems insensitive # 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,\ add_new_contact_menuitem, service_disco_menuitem,\
single_message_menuitem]: single_message_menuitem):
item.set_sensitive(False) item.set_sensitive(False)
else: # we have one or more connected accounts else: # we have one or more connected accounts
for item in (new_chat_menuitem, join_gc_menuitem, for item in (new_chat_menuitem, join_gc_menuitem,
@ -4903,9 +4903,9 @@ class RosterWindow:
# make some items insensitive if account is offline # make some items insensitive if account is offline
if gajim.connections[account].connected < 2: 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, join_group_chat_menuitem, execute_command_menuitem, pep_menuitem,
start_chat_menuitem]: start_chat_menuitem):
widget.set_sensitive(False) widget.set_sensitive(False)
else: else:
xml = gtkgui_helpers.get_glade('zeroconf_context_menu.glade') xml = gtkgui_helpers.get_glade('zeroconf_context_menu.glade')
@ -5069,7 +5069,7 @@ class RosterWindow:
send_custom_status_menuitem.set_submenu(status_menuitems) send_custom_status_menuitem.set_submenu(status_menuitems)
iconset = gajim.config.get('iconset') iconset = gajim.config.get('iconset')
path = os.path.join(helpers.get_iconset_path(iconset), '16x16') 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 # icon MUST be different instance for every item
state_images = gtkgui_helpers.load_iconset(path) state_images = gtkgui_helpers.load_iconset(path)
status_menuitem = gtk.ImageMenuItem(helpers.get_uf_show(s)) status_menuitem = gtk.ImageMenuItem(helpers.get_uf_show(s))
@ -5266,8 +5266,8 @@ class RosterWindow:
# Unsensitive many items when account is offline # Unsensitive many items when account is offline
if gajim.connections[account].connected < 2: if gajim.connections[account].connected < 2:
for widget in [start_chat_menuitem, rename_menuitem, for widget in (start_chat_menuitem, rename_menuitem,
edit_groups_menuitem, send_file_menuitem]: edit_groups_menuitem, send_file_menuitem):
widget.set_sensitive(False) widget.set_sensitive(False)
event_button = gtkgui_helpers.get_possible_button_event(event) event_button = gtkgui_helpers.get_possible_button_event(event)
@ -5369,7 +5369,7 @@ class RosterWindow:
send_custom_status_menuitem.set_submenu(status_menuitems) send_custom_status_menuitem.set_submenu(status_menuitems)
iconset = gajim.config.get('iconset') iconset = gajim.config.get('iconset')
path = os.path.join(helpers.get_iconset_path(iconset), '16x16') 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 # icon MUST be different instance for every item
state_images = gtkgui_helpers.load_iconset(path) state_images = gtkgui_helpers.load_iconset(path)
status_menuitem = gtk.ImageMenuItem(helpers.get_uf_show(s)) status_menuitem = gtk.ImageMenuItem(helpers.get_uf_show(s))
@ -5473,11 +5473,11 @@ class RosterWindow:
# Unsensitive many items when account is offline # Unsensitive many items when account is offline
if gajim.connections[account].connected < 2: 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, rename_menuitem, edit_groups_menuitem, send_file_menuitem,
subscription_menuitem, add_to_roster_menuitem, subscription_menuitem, add_to_roster_menuitem,
remove_from_roster_menuitem, execute_command_menuitem, remove_from_roster_menuitem, execute_command_menuitem,
send_custom_status_menuitem]: send_custom_status_menuitem):
widget.set_sensitive(False) widget.set_sensitive(False)
if gajim.connections[account] and gajim.connections[account].\ if gajim.connections[account] and gajim.connections[account].\
@ -5661,7 +5661,7 @@ class RosterWindow:
send_custom_status_menuitem.set_submenu(status_menuitems) send_custom_status_menuitem.set_submenu(status_menuitems)
iconset = gajim.config.get('iconset') iconset = gajim.config.get('iconset')
path = os.path.join(helpers.get_iconset_path(iconset), '16x16') 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 # icon MUST be different instance for every item
state_images = gtkgui_helpers.load_iconset(path) state_images = gtkgui_helpers.load_iconset(path)
status_menuitem = gtk.ImageMenuItem(helpers.get_uf_show(s)) status_menuitem = gtk.ImageMenuItem(helpers.get_uf_show(s))