[thorstenp] replace has_key by key in dict. Fixes #4392

This commit is contained in:
Yann Leboulanger 2008-10-07 20:41:59 +00:00
parent 96dd7b8ba7
commit 9d7c80d522
60 changed files with 597 additions and 600 deletions

View file

@ -144,7 +144,7 @@ class AdvancedConfigurationWindow(object):
self.desc_label.set_text(_('(None)')) self.desc_label.set_text(_('(None)'))
def remember_option(self, option, oldval, newval): def remember_option(self, option, oldval, newval):
if self.changed_opts.has_key(option): if option in self.changed_opts:
self.changed_opts[option] = (self.changed_opts[option][0], newval) self.changed_opts[option] = (self.changed_opts[option][0], newval)
else: else:
self.changed_opts[option] = (oldval, newval) self.changed_opts[option] = (oldval, newval)

View file

@ -764,7 +764,7 @@ class ChatControlBase(MessageControl):
if not jid: if not jid:
jid = self.contact.jid jid = self.contact.jid
if gajim.interface.instances.has_key('logs'): if 'logs' in gajim.interface.instances:
gajim.interface.instances['logs'].window.present() gajim.interface.instances['logs'].window.present()
gajim.interface.instances['logs'].open_history(jid, self.account) gajim.interface.instances['logs'].open_history(jid, self.account)
else: else:
@ -1190,9 +1190,9 @@ class ChatControl(ChatControlBase):
if isinstance(self.contact, GC_Contact): if isinstance(self.contact, GC_Contact):
return return
if self.contact.mood.has_key('mood'): if 'mood' in self.contact.mood:
mood = self.contact.mood['mood'].strip() mood = self.contact.mood['mood'].strip()
if self.contact.mood.has_key('text'): if 'text' in self.contact.mood:
text = self.contact.mood['text'].strip() text = self.contact.mood['text'].strip()
if mood is not None: if mood is not None:
@ -1230,11 +1230,11 @@ class ChatControl(ChatControlBase):
if isinstance(self.contact, GC_Contact): if isinstance(self.contact, GC_Contact):
return return
if self.contact.activity.has_key('activity'): if 'activity' in self.contact.activity:
activity = self.contact.activity['activity'].strip() activity = self.contact.activity['activity'].strip()
if self.contact.activity.has_key('subactivity'): if 'subactivity' in self.contact.activity:
subactivity = self.contact.activity['subactivity'].strip() subactivity = self.contact.activity['subactivity'].strip()
if self.contact.activity.has_key('text'): if 'text' in self.contact.activity:
text = self.contact.activity['text'].strip() text = self.contact.activity['text'].strip()
if activity is not None: if activity is not None:
@ -1280,15 +1280,15 @@ class ChatControl(ChatControlBase):
if isinstance(self.contact, GC_Contact): if isinstance(self.contact, GC_Contact):
return return
if self.contact.tune.has_key('artist'): if 'artist' in self.contact.tune:
artist = self.contact.tune['artist'].strip() artist = self.contact.tune['artist'].strip()
if HAVE_MARKUP_TOOLTIPS: if HAVE_MARKUP_TOOLTIPS:
artist = gobject.markup_escape_text(artist) artist = gobject.markup_escape_text(artist)
if self.contact.tune.has_key('title'): if 'title' in self.contact.tune:
title = self.contact.tune['title'].strip() title = self.contact.tune['title'].strip()
if HAVE_MARKUP_TOOLTIPS: if HAVE_MARKUP_TOOLTIPS:
title = gobject.markup_escape_text(title) title = gobject.markup_escape_text(title)
if self.contact.tune.has_key('source'): if 'source' in self.contact.tune:
source = self.contact.tune['source'].strip() source = self.contact.tune['source'].strip()
if HAVE_MARKUP_TOOLTIPS: if HAVE_MARKUP_TOOLTIPS:
source = gobject.markup_escape_text(source) source = gobject.markup_escape_text(source)
@ -1396,7 +1396,7 @@ class ChatControl(ChatControlBase):
size = '32', icon_name = show) size = '32', icon_name = show)
img_16 = gajim.interface.roster.get_appropriate_state_images(jid, img_16 = gajim.interface.roster.get_appropriate_state_images(jid,
icon_name = show) icon_name = show)
if img_32.has_key(show) and img_32[show].get_pixbuf(): if show in img_32 and img_32[show].get_pixbuf():
# we have 32x32! use it! # we have 32x32! use it!
banner_image = img_32[show] banner_image = img_32[show]
use_size_32 = True use_size_32 = True

View file

@ -140,7 +140,7 @@ if gajim.HAVE_GPG:
try: proc.wait() try: proc.wait()
except IOError: pass except IOError: pass
if resp.has_key('GOOD_PASSPHRASE') or resp.has_key('SIG_CREATED'): if 'GOOD_PASSPHRASE' in resp or 'SIG_CREATED' in resp:
return self._stripHeaderFooter(output) return self._stripHeaderFooter(output)
return 'BAD_PASSPHRASE' return 'BAD_PASSPHRASE'
@ -168,7 +168,7 @@ if gajim.HAVE_GPG:
except IOError: pass except IOError: pass
keyid = '' keyid = ''
if resp.has_key('GOODSIG'): if 'GOODSIG' in resp:
keyid = resp['GOODSIG'].split()[0] keyid = resp['GOODSIG'].split()[0]
return keyid return keyid

View file

@ -342,14 +342,14 @@ class GnuPG:
if attach_fhs is None: attach_fhs = {} if attach_fhs is None: attach_fhs = {}
for std in _stds: for std in _stds:
if not attach_fhs.has_key(std) \ if std not in attach_fhs \
and std not in create_fhs: and std not in create_fhs:
attach_fhs.setdefault(std, getattr(sys, std)) attach_fhs.setdefault(std, getattr(sys, std))
handle_passphrase = 0 handle_passphrase = 0
if self.passphrase is not None \ if self.passphrase is not None \
and not attach_fhs.has_key('passphrase') \ and 'passphrase' not in attach_fhs \
and 'passphrase' not in create_fhs: and 'passphrase' not in create_fhs:
handle_passphrase = 1 handle_passphrase = 1
create_fhs.append('passphrase') create_fhs.append('passphrase')
@ -373,7 +373,7 @@ class GnuPG:
process = Process() process = Process()
for fh_name in create_fhs + attach_fhs.keys(): for fh_name in create_fhs + attach_fhs.keys():
if not _fd_modes.has_key(fh_name): if fh_name not in _fd_modes:
raise KeyError, \ raise KeyError, \
"unrecognized filehandle name '%s'; must be one of %s" \ "unrecognized filehandle name '%s'; must be one of %s" \
% (fh_name, _fd_modes.keys()) % (fh_name, _fd_modes.keys())
@ -381,7 +381,7 @@ class GnuPG:
for fh_name in create_fhs: for fh_name in create_fhs:
# make sure the user doesn't specify a filehandle # make sure the user doesn't specify a filehandle
# to be created *and* attached # to be created *and* attached
if attach_fhs.has_key(fh_name): if fh_name in attach_fhs:
raise ValueError, \ raise ValueError, \
"cannot have filehandle '%s' in both create_fhs and attach_fhs" \ "cannot have filehandle '%s' in both create_fhs and attach_fhs" \
% fh_name % fh_name

View file

@ -124,7 +124,7 @@ class OldEntry(xmpp.Node, object):
''' Get the uri the entry points to (entry's first link element with rel='alternate' ''' Get the uri the entry points to (entry's first link element with rel='alternate'
or without rel attribute). ''' or without rel attribute). '''
for element in self.getTags('link'): for element in self.getTags('link'):
if element.attrs.has_key('rel') and element.attrs['rel']<>'alternate': continue if 'rel' in element.attrs and element.attrs['rel']<>'alternate': continue
try: try:
return element.attrs['href'] return element.attrs['href']
except AttributeError: except AttributeError:

View file

@ -166,7 +166,7 @@ def find_current_groupchats(account):
continue continue
room_jid = gc_control.room_jid room_jid = gc_control.room_jid
nick = gc_control.nick nick = gc_control.nick
if gajim.gc_connected[acct].has_key(room_jid) and \ if room_jid in gajim.gc_connected[acct] and \
gajim.gc_connected[acct][room_jid]: gajim.gc_connected[acct][room_jid]:
rooms.append((room_jid, nick,)) rooms.append((room_jid, nick,))
return rooms return rooms

View file

@ -518,7 +518,7 @@ class Config:
return None return None
def set(self, optname, value): def set(self, optname, value):
if not self.__options.has_key(optname): if optname not in self.__options:
# raise RuntimeError, 'option %s does not exist' % optname # raise RuntimeError, 'option %s does not exist' % optname
return return
opt = self.__options[optname] opt = self.__options[optname]
@ -532,35 +532,35 @@ class Config:
def get(self, optname = None): def get(self, optname = None):
if not optname: if not optname:
return self.__options.keys() return self.__options.keys()
if not self.__options.has_key(optname): if optname not in self.__options:
return None return None
return self.__options[optname][OPT_VAL] return self.__options[optname][OPT_VAL]
def get_desc(self, optname): def get_desc(self, optname):
if not self.__options.has_key(optname): if optname not in self.__options:
return None return None
if len(self.__options[optname]) > OPT_DESC: if len(self.__options[optname]) > OPT_DESC:
return self.__options[optname][OPT_DESC] return self.__options[optname][OPT_DESC]
def get_restart(self, optname): def get_restart(self, optname):
if not self.__options.has_key(optname): if optname not in self.__options:
return None return None
if len(self.__options[optname]) > OPT_RESTART: if len(self.__options[optname]) > OPT_RESTART:
return self.__options[optname][OPT_RESTART] return self.__options[optname][OPT_RESTART]
def add_per(self, typename, name): # per_group_of_option def add_per(self, typename, name): # per_group_of_option
if not self.__options_per_key.has_key(typename): if typename not in self.__options_per_key:
# raise RuntimeError, 'option %s does not exist' % typename # raise RuntimeError, 'option %s does not exist' % typename
return return
opt = self.__options_per_key[typename] opt = self.__options_per_key[typename]
if opt[1].has_key(name): if name in opt[1]:
# we already have added group name before # we already have added group name before
return 'you already have added %s before' % name return 'you already have added %s before' % name
opt[1][name] = copy.deepcopy(opt[0]) opt[1][name] = copy.deepcopy(opt[0])
def del_per(self, typename, name, subname = None): # per_group_of_option def del_per(self, typename, name, subname = None): # per_group_of_option
if not self.__options_per_key.has_key(typename): if typename not in self.__options_per_key:
# raise RuntimeError, 'option %s does not exist' % typename # raise RuntimeError, 'option %s does not exist' % typename
return return
@ -568,21 +568,21 @@ class Config:
if subname is None: if subname is None:
del opt[1][name] del opt[1][name]
# if subname is specified, delete the item in the group. # if subname is specified, delete the item in the group.
elif opt[1][name].has_key(subname): elif subname in opt[1][name]:
del opt[1][name][subname] del opt[1][name][subname]
def set_per(self, optname, key, subname, value): # per_group_of_option def set_per(self, optname, key, subname, value): # per_group_of_option
if not self.__options_per_key.has_key(optname): if optname not in self.__options_per_key:
# raise RuntimeError, 'option %s does not exist' % optname # raise RuntimeError, 'option %s does not exist' % optname
return return
if not key: if not key:
return return
dict = self.__options_per_key[optname][1] dict = self.__options_per_key[optname][1]
if not dict.has_key(key): if key not in dict:
# raise RuntimeError, '%s is not a key of %s' % (key, dict) # raise RuntimeError, '%s is not a key of %s' % (key, dict)
self.add_per(optname, key) self.add_per(optname, key)
obj = dict[key] obj = dict[key]
if not obj.has_key(subname): if subname not in obj:
# raise RuntimeError, '%s is not a key of %s' % (subname, obj) # raise RuntimeError, '%s is not a key of %s' % (subname, obj)
return return
subobj = obj[subname] subobj = obj[subname]
@ -593,53 +593,53 @@ class Config:
subobj[OPT_VAL] = value subobj[OPT_VAL] = value
def get_per(self, optname, key = None, subname = None): # per_group_of_option def get_per(self, optname, key = None, subname = None): # per_group_of_option
if not self.__options_per_key.has_key(optname): if optname not in self.__options_per_key:
return None return None
dict = self.__options_per_key[optname][1] dict = self.__options_per_key[optname][1]
if not key: if not key:
return dict.keys() return dict.keys()
if not dict.has_key(key): if key not in dict:
if self.__options_per_key.has_key(optname) \ if optname in self.__options_per_key \
and self.__options_per_key[optname][0].has_key(subname): and subname in self.__options_per_key[optname][0]:
return self.__options_per_key \ return self.__options_per_key \
[optname][0][subname][1] [optname][0][subname][1]
return None return None
obj = dict[key] obj = dict[key]
if not subname: if not subname:
return obj return obj
if not obj.has_key(subname): if subname not in obj:
return None return None
return obj[subname][OPT_VAL] return obj[subname][OPT_VAL]
def get_desc_per(self, optname, key = None, subname = None): def get_desc_per(self, optname, key = None, subname = None):
if not self.__options_per_key.has_key(optname): if optname not in self.__options_per_key:
return None return None
dict = self.__options_per_key[optname][1] dict = self.__options_per_key[optname][1]
if not key: if not key:
return None return None
if not dict.has_key(key): if key not in dict:
return None return None
obj = dict[key] obj = dict[key]
if not subname: if not subname:
return None return None
if not obj.has_key(subname): if subname not in obj:
return None return None
if len(obj[subname]) > OPT_DESC: if len(obj[subname]) > OPT_DESC:
return obj[subname][OPT_DESC] return obj[subname][OPT_DESC]
return None return None
def get_restart_per(self, optname, key = None, subname = None): def get_restart_per(self, optname, key = None, subname = None):
if not self.__options_per_key.has_key(optname): if optname not in self.__options_per_key:
return False return False
dict = self.__options_per_key[optname][1] dict = self.__options_per_key[optname][1]
if not key: if not key:
return False return False
if not dict.has_key(key): if key not in dict:
return False return False
obj = dict[key] obj = dict[key]
if not subname: if not subname:
return False return False
if not obj.has_key(subname): if subname not in obj:
return False return False
if len(obj[subname]) > OPT_RESTART: if len(obj[subname]) > OPT_RESTART:
return obj[subname][OPT_RESTART] return obj[subname][OPT_RESTART]

View file

@ -181,7 +181,7 @@ class Connection(ConnectionHandlers):
# END __init__ # END __init__
def put_event(self, ev): def put_event(self, ev):
if gajim.handlers.has_key(ev[0]): if ev[0] in gajim.handlers:
gajim.handlers[ev[0]](self.name, ev[1]) gajim.handlers[ev[0]](self.name, ev[1])
def dispatch(self, event, data): def dispatch(self, event, data):
@ -362,7 +362,7 @@ class Connection(ConnectionHandlers):
for child in data.getTag('query').getTag('list').getChildren(): for child in data.getTag('query').getTag('list').getChildren():
dict_item = child.getAttrs() dict_item = child.getAttrs()
childs = [] childs = []
if dict_item.has_key('type'): if 'type' in dict_item:
for scnd_child in child.getChildren(): for scnd_child in child.getChildren():
childs += [scnd_child.getName()] childs += [scnd_child.getName()]
rules.append({'action':dict_item['action'], rules.append({'action':dict_item['action'],
@ -1322,9 +1322,9 @@ class Connection(ConnectionHandlers):
self.new_account_info['password'] = field.value self.new_account_info['password'] = field.value
else: else:
# Get username and password and put them in new_account_info # Get username and password and put them in new_account_info
if form.has_key('username'): if 'username' in form:
self.new_account_info['name'] = form['username'] self.new_account_info['name'] = form['username']
if form.has_key('password'): if 'password' in form:
self.new_account_info['password'] = form['password'] self.new_account_info['password'] = form['password']
self.new_account_form = form self.new_account_form = form
self.new_account(self.name, self.new_account_info) self.new_account(self.name, self.new_account_info)
@ -1484,7 +1484,7 @@ class Connection(ConnectionHandlers):
for data in tags_list[tag]: for data in tags_list[tag]:
jid = data['jid'] jid = data['jid']
dict_ = {'jid': jid, 'tag': tag} dict_ = {'jid': jid, 'tag': tag}
if data.has_key('order'): if 'order' in data:
dict_['order'] = data['order'] dict_['order'] = data['order']
iq3.addChild(name = 'meta', attrs = dict_) iq3.addChild(name = 'meta', attrs = dict_)
self.connection.send(iq) self.connection.send(iq)
@ -1530,7 +1530,7 @@ class Connection(ConnectionHandlers):
self.connection.send(p) self.connection.send(p)
# last date/time in history to avoid duplicate # last date/time in history to avoid duplicate
if not self.last_history_time.has_key(room_jid): if room_jid not in self.last_history_time:
# Not in memory, get it from DB # Not in memory, get it from DB
last_log = None last_log = None
# Do not check if we are not logging for this room # Do not check if we are not logging for this room
@ -1644,7 +1644,7 @@ class Connection(ConnectionHandlers):
for jid in users_dict: for jid in users_dict:
item_tag = item.addChild('item', {'jid': jid, item_tag = item.addChild('item', {'jid': jid,
'affiliation': users_dict[jid]['affiliation']}) 'affiliation': users_dict[jid]['affiliation']})
if users_dict[jid].has_key('reason') and users_dict[jid]['reason']: if 'reason' in users_dict[jid] and users_dict[jid]['reason']:
item_tag.setTagData('reason', users_dict[jid]['reason']) item_tag.setTagData('reason', users_dict[jid]['reason'])
self.connection.send(iq) self.connection.send(iq)

View file

@ -76,13 +76,13 @@ class ConnectionBytestream:
self.files_props = {} self.files_props = {}
def is_transfer_stopped(self, file_props): def is_transfer_stopped(self, file_props):
if file_props.has_key('error') and file_props['error'] != 0: if 'error' in file_props and file_props['error'] != 0:
return True return True
if file_props.has_key('completed') and file_props['completed']: if 'completed' in file_props and file_props['completed']:
return True return True
if file_props.has_key('connected') and file_props['connected'] == False: if 'connected' in file_props and file_props['connected'] == False:
return True return True
if not file_props.has_key('stopped') or not file_props['stopped']: if 'stopped' not in file_props or not file_props['stopped']:
return False return False
return True return True
@ -133,18 +133,18 @@ class ConnectionBytestream:
gajim.socks5queue.remove_file_props(self.name, sid) gajim.socks5queue.remove_file_props(self.name, sid)
if remove_from_list: if remove_from_list:
if self.files_props.has_key('sid'): if 'sid' in self.files_props:
del(self.files_props['sid']) del(self.files_props['sid'])
def disconnect_transfer(self, file_props): def disconnect_transfer(self, file_props):
if file_props is None: if file_props is None:
return return
if file_props.has_key('hash'): if 'hash' in file_props:
gajim.socks5queue.remove_sender(file_props['hash']) gajim.socks5queue.remove_sender(file_props['hash'])
if file_props.has_key('streamhosts'): if 'streamhosts' in file_props:
for host in file_props['streamhosts']: for host in file_props['streamhosts']:
if host.has_key('idx') and host['idx'] > 0: if 'idx' in host and host['idx'] > 0:
gajim.socks5queue.remove_receiver(host['idx']) gajim.socks5queue.remove_receiver(host['idx'])
gajim.socks5queue.remove_sender(host['idx']) gajim.socks5queue.remove_sender(host['idx'])
@ -273,7 +273,7 @@ class ConnectionBytestream:
iq.setAttr('id', file_props['request-id']) iq.setAttr('id', file_props['request-id'])
si = iq.setTag('si') si = iq.setTag('si')
si.setNamespace(common.xmpp.NS_SI) si.setNamespace(common.xmpp.NS_SI)
if file_props.has_key('offset') and file_props['offset']: if 'offset' in file_props and file_props['offset']:
file_tag = si.setTag('file') file_tag = si.setTag('file')
file_tag.setNamespace(common.xmpp.NS_FILE) file_tag.setNamespace(common.xmpp.NS_FILE)
range_tag = file_tag.setTag('range') range_tag = file_tag.setTag('range')
@ -309,7 +309,7 @@ class ConnectionBytestream:
file_tag.setAttr('name', file_props['name']) file_tag.setAttr('name', file_props['name'])
file_tag.setAttr('size', file_props['size']) file_tag.setAttr('size', file_props['size'])
desc = file_tag.setTag('desc') desc = file_tag.setTag('desc')
if file_props.has_key('desc'): if 'desc' in file_props:
desc.setData(file_props['desc']) desc.setData(file_props['desc'])
file_tag.setTag('range') file_tag.setTag('range')
feature = si.setTag('feature') feature = si.setTag('feature')
@ -323,7 +323,7 @@ class ConnectionBytestream:
def _result_socks5_sid(self, sid, hash_id): def _result_socks5_sid(self, sid, hash_id):
''' store the result of sha message from auth. ''' ''' store the result of sha message from auth. '''
if not self.files_props.has_key(sid): if sid not in self.files_props:
return return
file_props = self.files_props[sid] file_props = self.files_props[sid]
file_props['hash'] = hash_id file_props['hash'] = hash_id
@ -381,7 +381,7 @@ class ConnectionBytestream:
gajim.proxy65_manager.error_cb(frm, query) gajim.proxy65_manager.error_cb(frm, query)
jid = helpers.get_jid_from_iq(iq_obj) jid = helpers.get_jid_from_iq(iq_obj)
id = id[3:] id = id[3:]
if not self.files_props.has_key(id): if id not in self.files_props:
return return
file_props = self.files_props[id] file_props = self.files_props[id]
file_props['error'] = -4 file_props['error'] = -4
@ -410,13 +410,13 @@ class ConnectionBytestream:
host_dict[attr] = item.getAttr(attr) host_dict[attr] = item.getAttr(attr)
streamhosts.append(host_dict) streamhosts.append(host_dict)
if file_props is None: if file_props is None:
if self.files_props.has_key(sid): if sid in self.files_props:
file_props = self.files_props[sid] file_props = self.files_props[sid]
file_props['fast'] = streamhosts file_props['fast'] = streamhosts
if file_props['type'] == 's': # FIXME: remove fast xmlns if file_props['type'] == 's': # FIXME: remove fast xmlns
# only psi do this # only psi do this
if file_props.has_key('streamhosts'): if 'streamhosts' in file_props:
file_props['streamhosts'].extend(streamhosts) file_props['streamhosts'].extend(streamhosts)
else: else:
file_props['streamhosts'] = streamhosts file_props['streamhosts'] = streamhosts
@ -444,11 +444,11 @@ class ConnectionBytestream:
return return
frm = helpers.get_full_jid_from_iq(iq_obj) frm = helpers.get_full_jid_from_iq(iq_obj)
id = real_id[3:] id = real_id[3:]
if self.files_props.has_key(id): if id in self.files_props:
file_props = self.files_props[id] file_props = self.files_props[id]
if file_props['streamhost-used']: if file_props['streamhost-used']:
for host in file_props['proxyhosts']: for host in file_props['proxyhosts']:
if host['initiator'] == frm and host.has_key('idx'): if host['initiator'] == frm and 'idx' in host:
gajim.socks5queue.activate_proxy(host['idx']) gajim.socks5queue.activate_proxy(host['idx'])
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
@ -464,7 +464,7 @@ class ConnectionBytestream:
except: # this bytestream result is not what we need except: # this bytestream result is not what we need
pass pass
id = real_id[3:] id = real_id[3:]
if self.files_props.has_key(id): if id in self.files_props:
file_props = self.files_props[id] file_props = self.files_props[id]
else: else:
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
@ -472,10 +472,10 @@ class ConnectionBytestream:
# proxy approves the activate query # proxy approves the activate query
if real_id[:3] == 'au_': if real_id[:3] == 'au_':
id = real_id[3:] id = real_id[3:]
if not file_props.has_key('streamhost-used') or \ if 'streamhost-used' not in file_props or \
file_props['streamhost-used'] is False: file_props['streamhost-used'] is False:
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
if not file_props.has_key('proxyhosts'): if 'proxyhosts' not in file_props:
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
for host in file_props['proxyhosts']: for host in file_props['proxyhosts']:
if host['initiator'] == frm and \ if host['initiator'] == frm and \
@ -484,26 +484,26 @@ class ConnectionBytestream:
break break
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
jid = streamhost.getAttr('jid') jid = streamhost.getAttr('jid')
if file_props.has_key('streamhost-used') and \ if 'streamhost-used' in file_props and \
file_props['streamhost-used'] is True: file_props['streamhost-used'] is True:
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
if real_id[:3] == 'au_': if real_id[:3] == 'au_':
if file.has_key('stopped') and file_props['stopped']: if 'stopped' in file and file_props['stopped']:
self.remove_transfer(file_props) self.remove_transfer(file_props)
else: else:
gajim.socks5queue.send_file(file_props, self.name) gajim.socks5queue.send_file(file_props, self.name)
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
proxy = None proxy = None
if file_props.has_key('proxyhosts'): if 'proxyhosts' in file_props:
for proxyhost in file_props['proxyhosts']: for proxyhost in file_props['proxyhosts']:
if proxyhost['jid'] == jid: if proxyhost['jid'] == jid:
proxy = proxyhost proxy = proxyhost
if proxy is not None: if proxy is not None:
file_props['streamhost-used'] = True file_props['streamhost-used'] = True
if not file_props.has_key('streamhosts'): if 'streamhosts' not in file_props:
file_props['streamhosts'] = [] file_props['streamhosts'] = []
file_props['streamhosts'].append(proxy) file_props['streamhosts'].append(proxy)
file_props['is_a_proxy'] = True file_props['is_a_proxy'] = True
@ -514,11 +514,11 @@ class ConnectionBytestream:
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
else: else:
if file_props.has_key('stopped') and file_props['stopped']: if 'stopped' in file_props and file_props['stopped']:
self.remove_transfer(file_props) self.remove_transfer(file_props)
else: else:
gajim.socks5queue.send_file(file_props, self.name) gajim.socks5queue.send_file(file_props, self.name)
if file_props.has_key('fast'): if 'fast' in file_props:
fasts = file_props['fast'] fasts = file_props['fast']
if len(fasts) > 0: if len(fasts) > 0:
self._connect_error(frm, fasts[0]['id'], file_props['sid'], self._connect_error(frm, fasts[0]['id'], file_props['sid'],
@ -529,14 +529,14 @@ class ConnectionBytestream:
def _siResultCB(self, con, iq_obj): def _siResultCB(self, con, iq_obj):
gajim.log.debug('_siResultCB') gajim.log.debug('_siResultCB')
id = iq_obj.getAttr('id') id = iq_obj.getAttr('id')
if not self.files_props.has_key(id): if id not in self.files_props:
# no such jid # no such jid
return return
file_props = self.files_props[id] file_props = self.files_props[id]
if file_props is None: if file_props is None:
# file properties for jid is none # file properties for jid is none
return return
if file_props.has_key('request-id'): if 'request-id' in file_props:
# we have already sent streamhosts info # we have already sent streamhosts info
return return
file_props['receiver'] = helpers.get_full_jid_from_iq(iq_obj) file_props['receiver'] = helpers.get_full_jid_from_iq(iq_obj)
@ -603,7 +603,7 @@ class ConnectionBytestream:
if profile != common.xmpp.NS_FILE: if profile != common.xmpp.NS_FILE:
return return
id = iq_obj.getAttr('id') id = iq_obj.getAttr('id')
if not self.files_props.has_key(id): if id not in self.files_props:
# no such jid # no such jid
return return
file_props = self.files_props[id] file_props = self.files_props[id]
@ -804,13 +804,13 @@ class ConnectionDisco:
attr = {} attr = {}
for key in i.getAttrs().keys(): for key in i.getAttrs().keys():
attr[key] = i.getAttr(key) attr[key] = i.getAttr(key)
if attr.has_key('category') and \ if 'category' in attr and \
attr['category'] in ('gateway', 'headline') and \ attr['category'] in ('gateway', 'headline') and \
attr.has_key('type'): 'type' in attr:
transport_type = attr['type'] transport_type = attr['type']
if attr.has_key('category') and \ if 'category' in attr and \
attr['category'] == 'conference' and \ attr['category'] == 'conference' and \
attr.has_key('type') and attr['type'] == 'text': 'type' in attr and attr['type'] == 'text':
is_muc = True is_muc = True
identities.append(attr) identities.append(attr)
elif i.getName() == 'feature': elif i.getName() == 'feature':
@ -851,7 +851,7 @@ class ConnectionDisco:
type_ = transport_type or 'jabber' type_ = transport_type or 'jabber'
self.muc_jid[type_] = jid self.muc_jid[type_] = jid
if transport_type: if transport_type:
if self.available_transports.has_key(transport_type): if transport_type in self.available_transports:
self.available_transports[transport_type].append(jid) self.available_transports[transport_type].append(jid)
else: else:
self.available_transports[transport_type] = [jid] self.available_transports[transport_type] = [jid]
@ -887,7 +887,7 @@ class ConnectionVcard:
for info in node.getChildren(): for info in node.getChildren():
name = info.getName() name = info.getName()
if name in ('ADR', 'TEL', 'EMAIL'): # we can have several if name in ('ADR', 'TEL', 'EMAIL'): # we can have several
if not dict.has_key(name): if name not in dict:
dict[name] = [] dict[name] = []
entry = {} entry = {}
for c in info.getChildren(): for c in info.getChildren():
@ -949,12 +949,12 @@ class ConnectionVcard:
os.remove(path_to_file) os.remove(path_to_file)
return None return None
vcard = self.node_to_dict(card) vcard = self.node_to_dict(card)
if vcard.has_key('PHOTO'): if 'PHOTO' in vcard:
if not isinstance(vcard['PHOTO'], dict): if not isinstance(vcard['PHOTO'], dict):
del vcard['PHOTO'] del vcard['PHOTO']
elif vcard['PHOTO'].has_key('SHA'): elif 'SHA' in vcard['PHOTO']:
cached_sha = vcard['PHOTO']['SHA'] cached_sha = vcard['PHOTO']['SHA']
if self.vcard_shas.has_key(jid) and self.vcard_shas[jid] != \ if jid in self.vcard_shas and self.vcard_shas[jid] != \
cached_sha: cached_sha:
# user change his vcard so don't use the cached one # user change his vcard so don't use the cached one
return {} return {}
@ -1012,8 +1012,8 @@ class ConnectionVcard:
our_jid = gajim.get_jid_from_account(self.name) our_jid = gajim.get_jid_from_account(self.name)
# Add the sha of the avatar # Add the sha of the avatar
if vcard.has_key('PHOTO') and isinstance(vcard['PHOTO'], dict) and \ if 'PHOTO' in vcard and isinstance(vcard['PHOTO'], dict) and \
vcard['PHOTO'].has_key('BINVAL'): 'BINVAL' in vcard['PHOTO']:
photo = vcard['PHOTO']['BINVAL'] photo = vcard['PHOTO']['BINVAL']
photo_decoded = base64.decodestring(photo) photo_decoded = base64.decodestring(photo)
gajim.interface.save_avatar_files(our_jid, photo_decoded) gajim.interface.save_avatar_files(our_jid, photo_decoded)
@ -1111,7 +1111,7 @@ class ConnectionVcard:
order = 0 order = 0
if order is not None: if order is not None:
data['order'] = order data['order'] = order
if meta_list.has_key(tag): if tag in meta_list:
meta_list[tag].append(data) meta_list[tag].append(data)
else: else:
meta_list[tag] = [data] meta_list[tag] = [data]
@ -1168,8 +1168,8 @@ class ConnectionVcard:
card = vc.getChildren()[0] card = vc.getChildren()[0]
vcard = self.node_to_dict(card) vcard = self.node_to_dict(card)
photo_decoded = None photo_decoded = None
if vcard.has_key('PHOTO') and isinstance(vcard['PHOTO'], dict) and \ if 'PHOTO' in vcard and isinstance(vcard['PHOTO'], dict) and \
vcard['PHOTO'].has_key('BINVAL'): 'BINVAL' in vcard['PHOTO']:
photo = vcard['PHOTO']['BINVAL'] photo = vcard['PHOTO']['BINVAL']
try: try:
photo_decoded = base64.decodestring(photo) photo_decoded = base64.decodestring(photo)
@ -1201,12 +1201,12 @@ class ConnectionVcard:
if frm_jid == our_jid and avatar_sha != self.vcard_sha: if frm_jid == our_jid and avatar_sha != self.vcard_sha:
gajim.interface.save_avatar_files(frm, photo_decoded, puny_nick) gajim.interface.save_avatar_files(frm, photo_decoded, puny_nick)
elif frm_jid != our_jid and (not os.path.exists(avatar_file) or \ elif frm_jid != our_jid and (not os.path.exists(avatar_file) or \
not self.vcard_shas.has_key(frm_jid) or \ frm_jid not in self.vcard_shas or \
avatar_sha != self.vcard_shas[frm_jid]): avatar_sha != self.vcard_shas[frm_jid]):
gajim.interface.save_avatar_files(frm, photo_decoded, puny_nick) gajim.interface.save_avatar_files(frm, photo_decoded, puny_nick)
if avatar_sha: if avatar_sha:
self.vcard_shas[frm_jid] = avatar_sha self.vcard_shas[frm_jid] = avatar_sha
elif self.vcard_shas.has_key(frm): elif frm in self.vcard_shas:
del self.vcard_shas[frm] del self.vcard_shas[frm]
else: else:
for ext in ('.jpeg', '.png', '_notif_size_bw.png', for ext in ('.jpeg', '.png', '_notif_size_bw.png',
@ -1861,7 +1861,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
return return
# Ignore message from room in which we are not # Ignore message from room in which we are not
if not self.last_history_time.has_key(jid): if jid not in self.last_history_time:
return return
self.dispatch('GC_MSG', (frm, msgtxt, tim, has_timestamp, msg.getXHTML(), self.dispatch('GC_MSG', (frm, msgtxt, tim, has_timestamp, msg.getXHTML(),
@ -2110,7 +2110,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
self.automatically_added.remove(jid_stripped) self.automatically_added.remove(jid_stripped)
else: else:
# detect a subscription loop # detect a subscription loop
if not self.subscribed_events.has_key(jid_stripped): if jid_stripped not in self.subscribed_events:
self.subscribed_events[jid_stripped] = [] self.subscribed_events[jid_stripped] = []
self.subscribed_events[jid_stripped].append(time_time()) self.subscribed_events[jid_stripped].append(time_time())
block = False block = False
@ -2130,7 +2130,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
elif ptype == 'unsubscribed': elif ptype == 'unsubscribed':
gajim.log.debug(_('we are now unsubscribed from %s') % who) gajim.log.debug(_('we are now unsubscribed from %s') % who)
# detect a unsubscription loop # detect a unsubscription loop
if not self.subscribed_events.has_key(jid_stripped): if jid_stripped not in self.subscribed_events:
self.subscribed_events[jid_stripped] = [] self.subscribed_events[jid_stripped] = []
self.subscribed_events[jid_stripped].append(time_time()) self.subscribed_events[jid_stripped].append(time_time())
block = False block = False
@ -2161,10 +2161,10 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
del self.sessions[jid_stripped][sess.thread_id] del self.sessions[jid_stripped][sess.thread_id]
if avatar_sha is not None and ptype != 'error': if avatar_sha is not None and ptype != 'error':
if not self.vcard_shas.has_key(jid_stripped): if jid_stripped not in self.vcard_shas:
cached_vcard = self.get_cached_vcard(jid_stripped) cached_vcard = self.get_cached_vcard(jid_stripped)
if cached_vcard and cached_vcard.has_key('PHOTO') and \ if cached_vcard and 'PHOTO' in cached_vcard and \
cached_vcard['PHOTO'].has_key('SHA'): 'SHA' in cached_vcard['PHOTO']:
self.vcard_shas[jid_stripped] = cached_vcard['PHOTO']['SHA'] self.vcard_shas[jid_stripped] = cached_vcard['PHOTO']['SHA']
else: else:
self.vcard_shas[jid_stripped] = '' self.vcard_shas[jid_stripped] = ''
@ -2335,7 +2335,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
priority = gajim.get_priority(self.name, sshow) priority = gajim.get_priority(self.name, sshow)
our_jid = helpers.parse_jid(gajim.get_jid_from_account(self.name)) our_jid = helpers.parse_jid(gajim.get_jid_from_account(self.name))
vcard = self.get_cached_vcard(our_jid) vcard = self.get_cached_vcard(our_jid)
if vcard and vcard.has_key('PHOTO') and vcard['PHOTO'].has_key('SHA'): if vcard and 'PHOTO' in vcard and 'SHA' in vcard['PHOTO']:
self.vcard_sha = vcard['PHOTO']['SHA'] self.vcard_sha = vcard['PHOTO']['SHA']
p = common.xmpp.Presence(typ = None, priority = priority, show = sshow) p = common.xmpp.Presence(typ = None, priority = priority, show = sshow)
p = self.add_sha(p) p = self.add_sha(p)

View file

@ -87,7 +87,7 @@ class Events:
listener(event_list) listener(event_list)
def change_account_name(self, old_name, new_name): def change_account_name(self, old_name, new_name):
if self._events.has_key(old_name): if old_name in self._events:
self._events[new_name] = self._events[old_name] self._events[new_name] = self._events[old_name]
del self._events[old_name] del self._events[old_name]
@ -107,10 +107,10 @@ class Events:
def add_event(self, account, jid, event): def add_event(self, account, jid, event):
# No such account before ? # No such account before ?
if not self._events.has_key(account): if account not in self._events:
self._events[account] = {jid: [event]} self._events[account] = {jid: [event]}
# no such jid before ? # no such jid before ?
elif not self._events[account].has_key(jid): elif jid not in self._events[account]:
self._events[account][jid] = [event] self._events[account][jid] = [event]
else: else:
self._events[account][jid].append(event) self._events[account][jid].append(event)
@ -122,9 +122,9 @@ class Events:
'''if event is not specified, remove all events from this jid, '''if event is not specified, remove all events from this jid,
optionally only from given type optionally only from given type
return True if no such event found''' return True if no such event found'''
if not self._events.has_key(account): if account not in self._events:
return True return True
if not self._events[account].has_key(jid): if jid not in self._events[account]:
return True return True
if event: # remove only one event if event: # remove only one event
if event in self._events[account][jid]: if event in self._events[account][jid]:
@ -157,9 +157,9 @@ class Events:
del self._events[account][jid] del self._events[account][jid]
def change_jid(self, account, old_jid, new_jid): def change_jid(self, account, old_jid, new_jid):
if not self._events[account].has_key(old_jid): if old_jid not in self._events[account]:
return return
if self._events[account].has_key(new_jid): if new_jid in self._events[account]:
self._events[account][new_jid] += self._events[account][old_jid] self._events[account][new_jid] += self._events[account][old_jid]
else: else:
self._events[account][new_jid] = self._events[account][old_jid] self._events[account][new_jid] = self._events[account][old_jid]
@ -173,7 +173,7 @@ class Events:
{jid1: [], jid2: []} {jid1: [], jid2: []}
if jid is given, returns all events from the given jid in a list: [] if jid is given, returns all events from the given jid in a list: []
optionally only from given type''' optionally only from given type'''
if not self._events.has_key(account): if account not in self._events:
return [] return []
if not jid: if not jid:
events_list = {} # list of events events_list = {} # list of events
@ -185,7 +185,7 @@ class Events:
if events: if events:
events_list[jid_] = events events_list[jid_] = events
return events_list return events_list
if not self._events[account].has_key(jid): if jid not in self._events[account]:
return [] return []
events_list = [] # list of events events_list = [] # list of events
for ev in self._events[account][jid]: for ev in self._events[account][jid]:
@ -214,14 +214,14 @@ class Events:
else: else:
accounts = self._events.keys() accounts = self._events.keys()
for acct in accounts: for acct in accounts:
if not self._events.has_key(acct): if acct not in self._events:
continue continue
if jid: if jid:
jids = [jid] jids = [jid]
else: else:
jids = self._events[acct].keys() jids = self._events[acct].keys()
for j in jids: for j in jids:
if not self._events[acct].has_key(j): if j not in self._events[acct]:
continue continue
for event in self._events[acct][j]: for event in self._events[acct][j]:
if types and event.type_ not in types: if types and event.type_ not in types:

View file

@ -242,7 +242,7 @@ def get_contact_dict_for_account(account):
jid) jid)
contacts_dict[jid] = contact contacts_dict[jid] = contact
name = contact.name name = contact.name
if contacts_dict.has_key(name): if name in contacts_dict:
contact1 = contacts_dict[name] contact1 = contacts_dict[name]
del contacts_dict[name] del contacts_dict[name]
contacts_dict['%s (%s)' % (name, contact1.jid)] = contact1 contacts_dict['%s (%s)' % (name, contact1.jid)] = contact1
@ -619,11 +619,11 @@ def get_icon_name_to_show(contact, account = None):
if account and gajim.events.get_nb_roster_events(account, if account and gajim.events.get_nb_roster_events(account,
contact.get_full_jid()): contact.get_full_jid()):
return 'event' return 'event'
if account and gajim.interface.minimized_controls.has_key(account) and \ if account and account in gajim.interface.minimized_controls and \
contact.jid in gajim.interface.minimized_controls[account] and gajim.interface.\ contact.jid in gajim.interface.minimized_controls[account] and gajim.interface.\
minimized_controls[account][contact.jid].get_nb_unread_pm() > 0: minimized_controls[account][contact.jid].get_nb_unread_pm() > 0:
return 'event' return 'event'
if account and gajim.gc_connected[account].has_key(contact.jid): if account and contact.jid in gajim.gc_connected[account]:
if gajim.gc_connected[account][contact.jid]: if gajim.gc_connected[account][contact.jid]:
return 'muc_active' return 'muc_active'
else: else:
@ -787,7 +787,7 @@ def get_os_info():
(2, 5, 2): '2003', (2, 5, 2): '2003',
(2, 6, 0): 'Vista', (2, 6, 0): 'Vista',
} }
if win_version.has_key(ver_format): if ver_format in win_version:
return 'Windows' + ' ' + win_version[ver_format] return 'Windows' + ' ' + win_version[ver_format]
else: else:
return 'Windows' return 'Windows'
@ -1175,7 +1175,7 @@ def prepare_and_validate_gpg_keyID(account, jid, keyID):
elif keyID: elif keyID:
public_keys = gajim.connections[account].ask_gpg_keys() public_keys = gajim.connections[account].ask_gpg_keys()
# Assign the corresponding key, if we have it in our keyring # Assign the corresponding key, if we have it in our keyring
if public_keys.has_key(keyID): if keyID in public_keys:
for u in gajim.contacts.get_contacts(account, jid): for u in gajim.contacts.get_contacts(account, jid):
u.keyID = keyID u.keyID = keyID
keys_str = gajim.config.get_per('accounts', account, 'attached_gpg_keys') keys_str = gajim.config.get_per('accounts', account, 'attached_gpg_keys')
@ -1192,11 +1192,11 @@ def sort_identities_func(i1, i2):
return -1 return -1
if cat1 > cat2: if cat1 > cat2:
return 1 return 1
if i1.has_key('type'): if 'type' in i1:
type1 = i1['type'] type1 = i1['type']
else: else:
type1 = '' type1 = ''
if i2.has_key('type'): if 'type' in i2:
type2 = i2['type'] type2 = i2['type']
else: else:
type2 = '' type2 = ''
@ -1204,11 +1204,11 @@ def sort_identities_func(i1, i2):
return -1 return -1
if type1 > type2: if type1 > type2:
return 1 return 1
if i1.has_key('xml:lang'): if 'xml:lang' in i1:
lang1 = i1['xml:lang'] lang1 = i1['xml:lang']
else: else:
lang1 = '' lang1 = ''
if i2.has_key('xml:lang'): if 'xml:lang' in i2:
lang2 = i2['xml:lang'] lang2 = i2['xml:lang']
else: else:
lang2 = '' lang2 = ''
@ -1234,15 +1234,15 @@ def compute_caps_hash(identities, features, dataforms=[], hash_method='sha-1'):
identities.sort(cmp=sort_identities_func) identities.sort(cmp=sort_identities_func)
for i in identities: for i in identities:
c = i['category'] c = i['category']
if i.has_key('type'): if 'type' in i:
type_ = i['type'] type_ = i['type']
else: else:
type_ = '' type_ = ''
if i.has_key('xml:lang'): if 'xml:lang' in i:
lang = i['xml:lang'] lang = i['xml:lang']
else: else:
lang = '' lang = ''
if i.has_key('name'): if 'name' in i:
name = i['name'] name = i['name']
else: else:
name = '' name = ''

View file

@ -150,9 +150,9 @@ class Resolver:
result_list = self.parse_srv_result(host, result) result_list = self.parse_srv_result(host, result)
# practically it is impossible to be the opposite, but who knows :) # practically it is impossible to be the opposite, but who knows :)
if not self.resolved_hosts.has_key(host): if host not in self.resolved_hosts:
self.resolved_hosts[host] = result_list self.resolved_hosts[host] = result_list
if self.handlers.has_key(host): if host in self.handlers:
for callback in self.handlers[host]: for callback in self.handlers[host]:
callback(host, result_list) callback(host, result_list)
del(self.handlers[host]) del(self.handlers[host])
@ -169,11 +169,11 @@ class Resolver:
# empty host, return empty list of srv records # empty host, return empty list of srv records
on_ready([]) on_ready([])
return return
if self.resolved_hosts.has_key(host): if host in self.resolved_hosts:
# host is already resolved, return cached values # host is already resolved, return cached values
on_ready(host, self.resolved_hosts[host]) on_ready(host, self.resolved_hosts[host])
return return
if self.handlers.has_key(host): if host in self.handlers:
# host is about to be resolved by another connection, # host is about to be resolved by another connection,
# attach our callback # attach our callback
self.handlers[host].append(on_ready) self.handlers[host].append(on_ready)

View file

@ -199,14 +199,14 @@ class OptionsParser:
def update_config_x_to_09(self): def update_config_x_to_09(self):
# Var name that changed: # Var name that changed:
# avatar_width /height -> chat_avatar_width / height # avatar_width /height -> chat_avatar_width / height
if self.old_values.has_key('avatar_width'): if 'avatar_width' in self.old_values:
gajim.config.set('chat_avatar_width', self.old_values['avatar_width']) gajim.config.set('chat_avatar_width', self.old_values['avatar_width'])
if self.old_values.has_key('avatar_height'): if 'avatar_height' in self.old_values:
gajim.config.set('chat_avatar_height', self.old_values['avatar_height']) gajim.config.set('chat_avatar_height', self.old_values['avatar_height'])
if self.old_values.has_key('use_dbus'): if 'use_dbus' in self.old_values:
gajim.config.set('remote_control', self.old_values['use_dbus']) gajim.config.set('remote_control', self.old_values['use_dbus'])
# always_compact_view -> always_compact_view_chat / _gc # always_compact_view -> always_compact_view_chat / _gc
if self.old_values.has_key('always_compact_view'): if 'always_compact_view' in self.old_values:
gajim.config.set('always_compact_view_chat', gajim.config.set('always_compact_view_chat',
self.old_values['always_compact_view']) self.old_values['always_compact_view'])
gajim.config.set('always_compact_view_gc', gajim.config.set('always_compact_view_gc',
@ -269,19 +269,19 @@ class OptionsParser:
con.close() con.close()
def update_config_09_to_010(self): def update_config_09_to_010(self):
if self.old_values.has_key('usetabbedchat') and not \ if 'usetabbedchat' in self.old_values and not \
self.old_values['usetabbedchat']: self.old_values['usetabbedchat']:
gajim.config.set('one_message_window', 'never') gajim.config.set('one_message_window', 'never')
if self.old_values.has_key('autodetect_browser_mailer') and \ if 'autodetect_browser_mailer' in self.old_values and \
self.old_values['autodetect_browser_mailer'] is True: self.old_values['autodetect_browser_mailer'] is True:
gajim.config.set('autodetect_browser_mailer', False) gajim.config.set('autodetect_browser_mailer', False)
if self.old_values.has_key('useemoticons') and \ if 'useemoticons' in self.old_values and \
not self.old_values['useemoticons']: not self.old_values['useemoticons']:
gajim.config.set('emoticons_theme', '') gajim.config.set('emoticons_theme', '')
if self.old_values.has_key('always_compact_view_chat') and \ if 'always_compact_view_chat' in self.old_values and \
self.old_values['always_compact_view_chat'] != 'False': self.old_values['always_compact_view_chat'] != 'False':
gajim.config.set('always_hide_chat_buttons', True) gajim.config.set('always_hide_chat_buttons', True)
if self.old_values.has_key('always_compact_view_gc') and \ if 'always_compact_view_gc' in self.old_values and \
self.old_values['always_compact_view_gc'] != 'False': self.old_values['always_compact_view_gc'] != 'False':
gajim.config.set('always_hide_groupchat_buttons', True) gajim.config.set('always_hide_groupchat_buttons', True)
@ -306,14 +306,14 @@ class OptionsParser:
gajim.config.set('version', '0.10') gajim.config.set('version', '0.10')
def update_config_to_01011(self): def update_config_to_01011(self):
if self.old_values.has_key('print_status_in_muc') and \ if 'print_status_in_muc' in self.old_values and \
self.old_values['print_status_in_muc'] in (True, False): self.old_values['print_status_in_muc'] in (True, False):
gajim.config.set('print_status_in_muc', 'in_and_out') gajim.config.set('print_status_in_muc', 'in_and_out')
gajim.config.set('version', '0.10.1.1') gajim.config.set('version', '0.10.1.1')
def update_config_to_01012(self): def update_config_to_01012(self):
# See [6456] # See [6456]
if self.old_values.has_key('emoticons_theme') and \ if 'emoticons_theme' in self.old_values and \
self.old_values['emoticons_theme'] == 'Disabled': self.old_values['emoticons_theme'] == 'Disabled':
gajim.config.set('emoticons_theme', '') gajim.config.set('emoticons_theme', '')
gajim.config.set('version', '0.10.1.2') gajim.config.set('version', '0.10.1.2')
@ -387,7 +387,7 @@ class OptionsParser:
def update_config_to_01016(self): def update_config_to_01016(self):
'''#2494 : Now we play gc_received_message sound even if '''#2494 : Now we play gc_received_message sound even if
notify_on_all_muc_messages is false. Keep precedent behaviour.''' notify_on_all_muc_messages is false. Keep precedent behaviour.'''
if self.old_values.has_key('notify_on_all_muc_messages') and \ if 'notify_on_all_muc_messages' in self.old_values and \
self.old_values['notify_on_all_muc_messages'] == 'False' and \ self.old_values['notify_on_all_muc_messages'] == 'False' and \
gajim.config.get_per('soundevents', 'muc_message_received', 'enabled'): gajim.config.get_per('soundevents', 'muc_message_received', 'enabled'):
gajim.config.set_per('soundevents',\ gajim.config.set_per('soundevents',\
@ -397,43 +397,43 @@ class OptionsParser:
def update_config_to_01017(self): def update_config_to_01017(self):
'''trayicon_notification_on_new_messages -> '''trayicon_notification_on_new_messages ->
trayicon_notification_on_events ''' trayicon_notification_on_events '''
if self.old_values.has_key('trayicon_notification_on_new_messages'): if 'trayicon_notification_on_new_messages' in self.old_values:
gajim.config.set('trayicon_notification_on_events', gajim.config.set('trayicon_notification_on_events',
self.old_values['trayicon_notification_on_new_messages']) self.old_values['trayicon_notification_on_new_messages'])
gajim.config.set('version', '0.10.1.7') gajim.config.set('version', '0.10.1.7')
def update_config_to_01018(self): def update_config_to_01018(self):
'''chat_state_notifications -> outgoing_chat_state_notifications''' '''chat_state_notifications -> outgoing_chat_state_notifications'''
if self.old_values.has_key('chat_state_notifications'): if 'chat_state_notifications' in self.old_values:
gajim.config.set('outgoing_chat_state_notifications', gajim.config.set('outgoing_chat_state_notifications',
self.old_values['chat_state_notifications']) self.old_values['chat_state_notifications'])
gajim.config.set('version', '0.10.1.8') gajim.config.set('version', '0.10.1.8')
def update_config_to_01101(self): def update_config_to_01101(self):
'''fill time_stamp from before_time and after_time''' '''fill time_stamp from before_time and after_time'''
if self.old_values.has_key('before_time'): if 'before_time' in self.old_values:
gajim.config.set('time_stamp', '%s%%X%s ' % ( gajim.config.set('time_stamp', '%s%%X%s ' % (
self.old_values['before_time'], self.old_values['after_time'])) self.old_values['before_time'], self.old_values['after_time']))
gajim.config.set('version', '0.11.0.1') gajim.config.set('version', '0.11.0.1')
def update_config_to_01102(self): def update_config_to_01102(self):
'''fill time_stamp from before_time and after_time''' '''fill time_stamp from before_time and after_time'''
if self.old_values.has_key('ft_override_host_to_send'): if 'ft_override_host_to_send' in self.old_values:
gajim.config.set('ft_add_hosts_to_send', gajim.config.set('ft_add_hosts_to_send',
self.old_values['ft_override_host_to_send']) self.old_values['ft_override_host_to_send'])
gajim.config.set('version', '0.11.0.2') gajim.config.set('version', '0.11.0.2')
def update_config_to_01111(self): def update_config_to_01111(self):
'''always_hide_chatbuttons -> compact_view''' '''always_hide_chatbuttons -> compact_view'''
if self.old_values.has_key('always_hide_groupchat_buttons') and \ if 'always_hide_groupchat_buttons' in self.old_values and \
self.old_values.has_key('always_hide_chat_buttons'): 'always_hide_chat_buttons' in self.old_values:
gajim.config.set('compact_view', self.old_values['always_hide_groupchat_buttons'] and \ gajim.config.set('compact_view', self.old_values['always_hide_groupchat_buttons'] and \
self.old_values['always_hide_chat_buttons']) self.old_values['always_hide_chat_buttons'])
gajim.config.set('version', '0.11.1.1') gajim.config.set('version', '0.11.1.1')
def update_config_to_01112(self): def update_config_to_01112(self):
'''gtk+ theme is renamed to default''' '''gtk+ theme is renamed to default'''
if self.old_values.has_key('roster_theme') and \ if 'roster_theme' in self.old_values and \
self.old_values['roster_theme'] == 'gtk+': self.old_values['roster_theme'] == 'gtk+':
gajim.config.set('roster_theme', _('default')) gajim.config.set('roster_theme', _('default'))
gajim.config.set('version', '0.11.1.2') gajim.config.set('version', '0.11.1.2')

View file

@ -101,7 +101,7 @@ class GnomePasswordStorage(PasswordStorage):
return return
token = 'gnomekeyring:%i' % auth_token token = 'gnomekeyring:%i' % auth_token
gajim.config.set_per('accounts', account_name, 'password', token) gajim.config.set_per('accounts', account_name, 'password', token)
if gajim.connections.has_key(account_name): if account_name in gajim.connections:
gajim.connections[account_name].password = password gajim.connections[account_name].password = password
storage = None storage = None

View file

@ -155,35 +155,35 @@ def user_mood(items, name, jid):
if jid == gajim.get_jid_from_account(name): if jid == gajim.get_jid_from_account(name):
acc = gajim.connections[name] acc = gajim.connections[name]
if has_child: if has_child:
if acc.mood.has_key('mood'): if 'mood' in acc.mood:
del acc.mood['mood'] del acc.mood['mood']
if acc.mood.has_key('text'): if 'text' in acc.mood:
del acc.mood['text'] del acc.mood['text']
if mood is not None: if mood is not None:
acc.mood['mood'] = mood acc.mood['mood'] = mood
if text is not None: if text is not None:
acc.mood['text'] = text acc.mood['text'] = text
elif retract: elif retract:
if acc.mood.has_key('mood'): if 'mood' in acc.mood:
del acc.mood['mood'] del acc.mood['mood']
if acc.mood.has_key('text'): if 'text' in acc.mood:
del acc.mood['text'] del acc.mood['text']
(user, resource) = gajim.get_room_and_nick_from_fjid(jid) (user, resource) = gajim.get_room_and_nick_from_fjid(jid)
for contact in gajim.contacts.get_contacts(name, user): for contact in gajim.contacts.get_contacts(name, user):
if has_child: if has_child:
if contact.mood.has_key('mood'): if 'mood' in contact.mood:
del contact.mood['mood'] del contact.mood['mood']
if contact.mood.has_key('text'): if 'text' in contact.mood:
del contact.mood['text'] del contact.mood['text']
if mood is not None: if mood is not None:
contact.mood['mood'] = mood contact.mood['mood'] = mood
if text is not None: if text is not None:
contact.mood['text'] = text contact.mood['text'] = text
elif retract: elif retract:
if contact.mood.has_key('mood'): if 'mood' in contact.mood:
del contact.mood['mood'] del contact.mood['mood']
if contact.mood.has_key('text'): if 'text' in contact.mood:
del contact.mood['text'] del contact.mood['text']
if jid == gajim.get_jid_from_account(name): if jid == gajim.get_jid_from_account(name):
@ -223,15 +223,15 @@ def user_tune(items, name, jid):
if jid == gajim.get_jid_from_account(name): if jid == gajim.get_jid_from_account(name):
acc = gajim.connections[name] acc = gajim.connections[name]
if has_child: if has_child:
if acc.tune.has_key('artist'): if 'artist' in acc.tune:
del acc.tune['artist'] del acc.tune['artist']
if acc.tune.has_key('title'): if 'title' in acc.tune:
del acc.tune['title'] del acc.tune['title']
if acc.tune.has_key('source'): if 'source' in acc.tune:
del acc.tune['source'] del acc.tune['source']
if acc.tune.has_key('track'): if 'track' in acc.tune:
del acc.tune['track'] del acc.tune['track']
if acc.tune.has_key('length'): if 'length' in acc.tune:
del acc.tune['length'] del acc.tune['length']
if artist is not None: if artist is not None:
acc.tune['artist'] = artist acc.tune['artist'] = artist
@ -244,29 +244,29 @@ def user_tune(items, name, jid):
if length is not None: if length is not None:
acc.tune['length'] = length acc.tune['length'] = length
elif retract: elif retract:
if acc.tune.has_key('artist'): if 'artist' in acc.tune:
del acc.tune['artist'] del acc.tune['artist']
if acc.tune.has_key('title'): if 'title' in acc.tune:
del acc.tune['title'] del acc.tune['title']
if acc.tune.has_key('source'): if 'source' in acc.tune:
del acc.tune['source'] del acc.tune['source']
if acc.tune.has_key('track'): if 'track' in acc.tune:
del acc.tune['track'] del acc.tune['track']
if acc.tune.has_key('length'): if 'length' in acc.tune:
del acc.tune['length'] del acc.tune['length']
(user, resource) = gajim.get_room_and_nick_from_fjid(jid) (user, resource) = gajim.get_room_and_nick_from_fjid(jid)
for contact in gajim.contacts.get_contacts(name, user): for contact in gajim.contacts.get_contacts(name, user):
if has_child: if has_child:
if contact.tune.has_key('artist'): if 'artist' in contact.tune:
del contact.tune['artist'] del contact.tune['artist']
if contact.tune.has_key('title'): if 'title' in contact.tune:
del contact.tune['title'] del contact.tune['title']
if contact.tune.has_key('source'): if 'source' in contact.tune:
del contact.tune['source'] del contact.tune['source']
if contact.tune.has_key('track'): if 'track' in contact.tune:
del contact.tune['track'] del contact.tune['track']
if contact.tune.has_key('length'): if 'length' in contact.tune:
del contact.tune['length'] del contact.tune['length']
if artist is not None: if artist is not None:
contact.tune['artist'] = artist contact.tune['artist'] = artist
@ -279,15 +279,15 @@ def user_tune(items, name, jid):
if length is not None: if length is not None:
contact.tune['length'] = length contact.tune['length'] = length
elif retract: elif retract:
if contact.tune.has_key('artist'): if 'artist' in contact.tune:
del contact.tune['artist'] del contact.tune['artist']
if contact.tune.has_key('title'): if 'title' in contact.tune:
del contact.tune['title'] del contact.tune['title']
if contact.tune.has_key('source'): if 'source' in contact.tune:
del contact.tune['source'] del contact.tune['source']
if contact.tune.has_key('track'): if 'track' in contact.tune:
del contact.tune['track'] del contact.tune['track']
if contact.tune.has_key('length'): if 'length' in contact.tune:
del contact.tune['length'] del contact.tune['length']
if jid == gajim.get_jid_from_account(name): if jid == gajim.get_jid_from_account(name):
@ -324,11 +324,11 @@ def user_activity(items, name, jid):
if jid == gajim.get_jid_from_account(name): if jid == gajim.get_jid_from_account(name):
acc = gajim.connections[name] acc = gajim.connections[name]
if has_child: if has_child:
if acc.activity.has_key('activity'): if 'activity' in acc.activity:
del acc.activity['activity'] del acc.activity['activity']
if acc.activity.has_key('subactivity'): if 'subactivity' in acc.activity:
del acc.activity['subactivity'] del acc.activity['subactivity']
if acc.activity.has_key('text'): if 'text' in acc.activity:
del acc.activity['text'] del acc.activity['text']
if activity is not None: if activity is not None:
acc.activity['activity'] = activity acc.activity['activity'] = activity
@ -337,21 +337,21 @@ def user_activity(items, name, jid):
if text is not None: if text is not None:
acc.activity['text'] = text acc.activity['text'] = text
elif retract: elif retract:
if acc.activity.has_key('activity'): if 'activity' in acc.activity:
del acc.activity['activity'] del acc.activity['activity']
if acc.activity.has_key('subactivity'): if 'subactivity' in acc.activity:
del acc.activity['subactivity'] del acc.activity['subactivity']
if acc.activity.has_key('text'): if 'text' in acc.activity:
del acc.activity['text'] del acc.activity['text']
(user, resource) = gajim.get_room_and_nick_from_fjid(jid) (user, resource) = gajim.get_room_and_nick_from_fjid(jid)
for contact in gajim.contacts.get_contacts(name, user): for contact in gajim.contacts.get_contacts(name, user):
if has_child: if has_child:
if contact.activity.has_key('activity'): if 'activity' in contact.activity:
del contact.activity['activity'] del contact.activity['activity']
if contact.activity.has_key('subactivity'): if 'subactivity' in contact.activity:
del contact.activity['subactivity'] del contact.activity['subactivity']
if contact.activity.has_key('text'): if 'text' in contact.activity:
del contact.activity['text'] del contact.activity['text']
if activity is not None: if activity is not None:
contact.activity['activity'] = activity contact.activity['activity'] = activity
@ -360,11 +360,11 @@ def user_activity(items, name, jid):
if text is not None: if text is not None:
contact.activity['text'] = text contact.activity['text'] = text
elif retract: elif retract:
if contact.activity.has_key('activity'): if 'activity' in contact.activity:
del contact.activity['activity'] del contact.activity['activity']
if contact.activity.has_key('subactivity'): if 'subactivity' in contact.activity:
del contact.activity['subactivity'] del contact.activity['subactivity']
if contact.activity.has_key('text'): if 'text' in contact.activity:
del contact.activity['text'] del contact.activity['text']
if jid == gajim.get_jid_from_account(name): if jid == gajim.get_jid_from_account(name):

View file

@ -52,7 +52,7 @@ class Proxy65Manager:
def resolve(self, proxy, connection, sender_jid, default=None): def resolve(self, proxy, connection, sender_jid, default=None):
''' start ''' ''' start '''
if self.proxies.has_key(proxy): if proxy in self.proxies:
resolver = self.proxies[proxy] resolver = self.proxies[proxy]
else: else:
# proxy is being ressolved for the first time # proxy is being ressolved for the first time
@ -68,7 +68,7 @@ class Proxy65Manager:
resolver.disconnect(connection) resolver.disconnect(connection)
def resolve_result(self, proxy, query): def resolve_result(self, proxy, query):
if not self.proxies.has_key(proxy): if proxy not in self.proxies:
return return
jid = None jid = None
for item in query.getChildren(): for item in query.getChildren():
@ -88,11 +88,11 @@ class Proxy65Manager:
break break
def get_default_for_name(self, account): def get_default_for_name(self, account):
if self.default_proxies.has_key(account): if account in self.default_proxies:
return self.default_proxies[account] return self.default_proxies[account]
def get_proxy(self, proxy, account): def get_proxy(self, proxy, account):
if self.proxies.has_key(proxy): if proxy in self.proxies:
resolver = self.proxies[proxy] resolver = self.proxies[proxy]
if resolver.state == S_FINISHED: if resolver.state == S_FINISHED:
return (resolver.host, resolver.port, resolver.jid) return (resolver.host, resolver.port, resolver.jid)

View file

@ -89,15 +89,15 @@ class SocksQueue:
return self.listener return self.listener
def send_success_reply(self, file_props, streamhost): def send_success_reply(self, file_props, streamhost):
if file_props.has_key('streamhost-used') and \ if 'streamhost-used' in file_props and \
file_props['streamhost-used'] is True: file_props['streamhost-used'] is True:
if file_props.has_key('proxyhosts'): if 'proxyhosts' in file_props:
for proxy in file_props['proxyhosts']: for proxy in file_props['proxyhosts']:
if proxy == streamhost: if proxy == streamhost:
self.on_success(streamhost) self.on_success(streamhost)
return 2 return 2
return 0 return 0
if file_props.has_key('streamhosts'): if 'streamhosts' in file_props:
for host in file_props['streamhosts']: for host in file_props['streamhosts']:
if streamhost['state'] == 1: if streamhost['state'] == 1:
return 0 return 0
@ -123,7 +123,7 @@ class SocksQueue:
''' called when there is a host connected to one of the ''' called when there is a host connected to one of the
senders's streamhosts. Stop othere attempts for connections ''' senders's streamhosts. Stop othere attempts for connections '''
for host in file_props['streamhosts']: for host in file_props['streamhosts']:
if host != streamhost and host.has_key('idx'): if host != streamhost and 'idx' in host:
if host['state'] == 1: if host['state'] == 1:
# remove current # remove current
self.remove_receiver(streamhost['idx']) self.remove_receiver(streamhost['idx'])
@ -147,7 +147,7 @@ class SocksQueue:
# boolean, indicates that there are hosts, which are not tested yet # boolean, indicates that there are hosts, which are not tested yet
unused_hosts = False unused_hosts = False
for host in file_props['streamhosts']: for host in file_props['streamhosts']:
if host.has_key('idx'): if 'idx' in host:
if host['state'] >= 0: if host['state'] >= 0:
return return
elif host['state'] == -2: elif host['state'] == -2:
@ -161,7 +161,7 @@ class SocksQueue:
host['idx'] = receiver.queue_idx host['idx'] = receiver.queue_idx
# we still have chances to connect # we still have chances to connect
return return
if not file_props.has_key('received-len') or file_props['received-len'] == 0: if 'received-len' not in file_props or file_props['received-len'] == 0:
# there are no other streamhosts and transfer hasn't started # there are no other streamhosts and transfer hasn't started
self._connection_refused(streamhost, file_props, receiver.queue_idx) self._connection_refused(streamhost, file_props, receiver.queue_idx)
else: else:
@ -176,12 +176,12 @@ class SocksQueue:
return return
streamhost['state'] = -1 streamhost['state'] = -1
self.remove_receiver(idx, False) self.remove_receiver(idx, False)
if file_props.has_key('streamhosts'): if 'streamhosts' in file_props:
for host in file_props['streamhosts']: for host in file_props['streamhosts']:
if host['state'] != -1: if host['state'] != -1:
return return
# failure_cb exists - this means that it has never been called # failure_cb exists - this means that it has never been called
if file_props.has_key('failure_cb') and file_props['failure_cb']: if 'failure_cb' in file_props and file_props['failure_cb']:
file_props['failure_cb'](streamhost['initiator'], streamhost['id'], file_props['failure_cb'](streamhost['initiator'], streamhost['id'],
file_props['sid'], code = 404) file_props['sid'], code = 404)
del(file_props['failure_cb']) del(file_props['failure_cb'])
@ -204,8 +204,8 @@ class SocksQueue:
def get_file_from_sender(self, file_props, account): def get_file_from_sender(self, file_props, account):
if file_props is None: if file_props is None:
return return
if file_props.has_key('hash') and \ if 'hash' in file_props and \
self.senders.has_key(file_props['hash']): file_props['hash'] in self.senders:
sender = self.senders[file_props['hash']] sender = self.senders[file_props['hash']]
sender.account = account sender.account = account
@ -213,12 +213,12 @@ class SocksQueue:
self.process_result(result, sender) self.process_result(result, sender)
def result_sha(self, sha_str, idx): def result_sha(self, sha_str, idx):
if self.sha_handlers.has_key(sha_str): if sha_str in self.sha_handlers:
props = self.sha_handlers[sha_str] props = self.sha_handlers[sha_str]
props[0](props[1], idx) props[0](props[1], idx)
def activate_proxy(self, idx): def activate_proxy(self, idx):
if not self.readers.has_key(idx): if idx not in self.readers:
return return
reader = self.readers[idx] reader = self.readers[idx]
if reader.file_props['type'] != 's': if reader.file_props['type'] != 's':
@ -244,8 +244,8 @@ class SocksQueue:
self.process_result(result, reader) self.process_result(result, reader)
def send_file(self, file_props, account): def send_file(self, file_props, account):
if file_props.has_key('hash') and \ if 'hash' in file_props and \
self.senders.has_key(file_props['hash']): file_props['hash'] in self.senders:
sender = self.senders[file_props['hash']] sender = self.senders[file_props['hash']]
file_props['streamhost-used'] = True file_props['streamhost-used'] = True
sender.account = account sender.account = account
@ -264,17 +264,17 @@ class SocksQueue:
It is identified by account name and sid It is identified by account name and sid
''' '''
if file_props is None or \ if file_props is None or \
file_props.has_key('sid') is False: ('sid' in file_props) is False:
return return
_id = file_props['sid'] _id = file_props['sid']
if not self.files_props.has_key(account): if account not in self.files_props:
self.files_props[account] = {} self.files_props[account] = {}
self.files_props[account][_id] = file_props self.files_props[account][_id] = file_props
def remove_file_props(self, account, sid): def remove_file_props(self, account, sid):
if self.files_props.has_key(account): if account in self.files_props:
fl_props = self.files_props[account] fl_props = self.files_props[account]
if fl_props.has_key(sid): if sid in fl_props:
del(fl_props[sid]) del(fl_props[sid])
if len(self.files_props) == 0: if len(self.files_props) == 0:
@ -282,15 +282,15 @@ class SocksQueue:
def get_file_props(self, account, sid): def get_file_props(self, account, sid):
''' get fil_prop by account name and session id ''' ''' get fil_prop by account name and session id '''
if self.files_props.has_key(account): if account in self.files_props:
fl_props = self.files_props[account] fl_props = self.files_props[account]
if fl_props.has_key(sid): if sid in fl_props:
return fl_props[sid] return fl_props[sid]
return None return None
def on_connection_accepted(self, sock): def on_connection_accepted(self, sock):
sock_hash = sock.__hash__() sock_hash = sock.__hash__()
if not self.senders.has_key(sock_hash): if sock_hash not in self.senders:
self.senders[sock_hash] = Socks5Sender(self.idlequeue, self.senders[sock_hash] = Socks5Sender(self.idlequeue,
sock_hash, self, sock[0], sock[1][0], sock[1][1]) sock_hash, self, sock[0], sock[1][0], sock[1][1])
self.connected += 1 self.connected += 1
@ -305,7 +305,7 @@ class SocksQueue:
return return
if result in (0, -1) and self.complete_transfer_cb is not None: if result in (0, -1) and self.complete_transfer_cb is not None:
account = actor.account account = actor.account
if account is None and actor.file_props.has_key('tt_account'): if account is None and 'tt_account' in actor.file_props:
account = actor.file_props['tt_account'] account = actor.file_props['tt_account']
self.complete_transfer_cb(account, actor.file_props) self.complete_transfer_cb(account, actor.file_props)
elif self.progress_transfer_cb is not None: elif self.progress_transfer_cb is not None:
@ -315,7 +315,7 @@ class SocksQueue:
''' Remove reciver from the list and decrease ''' Remove reciver from the list and decrease
the number of active connections with 1''' the number of active connections with 1'''
if idx != -1: if idx != -1:
if self.readers.has_key(idx): if idx in self.readers:
reader = self.readers[idx] reader = self.readers[idx]
self.idlequeue.unplug_idle(reader.fd) self.idlequeue.unplug_idle(reader.fd)
self.idlequeue.remove_timeout(reader.fd) self.idlequeue.remove_timeout(reader.fd)
@ -330,7 +330,7 @@ class SocksQueue:
''' Remove sender from the list of senders and decrease the ''' Remove sender from the list of senders and decrease the
number of active connections with 1''' number of active connections with 1'''
if idx != -1: if idx != -1:
if self.senders.has_key(idx): if idx in self.senders:
if do_disconnect: if do_disconnect:
self.senders[idx].disconnect() self.senders[idx].disconnect()
return return
@ -369,7 +369,7 @@ class Socks5:
if self.file is None: if self.file is None:
try: try:
self.file = open(self.file_props['file-name'],'rb') self.file = open(self.file_props['file-name'],'rb')
if self.file_props.has_key('offset') and self.file_props['offset']: if 'offset' in self.file_props and self.file_props['offset']:
self.size = self.file_props['offset'] self.size = self.file_props['offset']
self.file.seek(self.size) self.file.seek(self.size)
self.file_props['received-len'] = self.size self.file_props['received-len'] = self.size
@ -390,12 +390,12 @@ class Socks5:
''' Test if file is already open and return its fd, ''' Test if file is already open and return its fd,
or just open the file and return the fd. or just open the file and return the fd.
''' '''
if self.file_props.has_key('fd'): if 'fd' in self.file_props:
fd = self.file_props['fd'] fd = self.file_props['fd']
else: else:
offset = 0 offset = 0
opt = 'wb' opt = 'wb'
if self.file_props.has_key('offset') and self.file_props['offset']: if 'offset' in self.file_props and self.file_props['offset']:
offset = self.file_props['offset'] offset = self.file_props['offset']
opt = 'ab' opt = 'ab'
fd = open(self.file_props['file-name'], opt) fd = open(self.file_props['file-name'], opt)
@ -406,7 +406,7 @@ class Socks5:
return fd return fd
def rem_fd(self, fd): def rem_fd(self, fd):
if self.file_props.has_key('fd'): if 'fd' in self.file_props:
del(self.file_props['fd']) del(self.file_props['fd'])
try: try:
fd.close() fd.close()
@ -488,7 +488,7 @@ class Socks5:
''' read file contents from socket and write them to file ''', \ ''' read file contents from socket and write them to file ''', \
self.file_props['type'], self.file_props['sid'] self.file_props['type'], self.file_props['sid']
if self.file_props is None or \ if self.file_props is None or \
self.file_props.has_key('file-name') is False: ('file-name' in self.file_props) is False:
self.file_props['error'] = -2 self.file_props['error'] = -2
return None return None
fd = None fd = None
@ -545,7 +545,7 @@ class Socks5:
self.file_props['stalled'] = False self.file_props['stalled'] = False
if fd is None and self.file_props['stalled'] is False: if fd is None and self.file_props['stalled'] is False:
return None return None
if self.file_props.has_key('received-len'): if 'received-len' in self.file_props:
if self.file_props['received-len'] != 0: if self.file_props['received-len'] != 0:
return self.file_props['received-len'] return self.file_props['received-len']
return None return None
@ -647,7 +647,7 @@ class Socks5:
def _get_sha1_auth(self): def _get_sha1_auth(self):
''' get sha of sid + Initiator jid + Target jid ''' ''' get sha of sid + Initiator jid + Target jid '''
if self.file_props.has_key('is_a_proxy'): if 'is_a_proxy' in self.file_props:
del(self.file_props['is_a_proxy']) del(self.file_props['is_a_proxy'])
return sha.new('%s%s%s' % (self.sid, self.file_props['proxy_sender'], return sha.new('%s%s%s' % (self.sid, self.file_props['proxy_sender'],
self.file_props['proxy_receiver'])).hexdigest() self.file_props['proxy_receiver'])).hexdigest()
@ -880,7 +880,7 @@ class Socks5Receiver(Socks5, IdleObject):
# no activity for foo seconds # no activity for foo seconds
if self.file_props['stalled'] == False: if self.file_props['stalled'] == False:
self.file_props['stalled'] = True self.file_props['stalled'] = True
if not self.file_props.has_key('received-len'): if 'received-len' not in self.file_props:
self.file_props['received-len'] = 0 self.file_props['received-len'] = 0
self.queue.process_result(-1, self) self.queue.process_result(-1, self)
if READ_TIMEOUT > 0: if READ_TIMEOUT > 0:

View file

@ -102,7 +102,7 @@ class SASL(PlugIn):
self.password=password self.password=password
def plugin(self,owner): def plugin(self,owner):
if not self._owner.Dispatcher.Stream._document_attrs.has_key('version'): self.startsasl='not-supported' if 'version' not in self._owner.Dispatcher.Stream._document_attrs: self.startsasl='not-supported'
elif self._owner.Dispatcher.Stream.features: elif self._owner.Dispatcher.Stream.features:
try: self.FeaturesHandler(self._owner.Dispatcher,self._owner.Dispatcher.Stream.features) try: self.FeaturesHandler(self._owner.Dispatcher,self._owner.Dispatcher.Stream.features)
except NodeProcessed: pass except NodeProcessed: pass
@ -177,7 +177,7 @@ class SASL(PlugIn):
key,value=pair.split('=', 1) key,value=pair.split('=', 1)
if value[:1]=='"' and value[-1:]=='"': value=value[1:-1] if value[:1]=='"' and value[-1:]=='"': value=value[1:-1]
chal[key]=value chal[key]=value
if chal.has_key('qop') and chal['qop']=='auth': if 'qop' in chal and chal['qop']=='auth':
resp={} resp={}
resp['username']=self.username resp['username']=self.username
resp['realm']=self._owner.Server resp['realm']=self._owner.Server
@ -201,7 +201,7 @@ class SASL(PlugIn):
########################################3333 ########################################3333
node=Node('response',attrs={'xmlns':NS_SASL},payload=[base64.encodestring(sasl_data[:-1]).replace('\r','').replace('\n','')]) node=Node('response',attrs={'xmlns':NS_SASL},payload=[base64.encodestring(sasl_data[:-1]).replace('\r','').replace('\n','')])
self._owner.send(node.__str__()) self._owner.send(node.__str__())
elif chal.has_key('rspauth'): self._owner.send(Node('response',attrs={'xmlns':NS_SASL}).__str__()) elif 'rspauth' in chal: self._owner.send(Node('response',attrs={'xmlns':NS_SASL}).__str__())
else: else:
self.startsasl='failure' self.startsasl='failure'
self.DEBUG('Failed SASL authentification: unknown challenge','error') self.DEBUG('Failed SASL authentification: unknown challenge','error')

View file

@ -100,7 +100,7 @@ class SASL(PlugIn):
self.on_sasl = on_sasl self.on_sasl = on_sasl
self.realm = None self.realm = None
def plugin(self,owner): def plugin(self,owner):
if not self._owner.Dispatcher.Stream._document_attrs.has_key('version'): if 'version' not in self._owner.Dispatcher.Stream._document_attrs:
self.startsasl='not-supported' self.startsasl='not-supported'
elif self._owner.Dispatcher.Stream.features: elif self._owner.Dispatcher.Stream.features:
try: try:
@ -212,9 +212,9 @@ class SASL(PlugIn):
payload=response).__str__()) payload=response).__str__())
raise NodeProcessed raise NodeProcessed
chal = challenge_splitter(data) chal = challenge_splitter(data)
if not self.realm and chal.has_key('realm'): if not self.realm and 'realm' in chal:
self.realm = chal['realm'] self.realm = chal['realm']
if chal.has_key('qop') and ((type(chal['qop']) == str and \ if 'qop' in chal and ((type(chal['qop']) == str and \
chal['qop'] =='auth') or (type(chal['qop']) == list and 'auth' in \ chal['qop'] =='auth') or (type(chal['qop']) == list and 'auth' in \
chal['qop'])): chal['qop'])):
resp={} resp={}
@ -248,7 +248,7 @@ class SASL(PlugIn):
node=Node('response', attrs={'xmlns':NS_SASL}, node=Node('response', attrs={'xmlns':NS_SASL},
payload=[base64.encodestring(sasl_data[:-1]).replace('\r','').replace('\n','')]) payload=[base64.encodestring(sasl_data[:-1]).replace('\r','').replace('\n','')])
self._owner.send(node.__str__()) self._owner.send(node.__str__())
elif chal.has_key('rspauth'): elif 'rspauth' in chal:
self._owner.send(Node('response', attrs={'xmlns':NS_SASL}).__str__()) self._owner.send(Node('response', attrs={'xmlns':NS_SASL}).__str__())
else: else:
self.startsasl='failure' self.startsasl='failure'

View file

@ -104,7 +104,7 @@ class Browser(PlugIn):
Set returns '' or None as the key Set returns '' or None as the key
get returns '' or None as the key or None as the dict. get returns '' or None as the key or None as the dict.
Used internally.""" Used internally."""
if self._handlers.has_key(jid): cur=self._handlers[jid] if jid in self._handlers: cur=self._handlers[jid]
elif set: elif set:
self._handlers[jid]={} self._handlers[jid]={}
cur=self._handlers[jid] cur=self._handlers[jid]
@ -112,11 +112,11 @@ class Browser(PlugIn):
if node is None: node=[None] if node is None: node=[None]
else: node=node.replace('/',' /').split('/') else: node=node.replace('/',' /').split('/')
for i in node: for i in node:
if i<>'' and cur.has_key(i): cur=cur[i] if i<>'' and i in cur: cur=cur[i]
elif set and i<>'': cur[i]={dict:cur,str:i}; cur=cur[i] elif set and i<>'': cur[i]={dict:cur,str:i}; cur=cur[i]
elif set or cur.has_key(''): return cur,'' elif set or '' in cur: return cur,''
else: return None,None else: return None,None
if cur.has_key(1) or set: return cur,1 if 1 in cur or set: return cur,1
raise "Corrupted data" raise "Corrupted data"
def setDiscoHandler(self,handler,node='',jid=''): def setDiscoHandler(self,handler,node='',jid=''):
@ -211,7 +211,7 @@ class Browser(PlugIn):
# {'ids':[{},{},{},{}], 'features':[fe,at,ur,es], 'xdata':DataForm} # {'ids':[{},{},{},{}], 'features':[fe,at,ur,es], 'xdata':DataForm}
for id in dt['ids']: q.addChild('identity',id) for id in dt['ids']: q.addChild('identity',id)
for feature in dt['features']: q.addChild('feature',{'var':feature}) for feature in dt['features']: q.addChild('feature',{'var':feature})
if dt.has_key('xdata'): q.addChild(node=dt['xdata']) if 'xdata' in dt: q.addChild(node=dt['xdata'])
conn.send(rep) conn.send(rep)
raise NodeProcessed raise NodeProcessed

View file

@ -62,15 +62,15 @@ class PlugIn:
if self.DBG_LINE not in owner.debug_flags: if self.DBG_LINE not in owner.debug_flags:
owner.debug_flags.append(self.DBG_LINE) owner.debug_flags.append(self.DBG_LINE)
self.DEBUG('Plugging %s into %s'%(self,self._owner),'start') self.DEBUG('Plugging %s into %s'%(self,self._owner),'start')
if owner.__dict__.has_key(self.__class__.__name__): if self.__class__.__name__ in owner.__dict__:
return self.DEBUG('Plugging ignored: another instance already plugged.','error') return self.DEBUG('Plugging ignored: another instance already plugged.','error')
self._old_owners_methods=[] self._old_owners_methods=[]
for method in self._exported_methods: for method in self._exported_methods:
if owner.__dict__.has_key(method.__name__): if method.__name__ in owner.__dict__:
self._old_owners_methods.append(owner.__dict__[method.__name__]) self._old_owners_methods.append(owner.__dict__[method.__name__])
owner.__dict__[method.__name__]=method owner.__dict__[method.__name__]=method
owner.__dict__[self.__class__.__name__]=self owner.__dict__[self.__class__.__name__]=self
if self.__class__.__dict__.has_key('plugin'): return self.plugin(owner) if 'plugin' in self.__class__.__dict__: return self.plugin(owner)
def PlugOut(self): def PlugOut(self):
""" Unregister all our staff from main instance and detach from it. """ """ Unregister all our staff from main instance and detach from it. """
@ -79,7 +79,7 @@ class PlugIn:
for method in self._exported_methods: del self._owner.__dict__[method.__name__] for method in self._exported_methods: del self._owner.__dict__[method.__name__]
for method in self._old_owners_methods: self._owner.__dict__[method.__name__]=method for method in self._old_owners_methods: self._owner.__dict__[method.__name__]=method
del self._owner.__dict__[self.__class__.__name__] del self._owner.__dict__[self.__class__.__name__]
if self.__class__.__dict__.has_key('plugout'): return self.plugout() if 'plugout' in self.__class__.__dict__: return self.plugout()
del self._owner del self._owner
def DEBUG(self,text,severity='info'): def DEBUG(self,text,severity='info'):
@ -130,7 +130,7 @@ class CommonClient:
self.disconnect_handlers.reverse() self.disconnect_handlers.reverse()
for i in self.disconnect_handlers: i() for i in self.disconnect_handlers: i()
self.disconnect_handlers.reverse() self.disconnect_handlers.reverse()
if self.__dict__.has_key('TLS'): self.TLS.PlugOut() if 'TLS' in self.__dict__: self.TLS.PlugOut()
def DisconnectHandler(self): def DisconnectHandler(self):
""" Default disconnect handler. Just raises an IOError. """ Default disconnect handler. Just raises an IOError.
@ -150,11 +150,11 @@ class CommonClient:
""" Example of reconnection method. In fact, it can be used to batch connection and auth as well. """ """ Example of reconnection method. In fact, it can be used to batch connection and auth as well. """
handlerssave=self.Dispatcher.dumpHandlers() handlerssave=self.Dispatcher.dumpHandlers()
self.Dispatcher.PlugOut() self.Dispatcher.PlugOut()
if self.__dict__.has_key('NonSASL'): self.NonSASL.PlugOut() if 'NonSASL' in self.__dict__: self.NonSASL.PlugOut()
if self.__dict__.has_key('SASL'): self.SASL.PlugOut() if 'SASL' in self.__dict__: self.SASL.PlugOut()
if self.__dict__.has_key('TLS'): self.TLS.PlugOut() if 'TLS' in self.__dict__: self.TLS.PlugOut()
if self.__dict__.has_key('HTTPPROXYsocket'): self.HTTPPROXYsocket.PlugOut() if 'HTTPPROXYsocket' in self.__dict__: self.HTTPPROXYsocket.PlugOut()
if self.__dict__.has_key('TCPsocket'): self.TCPsocket.PlugOut() if 'TCPsocket' in self.__dict__: self.TCPsocket.PlugOut()
if not self.connect(server=self._Server,proxy=self._Proxy): return if not self.connect(server=self._Server,proxy=self._Proxy): return
if not self.auth(self._User,self._Password,self._Resource): return if not self.auth(self._User,self._Password,self._Resource): return
self.Dispatcher.restoreHandlers(handlerssave) self.Dispatcher.restoreHandlers(handlerssave)
@ -188,7 +188,7 @@ class CommonClient:
dispatcher.Dispatcher().PlugIn(self) dispatcher.Dispatcher().PlugIn(self)
while self.Dispatcher.Stream._document_attrs is None: while self.Dispatcher.Stream._document_attrs is None:
if not self.Process(1): return if not self.Process(1): return
if self.Dispatcher.Stream._document_attrs.has_key('version') and self.Dispatcher.Stream._document_attrs['version']=='1.0': if 'version' in self.Dispatcher.Stream._document_attrs and self.Dispatcher.Stream._document_attrs['version']=='1.0':
while not self.Dispatcher.Stream.features and self.Process(): pass # If we get version 1.0 stream the features tag MUST BE presented while not self.Dispatcher.Stream.features and self.Process(): pass # If we get version 1.0 stream the features tag MUST BE presented
return self.connected return self.connected
@ -205,7 +205,7 @@ class Client(CommonClient):
Returns '' or 'tcp' or 'tls', depending on the result.""" Returns '' or 'tcp' or 'tls', depending on the result."""
if not CommonClient.connect(self,server,proxy,secure,use_srv) or secure<>None and not secure: return self.connected if not CommonClient.connect(self,server,proxy,secure,use_srv) or secure<>None and not secure: return self.connected
transports.TLS().PlugIn(self) transports.TLS().PlugIn(self)
if not self.Dispatcher.Stream._document_attrs.has_key('version') or not self.Dispatcher.Stream._document_attrs['version']=='1.0': return self.connected if 'version' not in self.Dispatcher.Stream._document_attrs or not self.Dispatcher.Stream._document_attrs['version']=='1.0': return self.connected
while not self.Dispatcher.Stream.features and self.Process(): pass # If we get version 1.0 stream the features tag MUST BE presented while not self.Dispatcher.Stream.features and self.Process(): pass # If we get version 1.0 stream the features tag MUST BE presented
if not self.Dispatcher.Stream.features.getTag('starttls'): return self.connected # TLS not supported by server if not self.Dispatcher.Stream.features.getTag('starttls'): return self.connected # TLS not supported by server
while not self.TLS.starttls and self.Process(): pass while not self.TLS.starttls and self.Process(): pass
@ -218,7 +218,7 @@ class Client(CommonClient):
random one or library name used. """ random one or library name used. """
self._User,self._Password,self._Resource=user,password,resource self._User,self._Password,self._Resource=user,password,resource
while not self.Dispatcher.Stream._document_attrs and self.Process(): pass while not self.Dispatcher.Stream._document_attrs and self.Process(): pass
if self.Dispatcher.Stream._document_attrs.has_key('version') and self.Dispatcher.Stream._document_attrs['version']=='1.0': if 'version' in self.Dispatcher.Stream._document_attrs and self.Dispatcher.Stream._document_attrs['version']=='1.0':
while not self.Dispatcher.Stream.features and self.Process(): pass # If we get version 1.0 stream the features tag MUST BE presented while not self.Dispatcher.Stream.features and self.Process(): pass # If we get version 1.0 stream the features tag MUST BE presented
if sasl: auth.SASL(user,password).PlugIn(self) if sasl: auth.SASL(user,password).PlugIn(self)
if not sasl or self.SASL.startsasl=='not-supported': if not sasl or self.SASL.startsasl=='not-supported':
@ -238,7 +238,7 @@ class Client(CommonClient):
def initRoster(self): def initRoster(self):
""" Plug in the roster. """ """ Plug in the roster. """
if not self.__dict__.has_key('Roster'): roster.Roster().PlugIn(self) if 'Roster' not in self.__dict__: roster.Roster().PlugIn(self)
def getRoster(self): def getRoster(self):
""" Return the Roster instance, previously plugging it in and """ Return the Roster instance, previously plugging it in and

View file

@ -77,21 +77,21 @@ class NBCommonClient(CommonClient):
self.DEBUG(self.DBG,'Disconnect detected','stop') self.DEBUG(self.DBG,'Disconnect detected','stop')
for i in reversed(self.disconnect_handlers): for i in reversed(self.disconnect_handlers):
i() i()
if self.__dict__.has_key('NonBlockingRoster'): if 'NonBlockingRoster' in self.__dict__:
self.NonBlockingRoster.PlugOut() self.NonBlockingRoster.PlugOut()
if self.__dict__.has_key('NonBlockingBind'): if 'NonBlockingBind' in self.__dict__:
self.NonBlockingBind.PlugOut() self.NonBlockingBind.PlugOut()
if self.__dict__.has_key('NonBlockingNonSASL'): if 'NonBlockingNonSASL' in self.__dict__:
self.NonBlockingNonSASL.PlugOut() self.NonBlockingNonSASL.PlugOut()
if self.__dict__.has_key('SASL'): if 'SASL' in self.__dict__:
self.SASL.PlugOut() self.SASL.PlugOut()
if self.__dict__.has_key('NonBlockingTLS'): if 'NonBlockingTLS' in self.__dict__:
self.NonBlockingTLS.PlugOut() self.NonBlockingTLS.PlugOut()
if self.__dict__.has_key('NBHTTPPROXYsocket'): if 'NBHTTPPROXYsocket' in self.__dict__:
self.NBHTTPPROXYsocket.PlugOut() self.NBHTTPPROXYsocket.PlugOut()
if self.__dict__.has_key('NBSOCKS5PROXYsocket'): if 'NBSOCKS5PROXYsocket' in self.__dict__:
self.NBSOCKS5PROXYsocket.PlugOut() self.NBSOCKS5PROXYsocket.PlugOut()
if self.__dict__.has_key('NonBlockingTcp'): if 'NonBlockingTcp' in self.__dict__:
self.NonBlockingTcp.PlugOut() self.NonBlockingTcp.PlugOut()
def reconnectAndReauth(self): def reconnectAndReauth(self):
@ -106,7 +106,7 @@ class NBCommonClient(CommonClient):
self._Server, self._Proxy, self._Ssl = server , proxy, ssl self._Server, self._Proxy, self._Ssl = server , proxy, ssl
self.on_stream_start = on_stream_start self.on_stream_start = on_stream_start
if proxy: if proxy:
if proxy.has_key('type'): if 'type' in proxy:
type_ = proxy['type'] type_ = proxy['type']
if type_ == 'socks5': if type_ == 'socks5':
self.socket = transports_nb.NBSOCKS5PROXYsocket( self.socket = transports_nb.NBSOCKS5PROXYsocket(
@ -164,7 +164,7 @@ class NBCommonClient(CommonClient):
self.Dispatcher.Stream._document_attrs is None: self.Dispatcher.Stream._document_attrs is None:
return return
self.onreceive(None) self.onreceive(None)
if self.Dispatcher.Stream._document_attrs.has_key('version') and \ if 'version' in self.Dispatcher.Stream._document_attrs and \
self.Dispatcher.Stream._document_attrs['version'] == '1.0': self.Dispatcher.Stream._document_attrs['version'] == '1.0':
self.onreceive(self._on_receive_stream_features) self.onreceive(self._on_receive_stream_features)
return return
@ -219,7 +219,7 @@ class NonBlockingClient(NBCommonClient):
transports_nb.NonBlockingTLS().PlugIn(self) transports_nb.NonBlockingTLS().PlugIn(self)
if not self.Connection: # ssl error, stream is closed if not self.Connection: # ssl error, stream is closed
return True return True
if not self.Dispatcher.Stream._document_attrs.has_key('version') or \ if 'version' not in self.Dispatcher.Stream._document_attrs or \
not self.Dispatcher.Stream._document_attrs['version']=='1.0': not self.Dispatcher.Stream._document_attrs['version']=='1.0':
self._is_connected() self._is_connected()
return return
@ -273,7 +273,7 @@ class NonBlockingClient(NBCommonClient):
def _on_start_sasl(self, data=None): def _on_start_sasl(self, data=None):
if data: if data:
self.Dispatcher.ProcessNonBlocking(data) self.Dispatcher.ProcessNonBlocking(data)
if not self.__dict__.has_key('SASL'): if 'SASL' not in self.__dict__:
# SASL is pluged out, possible disconnect # SASL is pluged out, possible disconnect
return return
if self.SASL.startsasl == 'in-process': if self.SASL.startsasl == 'in-process':
@ -307,13 +307,13 @@ class NonBlockingClient(NBCommonClient):
def initRoster(self): def initRoster(self):
''' Plug in the roster. ''' ''' Plug in the roster. '''
if not self.__dict__.has_key('NonBlockingRoster'): if 'NonBlockingRoster' not in self.__dict__:
roster_nb.NonBlockingRoster().PlugIn(self) roster_nb.NonBlockingRoster().PlugIn(self)
def getRoster(self, on_ready = None): def getRoster(self, on_ready = None):
''' Return the Roster instance, previously plugging it in and ''' Return the Roster instance, previously plugging it in and
requesting roster from server if needed. ''' requesting roster from server if needed. '''
if self.__dict__.has_key('NonBlockingRoster'): if 'NonBlockingRoster' in self.__dict__:
return self.NonBlockingRoster.getRoster(on_ready) return self.NonBlockingRoster.getRoster(on_ready)
return None return None

View file

@ -78,13 +78,13 @@ class Commands(PlugIn):
except: except:
conn.send(Error(request,ERR_BAD_REQUEST)) conn.send(Error(request,ERR_BAD_REQUEST))
raise NodeProcessed raise NodeProcessed
if self._handlers.has_key(jid): if jid in self._handlers:
if self._handlers[jid].has_key(node): if node in self._handlers[jid]:
self._handlers[jid][node]['execute'](conn,request) self._handlers[jid][node]['execute'](conn,request)
else: else:
conn.send(Error(request,ERR_ITEM_NOT_FOUND)) conn.send(Error(request,ERR_ITEM_NOT_FOUND))
raise NodeProcessed raise NodeProcessed
elif self._handlers[''].has_key(node): elif node in self._handlers['']:
self._handlers[''][node]['execute'](conn,request) self._handlers[''][node]['execute'](conn,request)
else: else:
conn.send(Error(request,ERR_ITEM_NOT_FOUND)) conn.send(Error(request,ERR_ITEM_NOT_FOUND))
@ -105,7 +105,7 @@ class Commands(PlugIn):
items = [] items = []
jid = str(request.getTo()) jid = str(request.getTo())
# Get specific jid based results # Get specific jid based results
if self._handlers.has_key(jid): if jid in self._handlers:
for each in self._handlers[jid].keys(): for each in self._handlers[jid].keys():
items.append((jid,each)) items.append((jid,each))
else: else:
@ -133,10 +133,10 @@ class Commands(PlugIn):
# We must: # We must:
# Add item into disco # Add item into disco
# Add item into command list # Add item into command list
if not self._handlers.has_key(jid): if jid not in self._handlers:
self._handlers[jid]={} self._handlers[jid]={}
self._browser.setDiscoHandler(self._DiscoHandler,node=NS_COMMANDS,jid=jid) self._browser.setDiscoHandler(self._DiscoHandler,node=NS_COMMANDS,jid=jid)
if self._handlers[jid].has_key(name): if name in self._handlers[jid]:
raise NameError,'Command Exists' raise NameError,'Command Exists'
else: else:
self._handlers[jid][name]={'disco':cmddisco,'execute':cmdexecute} self._handlers[jid][name]={'disco':cmddisco,'execute':cmdexecute}
@ -149,9 +149,9 @@ class Commands(PlugIn):
# We must: # We must:
# Remove item from disco # Remove item from disco
# Remove item from command list # Remove item from command list
if not self._handlers.has_key(jid): if jid not in self._handlers:
raise NameError,'Jid not found' raise NameError,'Jid not found'
if not self._handlers[jid].has_key(name): if name not in self._handlers[jid]:
raise NameError, 'Command not found' raise NameError, 'Command not found'
else: else:
#Do disco removal here #Do disco removal here
@ -164,9 +164,9 @@ class Commands(PlugIn):
# This gets the command object with name # This gets the command object with name
# We must: # We must:
# Return item that matches this name # Return item that matches this name
if not self._handlers.has_key(jid): if jid not in self._handlers:
raise NameError,'Jid not found' raise NameError,'Jid not found'
elif not self._handlers[jid].has_key(name): elif name not in self._handlers[jid]:
raise NameError,'Command not found' raise NameError,'Command not found'
else: else:
return self._handlers[jid][name] return self._handlers[jid][name]
@ -229,10 +229,10 @@ class Command_Handler_Prototype(PlugIn):
action = None action = None
if action is None: action = 'execute' if action is None: action = 'execute'
# Check session is in session list # Check session is in session list
if self.sessions.has_key(session): if session in self.sessions:
if self.sessions[session]['jid']==request.getFrom(): if self.sessions[session]['jid']==request.getFrom():
# Check action is vaild # Check action is vaild
if self.sessions[session]['actions'].has_key(action): if action in self.sessions[session]['actions']:
# Execute next action # Execute next action
self.sessions[session]['actions'][action](conn,request) self.sessions[session]['actions'][action](conn,request)
else: else:

View file

@ -46,7 +46,7 @@ import os
import types import types
if os.environ.has_key('TERM'): if 'TERM' in os.environ:
colors_enabled=True colors_enabled=True
else: else:
colors_enabled=False colors_enabled=False
@ -377,10 +377,10 @@ class Debug:
def Show(self, flag, msg, prefix=''): def Show(self, flag, msg, prefix=''):
msg=msg.replace('\r','\\r').replace('\n','\\n').replace('><','>\n <') msg=msg.replace('\r','\\r').replace('\n','\\n').replace('><','>\n <')
if not colors_enabled: pass if not colors_enabled: pass
elif self.colors.has_key(prefix): msg=self.colors[prefix]+msg+color_none elif prefix in self.colors: msg=self.colors[prefix]+msg+color_none
else: msg=color_none+msg else: msg=color_none+msg
if not colors_enabled: prefixcolor='' if not colors_enabled: prefixcolor=''
elif self.colors.has_key(flag): prefixcolor=self.colors[flag] elif flag in self.colors: prefixcolor=self.colors[flag]
else: prefixcolor=color_none else: prefixcolor=color_none
if prefix=='error': if prefix=='error':

View file

@ -175,9 +175,9 @@ class Dispatcher(PlugIn):
if not xmlns: xmlns=self._owner.defaultNamespace if not xmlns: xmlns=self._owner.defaultNamespace
self.DEBUG('Registering handler %s for "%s" type->%s ns->%s(%s)'%(handler,name,typ,ns,xmlns), 'info') self.DEBUG('Registering handler %s for "%s" type->%s ns->%s(%s)'%(handler,name,typ,ns,xmlns), 'info')
if not typ and not ns: typ='default' if not typ and not ns: typ='default'
if not self.handlers.has_key(xmlns): self.RegisterNamespace(xmlns,'warn') if xmlns not in self.handlers: self.RegisterNamespace(xmlns,'warn')
if not self.handlers[xmlns].has_key(name): self.RegisterProtocol(name,Protocol,xmlns,'warn') if name not in self.handlers[xmlns]: self.RegisterProtocol(name,Protocol,xmlns,'warn')
if not self.handlers[xmlns][name].has_key(typ+ns): self.handlers[xmlns][name][typ+ns]=[] if typ+ns not in self.handlers[xmlns][name]: self.handlers[xmlns][name][typ+ns]=[]
if makefirst: self.handlers[xmlns][name][typ+ns].insert(0,{'func':handler,'system':system}) if makefirst: self.handlers[xmlns][name][typ+ns].insert(0,{'func':handler,'system':system})
else: self.handlers[xmlns][name][typ+ns].append({'func':handler,'system':system}) else: self.handlers[xmlns][name][typ+ns].append({'func':handler,'system':system})
@ -190,8 +190,8 @@ class Dispatcher(PlugIn):
""" Unregister handler. "typ" and "ns" must be specified exactly the same as with registering.""" """ Unregister handler. "typ" and "ns" must be specified exactly the same as with registering."""
if not xmlns: xmlns=self._owner.defaultNamespace if not xmlns: xmlns=self._owner.defaultNamespace
if not typ and not ns: typ='default' if not typ and not ns: typ='default'
if not self.handlers[xmlns].has_key(name): return if name not in self.handlers[xmlns]: return
if not self.handlers[xmlns][name].has_key(typ+ns): return if typ+ns not in self.handlers[xmlns][name]: return
for pack in self.handlers[xmlns][name][typ+ns]: for pack in self.handlers[xmlns][name][typ+ns]:
if handler==pack['func']: break if handler==pack['func']: break
else: pack=None else: pack=None
@ -264,10 +264,10 @@ class Dispatcher(PlugIn):
if name=='features': session.Stream.features=stanza if name=='features': session.Stream.features=stanza
xmlns=stanza.getNamespace() xmlns=stanza.getNamespace()
if not self.handlers.has_key(xmlns): if xmlns not in self.handlers:
self.DEBUG("Unknown namespace: " + xmlns,'warn') self.DEBUG("Unknown namespace: " + xmlns,'warn')
xmlns='unknown' xmlns='unknown'
if not self.handlers[xmlns].has_key(name): if name not in self.handlers[xmlns]:
self.DEBUG("Unknown stanza: " + name,'warn') self.DEBUG("Unknown stanza: " + name,'warn')
name='unknown' name='unknown'
else: else:
@ -283,17 +283,17 @@ class Dispatcher(PlugIn):
session.DEBUG("Dispatching %s stanza with type->%s props->%s id->%s"%(name,typ,stanza.props,ID),'ok') session.DEBUG("Dispatching %s stanza with type->%s props->%s id->%s"%(name,typ,stanza.props,ID),'ok')
list=['default'] # we will use all handlers: list=['default'] # we will use all handlers:
if self.handlers[xmlns][name].has_key(typ): list.append(typ) # from very common... if typ in self.handlers[xmlns][name]: list.append(typ) # from very common...
for prop in stanza.props: for prop in stanza.props:
if self.handlers[xmlns][name].has_key(prop): list.append(prop) if prop in self.handlers[xmlns][name]: list.append(prop)
if typ and self.handlers[xmlns][name].has_key(typ+prop): list.append(typ+prop) # ...to very particular if typ and typ+prop in self.handlers[xmlns][name]: list.append(typ+prop) # ...to very particular
chain=self.handlers[xmlns]['default']['default'] chain=self.handlers[xmlns]['default']['default']
for key in list: for key in list:
if key: chain = chain + self.handlers[xmlns][name][key] if key: chain = chain + self.handlers[xmlns][name][key]
output='' output=''
if session._expected.has_key(ID): if ID in session._expected:
user=0 user=0
if type(session._expected[ID])==type(()): if type(session._expected[ID])==type(()):
cb,args=session._expected[ID] cb,args=session._expected[ID]

View file

@ -193,11 +193,11 @@ class Dispatcher(PlugIn):
(handler, name, typ, ns, xmlns), 'info') (handler, name, typ, ns, xmlns), 'info')
if not typ and not ns: if not typ and not ns:
typ='default' typ='default'
if not self.handlers.has_key(xmlns): if xmlns not in self.handlers:
self.RegisterNamespace(xmlns,'warn') self.RegisterNamespace(xmlns,'warn')
if not self.handlers[xmlns].has_key(name): if name not in self.handlers[xmlns]:
self.RegisterProtocol(name,Protocol,xmlns,'warn') self.RegisterProtocol(name,Protocol,xmlns,'warn')
if not self.handlers[xmlns][name].has_key(typ+ns): if typ+ns not in self.handlers[xmlns][name]:
self.handlers[xmlns][name][typ+ns]=[] self.handlers[xmlns][name][typ+ns]=[]
if makefirst: if makefirst:
self.handlers[xmlns][name][typ+ns].insert(0,{'func':handler,'system':system}) self.handlers[xmlns][name][typ+ns].insert(0,{'func':handler,'system':system})
@ -216,11 +216,11 @@ class Dispatcher(PlugIn):
xmlns=self._owner.defaultNamespace xmlns=self._owner.defaultNamespace
if not typ and not ns: if not typ and not ns:
typ='default' typ='default'
if not self.handlers.has_key(xmlns): if xmlns not in self.handlers:
return return
if not self.handlers[xmlns].has_key(name): if name not in self.handlers[xmlns]:
return return
if not self.handlers[xmlns][name].has_key(typ+ns): if typ+ns not in self.handlers[xmlns][name]:
return return
for pack in self.handlers[xmlns][name][typ+ns]: for pack in self.handlers[xmlns][name][typ+ns]:
if handler==pack['func']: if handler==pack['func']:
@ -306,10 +306,10 @@ class Dispatcher(PlugIn):
session.Stream.features=stanza session.Stream.features=stanza
xmlns=stanza.getNamespace() xmlns=stanza.getNamespace()
if not self.handlers.has_key(xmlns): if xmlns not in self.handlers:
self.DEBUG("Unknown namespace: " + xmlns, 'warn') self.DEBUG("Unknown namespace: " + xmlns, 'warn')
xmlns='unknown' xmlns='unknown'
if not self.handlers[xmlns].has_key(name): if name not in self.handlers[xmlns]:
self.DEBUG("Unknown stanza: " + name, 'warn') self.DEBUG("Unknown stanza: " + name, 'warn')
name='unknown' name='unknown'
else: else:
@ -325,17 +325,17 @@ class Dispatcher(PlugIn):
session.DEBUG("Dispatching %s stanza with type->%s props->%s id->%s"%(name,typ,stanza.props,ID),'ok') session.DEBUG("Dispatching %s stanza with type->%s props->%s id->%s"%(name,typ,stanza.props,ID),'ok')
list=['default'] # we will use all handlers: list=['default'] # we will use all handlers:
if self.handlers[xmlns][name].has_key(typ): list.append(typ) # from very common... if typ in self.handlers[xmlns][name]: list.append(typ) # from very common...
for prop in stanza.props: for prop in stanza.props:
if self.handlers[xmlns][name].has_key(prop): list.append(prop) if prop in self.handlers[xmlns][name]: list.append(prop)
if typ and self.handlers[xmlns][name].has_key(typ+prop): list.append(typ+prop) # ...to very particular if typ and typ+prop in self.handlers[xmlns][name]: list.append(typ+prop) # ...to very particular
chain=self.handlers[xmlns]['default']['default'] chain=self.handlers[xmlns]['default']['default']
for key in list: for key in list:
if key: chain = chain + self.handlers[xmlns][name][key] if key: chain = chain + self.handlers[xmlns][name][key]
output='' output=''
if session._expected.has_key(ID): if ID in session._expected:
user=0 user=0
if type(session._expected[ID]) == type(()): if type(session._expected[ID]) == type(()):
cb,args = session._expected[ID] cb,args = session._expected[ID]
@ -372,7 +372,7 @@ class Dispatcher(PlugIn):
self._owner.remove_timeout() self._owner.remove_timeout()
if self._expected[self._witid] is None: if self._expected[self._witid] is None:
return return
if self.on_responses.has_key(self._witid): if self._witid in self.on_responses:
i = self._witid # copy id cause it can change in resp() call i = self._witid # copy id cause it can change in resp() call
self._owner.onreceive(None) self._owner.onreceive(None)
resp, args = self.on_responses[self._witid] resp, args = self.on_responses[self._witid]

View file

@ -236,13 +236,13 @@ def setPrivacyList(disp, listname, tags):
iq = Iq('set', NS_PRIVACY, xmlns = '') iq = Iq('set', NS_PRIVACY, xmlns = '')
list_query = iq.getTag('query').setTag('list', {'name': listname}) list_query = iq.getTag('query').setTag('list', {'name': listname})
for item in tags: for item in tags:
if item.has_key('type') and item.has_key('value'): if 'type' in item and 'value' in item:
item_tag = list_query.setTag('item', {'action': item['action'], item_tag = list_query.setTag('item', {'action': item['action'],
'order': item['order'], 'type': item['type'], 'value': item['value']}) 'order': item['order'], 'type': item['type'], 'value': item['value']})
else: else:
item_tag = list_query.setTag('item', {'action': item['action'], item_tag = list_query.setTag('item', {'action': item['action'],
'order': item['order']}) 'order': item['order']})
if item.has_key('child'): if 'child' in item:
for child_tag in item['child']: for child_tag in item['child']:
item_tag.setTag(child_tag) item_tag.setTag(child_tag)
_on_default_response(disp, iq, None) _on_default_response(disp, iq, None)

View file

@ -53,14 +53,14 @@ class IdleQueue:
self.selector = select.poll() self.selector = select.poll()
def remove_timeout(self, fd): def remove_timeout(self, fd):
if self.read_timeouts.has_key(fd): if fd in self.read_timeouts:
del(self.read_timeouts[fd]) del(self.read_timeouts[fd])
def set_alarm(self, alarm_cb, seconds): def set_alarm(self, alarm_cb, seconds):
''' set up a new alarm, to be called after alarm_cb sec. ''' ''' set up a new alarm, to be called after alarm_cb sec. '''
alarm_time = self.current_time() + seconds alarm_time = self.current_time() + seconds
# almost impossible, but in case we have another alarm_cb at this time # almost impossible, but in case we have another alarm_cb at this time
if self.alarms.has_key(alarm_time): if alarm_time in self.alarms:
self.alarms[alarm_time].append(alarm_cb) self.alarms[alarm_time].append(alarm_cb)
else: else:
self.alarms[alarm_time] = [alarm_cb] self.alarms[alarm_time] = [alarm_cb]
@ -76,7 +76,7 @@ class IdleQueue:
for fd, timeout in self.read_timeouts.items(): for fd, timeout in self.read_timeouts.items():
if timeout > current_time: if timeout > current_time:
continue continue
if self.queue.has_key(fd): if fd in self.queue:
self.queue[fd].read_timeout() self.queue[fd].read_timeout()
else: else:
self.remove_timeout(fd) self.remove_timeout(fd)
@ -91,7 +91,7 @@ class IdleQueue:
def plug_idle(self, obj, writable = True, readable = True): def plug_idle(self, obj, writable = True, readable = True):
if obj.fd == -1: if obj.fd == -1:
return return
if self.queue.has_key(obj.fd): if obj.fd in self.queue:
self.unplug_idle(obj.fd) self.unplug_idle(obj.fd)
self.queue[obj.fd] = obj self.queue[obj.fd] = obj
if writable: if writable:
@ -111,7 +111,7 @@ class IdleQueue:
self.selector.register(fd, flags) self.selector.register(fd, flags)
def unplug_idle(self, fd): def unplug_idle(self, fd):
if self.queue.has_key(fd): if fd in self.queue:
del(self.queue[fd]) del(self.queue[fd])
self.remove_idle(fd) self.remove_idle(fd)
@ -187,11 +187,11 @@ class SelectIdleQueue(IdleQueue):
''' this method is called when we unplug a new idle object. ''' this method is called when we unplug a new idle object.
Remove descriptor from read/write/error lists Remove descriptor from read/write/error lists
''' '''
if self.read_fds.has_key(fd): if fd in self.read_fds:
del(self.read_fds[fd]) del(self.read_fds[fd])
if self.write_fds.has_key(fd): if fd in self.write_fds:
del(self.write_fds[fd]) del(self.write_fds[fd])
if self.error_fds.has_key(fd): if fd in self.error_fds:
del(self.error_fds[fd]) del(self.error_fds[fd])
def process(self): def process(self):

View file

@ -321,7 +321,7 @@ class Protocol(Node):
if not node and xmlns: self.setNamespace(xmlns) if not node and xmlns: self.setNamespace(xmlns)
if self['to']: self.setTo(self['to']) if self['to']: self.setTo(self['to'])
if self['from']: self.setFrom(self['from']) if self['from']: self.setFrom(self['from'])
if node and type(self)==type(node) and self.__class__==node.__class__ and self.attrs.has_key('id'): del self.attrs['id'] if node and type(self)==type(node) and self.__class__==node.__class__ and 'id' in self.attrs: del self.attrs['id']
self.timestamp=None self.timestamp=None
for d in self.getTags('delay',namespace=NS_DELAY2): for d in self.getTags('delay',namespace=NS_DELAY2):
try: try:
@ -598,7 +598,7 @@ class ErrorNode(Node):
""" Create new error node object. """ Create new error node object.
Mandatory parameter: name - name of error condition. Mandatory parameter: name - name of error condition.
Optional parameters: code, typ, text. Used for backwards compartibility with older jabber protocol.""" Optional parameters: code, typ, text. Used for backwards compartibility with older jabber protocol."""
if ERRORS.has_key(name): if name in ERRORS:
cod,type,txt=ERRORS[name] cod,type,txt=ERRORS[name]
ns=name.split()[0] ns=name.split()[0]
else: cod,ns,type,txt='500',NS_STANZAS,'cancel','' else: cod,ns,type,txt='500',NS_STANZAS,'cancel',''

View file

@ -71,15 +71,15 @@ class Roster(PlugIn):
for item in stanza.getTag('query').getTags('item'): for item in stanza.getTag('query').getTags('item'):
jid=item.getAttr('jid') jid=item.getAttr('jid')
if item.getAttr('subscription')=='remove': if item.getAttr('subscription')=='remove':
if self._data.has_key(jid): del self._data[jid] if jid in self._data: del self._data[jid]
return return
self.DEBUG('Setting roster item %s...'%jid,'ok') self.DEBUG('Setting roster item %s...'%jid,'ok')
if not self._data.has_key(jid): self._data[jid]={} if jid not in self._data: self._data[jid]={}
self._data[jid]['name']=item.getAttr('name') self._data[jid]['name']=item.getAttr('name')
self._data[jid]['ask']=item.getAttr('ask') self._data[jid]['ask']=item.getAttr('ask')
self._data[jid]['subscription']=item.getAttr('subscription') self._data[jid]['subscription']=item.getAttr('subscription')
self._data[jid]['groups']=[] self._data[jid]['groups']=[]
if not self._data[jid].has_key('resources'): self._data[jid]['resources']={} if 'resources' not in self._data[jid]: self._data[jid]['resources']={}
for group in item.getTags('group'): self._data[jid]['groups'].append(group.getData()) for group in item.getTags('group'): self._data[jid]['groups'].append(group.getData())
self._data[self._owner.User+'@'+self._owner.Server]={'resources':{},'name':None,'ask':None,'subscription':None,'groups':None,} self._data[self._owner.User+'@'+self._owner.Server]={'resources':{},'name':None,'ask':None,'subscription':None,'groups':None,}
self.set=1 self.set=1
@ -92,7 +92,7 @@ class Roster(PlugIn):
# If no from attribue, it's from server # If no from attribue, it's from server
jid=self._owner.Server jid=self._owner.Server
jid=JID(jid) jid=JID(jid)
if not self._data.has_key(jid.getStripped()): self._data[jid.getStripped()]={'name':None,'ask':None,'subscription':'none','groups':['Not in roster'],'resources':{}} if jid.getStripped() not in self._data: self._data[jid.getStripped()]={'name':None,'ask':None,'subscription':'none','groups':['Not in roster'],'resources':{}}
if type(self._data[jid.getStripped()]['resources'])!=type(dict()): if type(self._data[jid.getStripped()]['resources'])!=type(dict()):
self._data[jid.getStripped()]['resources']={} self._data[jid.getStripped()]['resources']={}
item=self._data[jid.getStripped()] item=self._data[jid.getStripped()]
@ -106,7 +106,7 @@ class Roster(PlugIn):
if pres.getTag('priority'): res['priority']=pres.getPriority() if pres.getTag('priority'): res['priority']=pres.getPriority()
if not pres.getTimestamp(): pres.setTimestamp() if not pres.getTimestamp(): pres.setTimestamp()
res['timestamp']=pres.getTimestamp() res['timestamp']=pres.getTimestamp()
elif typ=='unavailable' and item['resources'].has_key(jid.getResource()): del item['resources'][jid.getResource()] elif typ=='unavailable' and jid.getResource() in item['resources']: del item['resources'][jid.getResource()]
# Need to handle type='error' also # Need to handle type='error' also
def _getItemData(self,jid,dataname): def _getItemData(self,jid,dataname):
@ -117,7 +117,7 @@ class Roster(PlugIn):
""" Return specific jid's resource representation in internal format. Used internally. """ """ Return specific jid's resource representation in internal format. Used internally. """
if jid.find('/')+1: if jid.find('/')+1:
jid,resource=jid.split('/',1) jid,resource=jid.split('/',1)
if self._data[jid]['resources'].has_key(resource): return self._data[jid]['resources'][resource][dataname] if resource in self._data[jid]['resources']: return self._data[jid]['resources'][resource][dataname]
elif self._data[jid]['resources'].keys(): elif self._data[jid]['resources'].keys():
lastpri=-129 lastpri=-129
for r in self._data[jid]['resources'].keys(): for r in self._data[jid]['resources'].keys():
@ -176,7 +176,7 @@ class Roster(PlugIn):
return self._data[item] return self._data[item]
def getItem(self,item): def getItem(self,item):
""" Get the contact in the internal format (or None if JID 'item' is not in roster).""" """ Get the contact in the internal format (or None if JID 'item' is not in roster)."""
if self._data.has_key(item): return self._data[item] if item in self._data: return self._data[item]
def Subscribe(self,jid): def Subscribe(self,jid):
""" Send subscription request to JID 'jid'.""" """ Send subscription request to JID 'jid'."""
self._owner.send(Presence(jid,'subscribe')) self._owner.send(Presence(jid,'subscribe'))

View file

@ -213,10 +213,10 @@ class Session:
def _catch_stream_id(self,ns=None,tag='stream',attrs={}): def _catch_stream_id(self,ns=None,tag='stream',attrs={}):
""" This callback is used to detect the stream namespace of incoming stream. Used internally. """ """ This callback is used to detect the stream namespace of incoming stream. Used internally. """
if not attrs.has_key('id') or not attrs['id']: if 'id' not in attrs or not attrs['id']:
return self.terminate_stream(STREAM_INVALID_XML) return self.terminate_stream(STREAM_INVALID_XML)
self.ID=attrs['id'] self.ID=attrs['id']
if not attrs.has_key('version'): self._owner.Dialback(self) if 'version' not in attrs: self._owner.Dialback(self)
def _stream_open(self,ns=None,tag='stream',attrs={}): def _stream_open(self,ns=None,tag='stream',attrs={}):
""" This callback is used to handle opening stream tag of the incoming stream. """ This callback is used to handle opening stream tag of the incoming stream.
@ -228,23 +228,23 @@ class Session:
text+=' to="%s"'%self.peer text+=' to="%s"'%self.peer
else: else:
text+=' id="%s"'%self.ID text+=' id="%s"'%self.ID
if not attrs.has_key('to'): text+=' from="%s"'%self._owner.servernames[0] if 'to' not in attrs: text+=' from="%s"'%self._owner.servernames[0]
else: text+=' from="%s"'%attrs['to'] else: text+=' from="%s"'%attrs['to']
if attrs.has_key('xml:lang'): text+=' xml:lang="%s"'%attrs['xml:lang'] if 'xml:lang' in attrs: text+=' xml:lang="%s"'%attrs['xml:lang']
if self.xmlns: xmlns=self.xmlns if self.xmlns: xmlns=self.xmlns
else: xmlns=NS_SERVER else: xmlns=NS_SERVER
text+=' xmlns:db="%s" xmlns:stream="%s" xmlns="%s"'%(NS_DIALBACK,NS_STREAMS,xmlns) text+=' xmlns:db="%s" xmlns:stream="%s" xmlns="%s"'%(NS_DIALBACK,NS_STREAMS,xmlns)
if attrs.has_key('version') or self.TYP=='client': text+=' version="1.0"' if 'version' in attrs or self.TYP=='client': text+=' version="1.0"'
self.sendnow(text+'>') self.sendnow(text+'>')
self.set_stream_state(STREAM__OPENED) self.set_stream_state(STREAM__OPENED)
if self.TYP=='client': return if self.TYP=='client': return
if tag<>'stream': return self.terminate_stream(STREAM_INVALID_XML) if tag<>'stream': return self.terminate_stream(STREAM_INVALID_XML)
if ns<>NS_STREAMS: return self.terminate_stream(STREAM_INVALID_NAMESPACE) if ns<>NS_STREAMS: return self.terminate_stream(STREAM_INVALID_NAMESPACE)
if self.Stream.xmlns<>self.xmlns: return self.terminate_stream(STREAM_BAD_NAMESPACE_PREFIX) if self.Stream.xmlns<>self.xmlns: return self.terminate_stream(STREAM_BAD_NAMESPACE_PREFIX)
if not attrs.has_key('to'): return self.terminate_stream(STREAM_IMPROPER_ADDRESSING) if 'to' not in attrs: return self.terminate_stream(STREAM_IMPROPER_ADDRESSING)
if attrs['to'] not in self._owner.servernames: return self.terminate_stream(STREAM_HOST_UNKNOWN) if attrs['to'] not in self._owner.servernames: return self.terminate_stream(STREAM_HOST_UNKNOWN)
self.ourname=attrs['to'].lower() self.ourname=attrs['to'].lower()
if self.TYP=='server' and attrs.has_key('version'): if self.TYP=='server' and 'version' in attrs:
# send features # send features
features=Node('stream:features') features=Node('stream:features')
if NS_TLS in self.waiting_features: if NS_TLS in self.waiting_features:

View file

@ -217,7 +217,7 @@ class Node(object):
if namespace and namespace<>node.getNamespace(): continue if namespace and namespace<>node.getNamespace(): continue
if node.getName() == name: if node.getName() == name:
for key in attrs.keys(): for key in attrs.keys():
if not node.attrs.has_key(key) or node.attrs[key]<>attrs[key]: break if key not in node.attrs or node.attrs[key]<>attrs[key]: break
else: nodes.append(node) else: nodes.append(node)
if one and nodes: return nodes[0] if one and nodes: return nodes[0]
if not one: return nodes if not one: return nodes
@ -228,7 +228,7 @@ class Node(object):
if namespace is not None and namespace!=node.getNamespace(): continue if namespace is not None and namespace!=node.getNamespace(): continue
if node.getName() == name: if node.getName() == name:
for key in attrs.keys(): for key in attrs.keys():
if not node.attrs.has_key(key) or \ if key not in node.attrs or \
node.attrs[key]!=attrs[key]: break node.attrs[key]!=attrs[key]: break
else: else:
yield node yield node
@ -273,7 +273,7 @@ class Node(object):
except: self.addChild(tag,attrs,payload=[ustr(val)]) except: self.addChild(tag,attrs,payload=[ustr(val)])
def has_attr(self,key): def has_attr(self,key):
""" Checks if node have attribute "key".""" """ Checks if node have attribute "key"."""
return self.attrs.has_key(key) return key in self.attrs
def __getitem__(self,item): def __getitem__(self,item):
""" Returns node's attribute "item" value. """ """ Returns node's attribute "item" value. """
return self.getAttr(item) return self.getAttr(item)

View file

@ -194,7 +194,7 @@ class HTTPPROXYsocket(TCPsocket):
'Pragma: no-cache', 'Pragma: no-cache',
'Host: %s:%s'%self._server, 'Host: %s:%s'%self._server,
'User-Agent: HTTPPROXYsocket/v0.1'] 'User-Agent: HTTPPROXYsocket/v0.1']
if self._proxy.has_key('user') and self._proxy.has_key('password'): if 'user' in self._proxy and 'password' in self._proxy:
credentials = '%s:%s'%(self._proxy['user'],self._proxy['password']) credentials = '%s:%s'%(self._proxy['user'],self._proxy['password'])
credentials = base64.encodestring(credentials).strip() credentials = base64.encodestring(credentials).strip()
connector.append('Proxy-Authorization: Basic '+credentials) connector.append('Proxy-Authorization: Basic '+credentials)
@ -231,7 +231,7 @@ class TLS(PlugIn):
If 'now' in false then starts encryption as soon as TLS feature is If 'now' in false then starts encryption as soon as TLS feature is
declared by the server (if it were already declared - it is ok). declared by the server (if it were already declared - it is ok).
""" """
if owner.__dict__.has_key('TLS'): return # Already enabled. if 'TLS' in owner.__dict__: return # Already enabled.
PlugIn.PlugIn(self,owner) PlugIn.PlugIn(self,owner)
DBG_LINE='TLS' DBG_LINE='TLS'
if now: return self._startSSL() if now: return self._startSSL()

View file

@ -676,7 +676,7 @@ class NonBlockingTLS(PlugIn):
If 'now' in false then starts encryption as soon as TLS feature is If 'now' in false then starts encryption as soon as TLS feature is
declared by the server (if it were already declared - it is ok). declared by the server (if it were already declared - it is ok).
''' '''
if owner.__dict__.has_key('NonBlockingTLS'): if 'NonBlockingTLS' in owner.__dict__:
return # Already enabled. return # Already enabled.
PlugIn.PlugIn(self, owner) PlugIn.PlugIn(self, owner)
DBG_LINE='NonBlockingTLS' DBG_LINE='NonBlockingTLS'
@ -704,7 +704,7 @@ class NonBlockingTLS(PlugIn):
''' Unregisters TLS handler's from owner's dispatcher. Take note that encription ''' Unregisters TLS handler's from owner's dispatcher. Take note that encription
can not be stopped once started. You can only break the connection and start over.''' can not be stopped once started. You can only break the connection and start over.'''
# if dispatcher is not plugged we cannot (un)register handlers # if dispatcher is not plugged we cannot (un)register handlers
if self._owner.__dict__.has_key('Dispatcher'): if 'Dispatcher' in self._owner.__dict__:
self._owner.UnregisterHandler('features', self.FeaturesHandler,xmlns=NS_STREAMS) self._owner.UnregisterHandler('features', self.FeaturesHandler,xmlns=NS_STREAMS)
self._owner.Dispatcher.PlugOut() self._owner.Dispatcher.PlugOut()
self._owner = None self._owner = None
@ -906,7 +906,7 @@ class NBHTTPPROXYsocket(NonBlockingTcp):
'Pragma: no-cache', 'Pragma: no-cache',
'Host: %s:%s'%self.server, 'Host: %s:%s'%self.server,
'User-Agent: HTTPPROXYsocket/v0.1'] 'User-Agent: HTTPPROXYsocket/v0.1']
if self.proxy.has_key('user') and self.proxy.has_key('password'): if 'user' in self.proxy and 'password' in self.proxy:
credentials = '%s:%s' % ( self.proxy['user'], self.proxy['password']) credentials = '%s:%s' % ( self.proxy['user'], self.proxy['password'])
credentials = base64.encodestring(credentials).strip() credentials = base64.encodestring(credentials).strip()
connector.append('Proxy-Authorization: Basic '+credentials) connector.append('Proxy-Authorization: Basic '+credentials)
@ -988,7 +988,7 @@ class NBSOCKS5PROXYsocket(NonBlockingTcp):
def _on_tcp_connect(self): def _on_tcp_connect(self):
self.DEBUG('Proxy server contacted, performing authentification', 'start') self.DEBUG('Proxy server contacted, performing authentification', 'start')
if self.proxy.has_key('user') and self.proxy.has_key('password'): if 'user' in self.proxy and 'password' in self.proxy:
to_send = '\x05\x02\x00\x02' to_send = '\x05\x02\x00\x02'
else: else:
to_send = '\x05\x01\x00' to_send = '\x05\x01\x00'

View file

@ -146,7 +146,7 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
file_tag.setAttr('name', file_props['name']) file_tag.setAttr('name', file_props['name'])
file_tag.setAttr('size', file_props['size']) file_tag.setAttr('size', file_props['size'])
desc = file_tag.setTag('desc') desc = file_tag.setTag('desc')
if file_props.has_key('desc'): if 'desc' in file_props:
desc.setData(file_props['desc']) desc.setData(file_props['desc'])
file_tag.setTag('range') file_tag.setTag('range')
feature = si.setTag('feature') feature = si.setTag('feature')
@ -180,11 +180,11 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
host_dict[attr] = item.getAttr(attr) host_dict[attr] = item.getAttr(attr)
streamhosts.append(host_dict) streamhosts.append(host_dict)
if file_props is None: if file_props is None:
if self.files_props.has_key(sid): if sid in self.files_props:
file_props = self.files_props[sid] file_props = self.files_props[sid]
file_props['fast'] = streamhosts file_props['fast'] = streamhosts
if file_props['type'] == 's': if file_props['type'] == 's':
if file_props.has_key('streamhosts'): if 'streamhosts' in file_props:
file_props['streamhosts'].extend(streamhosts) file_props['streamhosts'].extend(streamhosts)
else: else:
file_props['streamhosts'] = streamhosts file_props['streamhosts'] = streamhosts
@ -209,11 +209,11 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
return return
frm = unicode(iq_obj.getFrom()) frm = unicode(iq_obj.getFrom())
id = real_id[3:] id = real_id[3:]
if self.files_props.has_key(id): if id in self.files_props:
file_props = self.files_props[id] file_props = self.files_props[id]
if file_props['streamhost-used']: if file_props['streamhost-used']:
for host in file_props['proxyhosts']: for host in file_props['proxyhosts']:
if host['initiator'] == frm and host.has_key('idx'): if host['initiator'] == frm and 'idx' in host:
gajim.socks5queue.activate_proxy(host['idx']) gajim.socks5queue.activate_proxy(host['idx'])
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
@ -229,7 +229,7 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
except: # this bytestream result is not what we need except: # this bytestream result is not what we need
pass pass
id = real_id[3:] id = real_id[3:]
if self.files_props.has_key(id): if id in self.files_props:
file_props = self.files_props[id] file_props = self.files_props[id]
else: else:
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
@ -237,10 +237,10 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
# proxy approves the activate query # proxy approves the activate query
if real_id[:3] == 'au_': if real_id[:3] == 'au_':
id = real_id[3:] id = real_id[3:]
if not file_props.has_key('streamhost-used') or \ if 'streamhost-used' not in file_props or \
file_props['streamhost-used'] is False: file_props['streamhost-used'] is False:
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
if not file_props.has_key('proxyhosts'): if 'proxyhosts' not in file_props:
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
for host in file_props['proxyhosts']: for host in file_props['proxyhosts']:
if host['initiator'] == frm and \ if host['initiator'] == frm and \
@ -249,7 +249,7 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
break break
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
jid = streamhost.getAttr('jid') jid = streamhost.getAttr('jid')
if file_props.has_key('streamhost-used') and \ if 'streamhost-used' in file_props and \
file_props['streamhost-used'] is True: file_props['streamhost-used'] is True:
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
@ -258,14 +258,14 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
raise common.xmpp.NodeProcessed raise common.xmpp.NodeProcessed
proxy = None proxy = None
if file_props.has_key('proxyhosts'): if 'proxyhosts' in file_props:
for proxyhost in file_props['proxyhosts']: for proxyhost in file_props['proxyhosts']:
if proxyhost['jid'] == jid: if proxyhost['jid'] == jid:
proxy = proxyhost proxy = proxyhost
if proxy != None: if proxy != None:
file_props['streamhost-used'] = True file_props['streamhost-used'] = True
if not file_props.has_key('streamhosts'): if 'streamhosts' not in file_props:
file_props['streamhosts'] = [] file_props['streamhosts'] = []
file_props['streamhosts'].append(proxy) file_props['streamhosts'].append(proxy)
file_props['is_a_proxy'] = True file_props['is_a_proxy'] = True
@ -277,7 +277,7 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
else: else:
gajim.socks5queue.send_file(file_props, self.name) gajim.socks5queue.send_file(file_props, self.name)
if file_props.has_key('fast'): if 'fast' in file_props:
fasts = file_props['fast'] fasts = file_props['fast']
if len(fasts) > 0: if len(fasts) > 0:
self._connect_error(frm, fasts[0]['id'], file_props['sid'], self._connect_error(frm, fasts[0]['id'], file_props['sid'],
@ -289,14 +289,14 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
gajim.log.debug('_siResultCB') gajim.log.debug('_siResultCB')
self.peerhost = con._owner.Connection._sock.getsockname() self.peerhost = con._owner.Connection._sock.getsockname()
id = iq_obj.getAttr('id') id = iq_obj.getAttr('id')
if not self.files_props.has_key(id): if id not in self.files_props:
# no such jid # no such jid
return return
file_props = self.files_props[id] file_props = self.files_props[id]
if file_props is None: if file_props is None:
# file properties for jid is none # file properties for jid is none
return return
if file_props.has_key('request-id'): if 'request-id' in file_props:
# we have already sent streamhosts info # we have already sent streamhosts info
return return
file_props['receiver'] = unicode(iq_obj.getFrom()) file_props['receiver'] = unicode(iq_obj.getFrom())
@ -362,7 +362,7 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
if profile != common.xmpp.NS_FILE: if profile != common.xmpp.NS_FILE:
return return
id = iq_obj.getAttr('id') id = iq_obj.getAttr('id')
if not self.files_props.has_key(id): if id not in self.files_props:
# no such jid # no such jid
return return
file_props = self.files_props[id] file_props = self.files_props[id]

View file

@ -135,7 +135,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
# END __init__ # END __init__
def dispatch(self, event, data): def dispatch(self, event, data):
if gajim.handlers.has_key(event): if event in gajim.handlers:
gajim.handlers[event](self.name, data) gajim.handlers[event](self.name, data)
def _reconnect(self): def _reconnect(self):

View file

@ -44,7 +44,7 @@ class Roster:
old_data = self._data.copy() old_data = self._data.copy()
self.update_roster() self.update_roster()
for key in old_data.keys(): for key in old_data.keys():
if self._data.has_key(key): if key in self._data:
if old_data[key] != self._data[key]: if old_data[key] != self._data[key]:
diffs[key] = self._data[key]['status'] diffs[key] = self._data[key]['status']
#print 'roster_zeroconf.py: diffs:' + str(diffs) #print 'roster_zeroconf.py: diffs:' + str(diffs)
@ -68,16 +68,16 @@ class Roster:
self._data[jid]['host'] = host self._data[jid]['host'] = host
self._data[jid]['port'] = port self._data[jid]['port'] = port
txt_dict = self.zeroconf.txt_array_to_dict(txt) txt_dict = self.zeroconf.txt_array_to_dict(txt)
if txt_dict.has_key('status'): if 'status' in txt_dict:
status = txt_dict['status'] status = txt_dict['status']
else: else:
status = '' status = ''
if not status: if not status:
status = 'avail' status = 'avail'
nm = '' nm = ''
if txt_dict.has_key('1st'): if '1st' in txt_dict:
nm = txt_dict['1st'] nm = txt_dict['1st']
if txt_dict.has_key('last'): if 'last' in txt_dict:
if nm != '': if nm != '':
nm += ' ' nm += ' '
nm += txt_dict['last'] nm += txt_dict['last']
@ -88,19 +88,19 @@ class Roster:
if status == 'avail': if status == 'avail':
status = 'online' status = 'online'
self._data[jid]['txt_dict'] = txt_dict self._data[jid]['txt_dict'] = txt_dict
if not self._data[jid]['txt_dict'].has_key('msg'): if 'msg' not in self._data[jid]['txt_dict']:
self._data[jid]['txt_dict']['msg'] = '' self._data[jid]['txt_dict']['msg'] = ''
self._data[jid]['status'] = status self._data[jid]['status'] = status
self._data[jid]['show'] = status self._data[jid]['show'] = status
def delItem(self, jid): def delItem(self, jid):
#print 'roster_zeroconf.py: delItem %s' % jid #print 'roster_zeroconf.py: delItem %s' % jid
if self._data.has_key(jid): if jid in self._data:
del self._data[jid] del self._data[jid]
def getItem(self, jid): def getItem(self, jid):
#print 'roster_zeroconf.py: getItem: %s' % jid #print 'roster_zeroconf.py: getItem: %s' % jid
if self._data.has_key(jid): if jid in self._data:
return self._data[jid] return self._data[jid]
def __getitem__(self,jid): def __getitem__(self,jid):
@ -128,15 +128,15 @@ class Roster:
return self._data[jid]['groups'] return self._data[jid]['groups']
def getName(self, jid): def getName(self, jid):
if self._data.has_key(jid): if jid in self._data:
return self._data[jid]['name'] return self._data[jid]['name']
def getStatus(self, jid): def getStatus(self, jid):
if self._data.has_key(jid): if jid in self._data:
return self._data[jid]['status'] return self._data[jid]['status']
def getMessage(self, jid): def getMessage(self, jid):
if self._data.has_key(jid): if jid in self._data:
return self._data[jid]['txt_dict']['msg'] return self._data[jid]['txt_dict']['msg']
def getShow(self, jid): def getShow(self, jid):

View file

@ -243,7 +243,7 @@ class Zeroconf:
txt['txtvers'] = 1 txt['txtvers'] = 1
# replace gajim's show messages with compatible ones # replace gajim's show messages with compatible ones
if self.txt.has_key('status'): if 'status' in self.txt:
txt['status'] = self.replace_show(self.txt['status']) txt['status'] = self.replace_show(self.txt['status'])
else: else:
txt['status'] = 'avail' txt['status'] = 'avail'

View file

@ -1122,7 +1122,7 @@ class PreferencesWindow:
helpers.play_sound(snd_event_config_name) helpers.play_sound(snd_event_config_name)
def on_open_advanced_editor_button_clicked(self, widget, data = None): def on_open_advanced_editor_button_clicked(self, widget, data = None):
if gajim.interface.instances.has_key('advanced_config'): if 'advanced_config' in gajim.interface.instances:
gajim.interface.instances['advanced_config'].window.present() gajim.interface.instances['advanced_config'].window.present()
else: else:
gajim.interface.instances['advanced_config'] = \ gajim.interface.instances['advanced_config'] = \
@ -1165,7 +1165,7 @@ class ManageProxiesWindow:
self.xml.get_widget('proxytype_combobox').set_active(0) self.xml.get_widget('proxytype_combobox').set_active(0)
def on_manage_proxies_window_destroy(self, widget): def on_manage_proxies_window_destroy(self, widget):
if gajim.interface.instances.has_key('accounts'): if 'accounts' in gajim.interface.instances:
gajim.interface.instances['accounts'].\ gajim.interface.instances['accounts'].\
update_proxy_list() update_proxy_list()
del gajim.interface.instances['manage_proxies'] del gajim.interface.instances['manage_proxies']
@ -1376,7 +1376,7 @@ class AccountsWindow:
def check_resend_relog(self): def check_resend_relog(self):
if self.need_relogin and self.current_account == gajim.ZEROCONF_ACC_NAME: if self.need_relogin and self.current_account == gajim.ZEROCONF_ACC_NAME:
if gajim.connections.has_key(gajim.ZEROCONF_ACC_NAME): if gajim.ZEROCONF_ACC_NAME in gajim.connections:
gajim.connections[gajim.ZEROCONF_ACC_NAME].update_details() gajim.connections[gajim.ZEROCONF_ACC_NAME].update_details()
return return
@ -1524,7 +1524,7 @@ class AccountsWindow:
# Personal tab # Personal tab
gpg_key_label = self.xml.get_widget('gpg_key_label2') gpg_key_label = self.xml.get_widget('gpg_key_label2')
if gajim.connections.has_key(gajim.ZEROCONF_ACC_NAME) and \ if gajim.ZEROCONF_ACC_NAME in gajim.connections and \
gajim.connections[gajim.ZEROCONF_ACC_NAME].gpg: gajim.connections[gajim.ZEROCONF_ACC_NAME].gpg:
self.xml.get_widget('gpg_choose_button2').set_sensitive(True) self.xml.get_widget('gpg_choose_button2').set_sensitive(True)
self.init_account_gpg() self.init_account_gpg()
@ -1651,7 +1651,7 @@ class AccountsWindow:
def on_add_button_clicked(self, widget): def on_add_button_clicked(self, widget):
'''When add button is clicked: open an account information window''' '''When add button is clicked: open an account information window'''
if gajim.interface.instances.has_key('account_creation_wizard'): if 'account_creation_wizard' in gajim.interface.instances:
gajim.interface.instances['account_creation_wizard'].window.present() gajim.interface.instances['account_creation_wizard'].window.present()
else: else:
gajim.interface.instances['account_creation_wizard'] = \ gajim.interface.instances['account_creation_wizard'] = \
@ -1683,7 +1683,7 @@ class AccountsWindow:
break break
# Detect if we have opened windows for this account # Detect if we have opened windows for this account
def remove(account): def remove(account):
if gajim.interface.instances[account].has_key('remove_account'): if 'remove_account' in gajim.interface.instances[account]:
gajim.interface.instances[account]['remove_account'].window.\ gajim.interface.instances[account]['remove_account'].window.\
present() present()
else: else:
@ -1972,7 +1972,7 @@ class AccountsWindow:
gajim.config.set_per('accounts', self.current_account, 'proxy', proxy) gajim.config.set_per('accounts', self.current_account, 'proxy', proxy)
def on_manage_proxies_button1_clicked(self, widget): def on_manage_proxies_button1_clicked(self, widget):
if gajim.interface.instances.has_key('manage_proxies'): if 'manage_proxies' in gajim.interface.instances:
gajim.interface.instances['manage_proxies'].window.present() gajim.interface.instances['manage_proxies'].window.present()
else: else:
gajim.interface.instances['manage_proxies'] = ManageProxiesWindow() gajim.interface.instances['manage_proxies'] = ManageProxiesWindow()
@ -2026,7 +2026,7 @@ class AccountsWindow:
custom_port) custom_port)
def on_gpg_choose_button_clicked(self, widget, data = None): def on_gpg_choose_button_clicked(self, widget, data = None):
if gajim.connections.has_key(self.current_account) and \ if self.current_account in gajim.connections and \
gajim.connections[self.current_account].gpg: gajim.connections[self.current_account].gpg:
secret_keys = gajim.connections[self.current_account].\ secret_keys = gajim.connections[self.current_account].\
ask_gpg_secrete_keys() ask_gpg_secrete_keys()
@ -2085,14 +2085,14 @@ class AccountsWindow:
self.on_checkbutton_toggled(widget, 'use_gpg_agent') self.on_checkbutton_toggled(widget, 'use_gpg_agent')
def on_edit_details_button1_clicked(self, widget): def on_edit_details_button1_clicked(self, widget):
if not gajim.interface.instances.has_key(self.current_account): if self.current_account not in gajim.interface.instances:
dialogs.ErrorDialog(_('No such account available'), dialogs.ErrorDialog(_('No such account available'),
_('You must create your account before editing your personal ' _('You must create your account before editing your personal '
'information.')) 'information.'))
return return
# show error dialog if account is newly created (not in gajim.connections) # show error dialog if account is newly created (not in gajim.connections)
if not gajim.connections.has_key(self.current_account) or \ if self.current_account not in gajim.connections or \
gajim.connections[self.current_account].connected < 2: gajim.connections[self.current_account].connected < 2:
dialogs.ErrorDialog(_('You are not connected to the server'), dialogs.ErrorDialog(_('You are not connected to the server'),
_('Without a connection, you can not edit your personal information.')) _('Without a connection, you can not edit your personal information.'))
@ -2128,7 +2128,7 @@ class AccountsWindow:
def on_enable_zeroconf_checkbutton2_toggled(self, widget): def on_enable_zeroconf_checkbutton2_toggled(self, widget):
# don't do anything if there is an account with the local name but is a # don't do anything if there is an account with the local name but is a
# normal account # normal account
if gajim.connections.has_key(gajim.ZEROCONF_ACC_NAME) and not \ if gajim.ZEROCONF_ACC_NAME in gajim.connections and not \
gajim.connections[gajim.ZEROCONF_ACC_NAME].is_zeroconf: gajim.connections[gajim.ZEROCONF_ACC_NAME].is_zeroconf:
gajim.connections[gajim.ZEROCONF_ACC_NAME].dispatch('ERROR', gajim.connections[gajim.ZEROCONF_ACC_NAME].dispatch('ERROR',
(_('Account Local already exists.'), (_('Account Local already exists.'),
@ -2264,7 +2264,7 @@ class FakeDataForm(gtk.Table, object):
def _draw_table(self): def _draw_table(self):
'''Draw the table''' '''Draw the table'''
nbrow = 0 nbrow = 0
if self.infos.has_key('instructions'): if 'instructions' in self.infos:
nbrow = 1 nbrow = 1
self.resize(rows = nbrow, columns = 2) self.resize(rows = nbrow, columns = 2)
label = gtk.Label(self.infos['instructions']) label = gtk.Label(self.infos['instructions'])
@ -2314,7 +2314,7 @@ class ServiceRegistrationWindow:
table = self.xml.get_widget('table') table = self.xml.get_widget('table')
table.attach(self.data_form_widget, 0, 2, 0, 1) table.attach(self.data_form_widget, 0, 2, 0, 1)
else: else:
if infos.has_key('registered'): if 'registered' in infos:
self.window.set_title(_('Edit %s') % service) self.window.set_title(_('Edit %s') % service)
else: else:
self.window.set_title(_('Register to %s') % service) self.window.set_title(_('Register to %s') % service)
@ -2336,9 +2336,9 @@ class ServiceRegistrationWindow:
form, True) # True is for is_form form, True) # True is for is_form
else: else:
infos = self.data_form_widget.get_infos() infos = self.data_form_widget.get_infos()
if infos.has_key('instructions'): if 'instructions' in infos:
del infos['instructions'] del infos['instructions']
if infos.has_key('registered'): if 'registered' in infos:
del infos['registered'] del infos['registered']
gajim.connections[self.account].register_agent(self.service, infos) gajim.connections[self.account].register_agent(self.service, infos)
@ -2500,13 +2500,13 @@ class GroupchatConfigWindow:
tv = self.affiliation_treeview[affiliation] tv = self.affiliation_treeview[affiliation]
model = tv.get_model() model = tv.get_model()
reason = '' reason = ''
if users_dict[jid].has_key('reason'): if 'reason' in users_dict[jid]:
reason = users_dict[jid]['reason'] reason = users_dict[jid]['reason']
nick = '' nick = ''
if users_dict[jid].has_key('nick'): if 'nick' in users_dict[jid]:
nick = users_dict[jid]['nick'] nick = users_dict[jid]['nick']
role = '' role = ''
if users_dict[jid].has_key('role'): if 'role' in users_dict[jid]:
role = users_dict[jid]['role'] role = users_dict[jid]['role']
model.append((jid, reason, nick, role)) model.append((jid, reason, nick, role))
@ -2527,8 +2527,8 @@ class GroupchatConfigWindow:
jid = model[iter][0].decode('utf-8') jid = model[iter][0].decode('utf-8')
actual_jid_list.append(jid) actual_jid_list.append(jid)
if jid not in self.start_users_dict[affiliation] or \ if jid not in self.start_users_dict[affiliation] or \
(affiliation == 'outcast' and self.start_users_dict[affiliation]\ (affiliation == 'outcast' and 'reason' in self.start_users_dict[affiliation]\
[jid].has_key('reason') and self.start_users_dict[affiliation][jid]\ [jid] and self.start_users_dict[affiliation][jid]\
['reason'] != model[iter][1].decode('utf-8')): ['reason'] != model[iter][1].decode('utf-8')):
users_dict[jid] = {'affiliation': affiliation} users_dict[jid] = {'affiliation': affiliation}
if affiliation == 'outcast': if affiliation == 'outcast':
@ -2549,7 +2549,7 @@ class RemoveAccountWindow:
and do removing of the account given''' and do removing of the account given'''
def on_remove_account_window_destroy(self, widget): def on_remove_account_window_destroy(self, widget):
if gajim.interface.instances.has_key(self.account): if self.account in gajim.interface.instances:
del gajim.interface.instances[self.account]['remove_account'] del gajim.interface.instances[self.account]['remove_account']
def on_cancel_button_clicked(self, widget): def on_cancel_button_clicked(self, widget):
@ -2635,7 +2635,7 @@ class RemoveAccountWindow:
gajim.interface.roster.regroup = False gajim.interface.roster.regroup = False
gajim.interface.roster.setup_and_draw_roster() gajim.interface.roster.setup_and_draw_roster()
gajim.interface.roster.set_actions_menu_needs_rebuild() gajim.interface.roster.set_actions_menu_needs_rebuild()
if gajim.interface.instances.has_key('accounts'): if 'accounts' in gajim.interface.instances:
gajim.interface.instances['accounts'].init_accounts() gajim.interface.instances['accounts'].init_accounts()
self.window.destroy() self.window.destroy()
@ -3231,7 +3231,7 @@ class AccountCreationWizardWindow:
proxies_combobox.set_active(0) proxies_combobox.set_active(0)
def on_manage_proxies_button_clicked(self, widget): def on_manage_proxies_button_clicked(self, widget):
if gajim.interface.instances.has_key('manage_proxies'): if 'manage_proxies' in gajim.interface.instances:
gajim.interface.instances['manage_proxies'].window.present() gajim.interface.instances['manage_proxies'].window.present()
else: else:
gajim.interface.instances['manage_proxies'] = \ gajim.interface.instances['manage_proxies'] = \
@ -3341,7 +3341,7 @@ class AccountCreationWizardWindow:
gobject.source_remove(self.update_progressbar_timeout_id) gobject.source_remove(self.update_progressbar_timeout_id)
def on_advanced_button_clicked(self, widget): def on_advanced_button_clicked(self, widget):
if gajim.interface.instances.has_key('accounts'): if 'accounts' in gajim.interface.instances:
gajim.interface.instances['accounts'].window.present() gajim.interface.instances['accounts'].window.present()
else: else:
gajim.interface.instances['accounts'] = AccountsWindow() gajim.interface.instances['accounts'] = AccountsWindow()
@ -3462,7 +3462,7 @@ class AccountCreationWizardWindow:
gajim.gajim_optional_features[self.account] = [] gajim.gajim_optional_features[self.account] = []
gajim.caps_hash[self.account] = '' gajim.caps_hash[self.account] = ''
# refresh accounts window # refresh accounts window
if gajim.interface.instances.has_key('accounts'): if 'accounts' in gajim.interface.instances:
gajim.interface.instances['accounts'].init_accounts() gajim.interface.instances['accounts'].init_accounts()
# refresh roster # refresh roster
if len(gajim.connections) >= 2: # Do not merge accounts if only one exists if len(gajim.connections) >= 2: # Do not merge accounts if only one exists

View file

@ -409,7 +409,7 @@ class ConversationTextview:
self.smooth_scroll_timer.cancel() self.smooth_scroll_timer.cancel()
def show_xep0184_warning(self, id): def show_xep0184_warning(self, id):
if self.xep0184_marks.has_key(id): if id in self.xep0184_marks:
return return
buffer = self.tv.get_buffer() buffer = self.tv.get_buffer()
@ -444,7 +444,7 @@ class ConversationTextview:
buffer.end_user_action() buffer.end_user_action()
def hide_xep0184_warning(self, id): def hide_xep0184_warning(self, id):
if not self.xep0184_marks.has_key(id): if id not in self.xep0184_marks:
return return
if self.xep0184_shown[id] == NOT_SHOWN: if self.xep0184_shown[id] == NOT_SHOWN:

View file

@ -392,8 +392,7 @@ class ChangeActivityDialog:
if 'activity' in con.activity \ if 'activity' in con.activity \
and con.activity['activity'] in pep.ACTIVITIES: and con.activity['activity'] in pep.ACTIVITIES:
if 'subactivity' in con.activity \ if 'subactivity' in con.activity \
and pep.ACTIVITIES[con.activity['activity']].has_key( and con.activity['subactivity'] in pep.ACTIVITIES[con.activity['activity']]:
con.activity['subactivity']):
subactivity = con.activity['subactivity'] subactivity = con.activity['subactivity']
else: else:
subactivity = 'other' subactivity = 'other'
@ -691,7 +690,7 @@ class AddNewContactWindow:
location = gajim.interface.instances[self.account] location = gajim.interface.instances[self.account]
else: else:
location = gajim.interface.instances location = gajim.interface.instances
if location.has_key('add_contact'): if 'add_contact' in location:
location['add_contact'].window.present() location['add_contact'].window.present()
# An instance is already opened # An instance is already opened
return return
@ -721,7 +720,7 @@ _('Please fill in the data of the contact you want to add in account %s') %accou
type_ = gajim.get_transport_name_from_jid(j, False) type_ = gajim.get_transport_name_from_jid(j, False)
if not type_: if not type_:
continue continue
if self.agents.has_key(type_): if type_ in self.agents:
self.agents[type_].append(j) self.agents[type_].append(j)
else: else:
self.agents[type_] = [j] self.agents[type_] = [j]
@ -757,7 +756,7 @@ _('Please fill in the data of the contact you want to add in account %s') %accou
continue continue
imgs = gajim.interface.roster.transports_state_images imgs = gajim.interface.roster.transports_state_images
img = None img = None
if imgs['16'].has_key(type_) and imgs['16'][type_].has_key('online'): if type_ in imgs['16'] and 'online' in imgs['16'][type_]:
img = imgs['16'][type_]['online'] img = imgs['16'][type_]['online']
if type_ in uf_type: if type_ in uf_type:
liststore.append([uf_type[type_], img.get_pixbuf(), type_]) liststore.append([uf_type[type_], img.get_pixbuf(), type_])
@ -1620,7 +1619,7 @@ class SubscriptionRequestWindow:
def on_contact_info_activate(self, widget): def on_contact_info_activate(self, widget):
'''ask vcard''' '''ask vcard'''
if gajim.interface.instances[self.account]['infos'].has_key(self.jid): if self.jid in gajim.interface.instances[self.account]['infos']:
gajim.interface.instances[self.account]['infos'][self.jid].window.present() gajim.interface.instances[self.account]['infos'][self.jid].window.present()
else: else:
contact = gajim.contacts.create_contact(jid=self.jid, name='', contact = gajim.contacts.create_contact(jid=self.jid, name='',
@ -1963,7 +1962,7 @@ class NewChatDialog(InputDialog):
_('Please make sure you are connected with "%s".') % self.account) _('Please make sure you are connected with "%s".') % self.account)
return return
if self.completion_dict.has_key(jid): if jid in self.completion_dict:
jid = self.completion_dict[jid].jid jid = self.completion_dict[jid].jid
else: else:
try: try:
@ -2343,7 +2342,7 @@ class SingleMessageWindow:
sender_list = [self.to_entry.get_text().decode('utf-8')] sender_list = [self.to_entry.get_text().decode('utf-8')]
for to_whom_jid in sender_list: for to_whom_jid in sender_list:
if self.completion_dict.has_key(to_whom_jid): if to_whom_jid in self.completion_dict:
to_whom_jid = self.completion_dict[to_whom_jid].jid to_whom_jid = self.completion_dict[to_whom_jid].jid
subject = self.subject_entry.get_text().decode('utf-8') subject = self.subject_entry.get_text().decode('utf-8')
@ -2608,7 +2607,7 @@ class PrivacyListWindow:
self.list_of_rules_combobox.get_model().clear() self.list_of_rules_combobox.get_model().clear()
self.global_rules = {} self.global_rules = {}
for rule in rules: for rule in rules:
if rule.has_key('type'): if 'type' in rule:
text_item = _('Order: %(order)s, action: %(action)s, type: %(type)s' text_item = _('Order: %(order)s, action: %(action)s, type: %(type)s'
', value: %(value)s') % {'order': rule['order'], ', value: %(value)s') % {'order': rule['order'],
'action': rule['action'], 'type': rule['type'], 'action': rule['action'], 'type': rule['type'],
@ -2666,13 +2665,13 @@ class PrivacyListWindow:
if self.active_rule != '': if self.active_rule != '':
rule_info = self.global_rules[self.active_rule] rule_info = self.global_rules[self.active_rule]
self.edit_order_spinbutton.set_value(int(rule_info['order'])) self.edit_order_spinbutton.set_value(int(rule_info['order']))
if rule_info.has_key('type'): if 'type' in rule_info:
if rule_info['type'] == 'jid': if rule_info['type'] == 'jid':
self.edit_type_jabberid_radiobutton.set_active(True) self.edit_type_jabberid_radiobutton.set_active(True)
self.edit_type_jabberid_entry.set_text(rule_info['value']) self.edit_type_jabberid_entry.set_text(rule_info['value'])
elif rule_info['type'] == 'group': elif rule_info['type'] == 'group':
self.edit_type_group_radiobutton.set_active(True) self.edit_type_group_radiobutton.set_active(True)
if self.list_of_groups.has_key(rule_info['value']): if rule_info['value'] in self.list_of_groups:
self.edit_type_group_combobox.set_active( self.edit_type_group_combobox.set_active(
self.list_of_groups[rule_info['value']]) self.list_of_groups[rule_info['value']])
else: else:
@ -2915,7 +2914,7 @@ class PrivacyListsWindow:
_('You must enter a name to create a privacy list.')) _('You must enter a name to create a privacy list.'))
return return
key_name = 'privacy_list_%s' % name key_name = 'privacy_list_%s' % name
if gajim.interface.instances[self.account].has_key(key_name): if key_name in gajim.interface.instances[self.account]:
gajim.interface.instances[self.account][key_name].window.present() gajim.interface.instances[self.account][key_name].window.present()
else: else:
gajim.interface.instances[self.account][key_name] = \ gajim.interface.instances[self.account][key_name] = \
@ -2929,8 +2928,7 @@ class PrivacyListsWindow:
name = self.privacy_lists_save[ name = self.privacy_lists_save[
self.list_of_privacy_lists_combobox.get_active()] self.list_of_privacy_lists_combobox.get_active()]
key_name = 'privacy_list_%s' % name key_name = 'privacy_list_%s' % name
if gajim.interface.instances[self.account].has_key( if key_name in gajim.interface.instances[self.account]:
key_name):
gajim.interface.instances[self.account][key_name].window.present() gajim.interface.instances[self.account][key_name].window.present()
else: else:
gajim.interface.instances[self.account][key_name] = \ gajim.interface.instances[self.account][key_name] = \

View file

@ -318,7 +318,7 @@ class ServicesCache:
'''Get info for an agent.''' '''Get info for an agent.'''
addr = get_agent_address(jid, node) addr = get_agent_address(jid, node)
# Check the cache # Check the cache
if self._info.has_key(addr): if addr in self._info:
args = self._info[addr] + args args = self._info[addr] + args
cb(jid, node, *args) cb(jid, node, *args)
return return
@ -330,7 +330,7 @@ class ServicesCache:
cb = Closure(cb, userargs = args, remove = self._clean_closure, cb = Closure(cb, userargs = args, remove = self._clean_closure,
removeargs = cbkey) removeargs = cbkey)
# Are we already fetching this? # Are we already fetching this?
if self._cbs.has_key(cbkey): if cbkey in self._cbs:
self._cbs[cbkey].append(cb) self._cbs[cbkey].append(cb)
else: else:
self._cbs[cbkey] = [cb] self._cbs[cbkey] = [cb]
@ -340,7 +340,7 @@ class ServicesCache:
'''Get a list of items in an agent.''' '''Get a list of items in an agent.'''
addr = get_agent_address(jid, node) addr = get_agent_address(jid, node)
# Check the cache # Check the cache
if self._items.has_key(addr): if addr in self._items:
args = (self._items[addr],) + args args = (self._items[addr],) + args
cb(jid, node, *args) cb(jid, node, *args)
return return
@ -352,7 +352,7 @@ class ServicesCache:
cb = Closure(cb, userargs = args, remove = self._clean_closure, cb = Closure(cb, userargs = args, remove = self._clean_closure,
removeargs = cbkey) removeargs = cbkey)
# Are we already fetching this? # Are we already fetching this?
if self._cbs.has_key(cbkey): if cbkey in self._cbs:
self._cbs[cbkey].append(cb) self._cbs[cbkey].append(cb)
else: else:
self._cbs[cbkey] = [cb] self._cbs[cbkey] = [cb]
@ -367,11 +367,11 @@ class ServicesCache:
# Call callbacks # Call callbacks
cbkey = ('info', addr) cbkey = ('info', addr)
if self._cbs.has_key(cbkey): if cbkey in self._cbs:
for cb in self._cbs[cbkey]: for cb in self._cbs[cbkey]:
cb(jid, node, identities, features, data) cb(jid, node, identities, features, data)
# clean_closure may have beaten us to it # clean_closure may have beaten us to it
if self._cbs.has_key(cbkey): if cbkey in self._cbs:
del self._cbs[cbkey] del self._cbs[cbkey]
def agent_items(self, jid, node, items): def agent_items(self, jid, node, items):
@ -383,11 +383,11 @@ class ServicesCache:
# Call callbacks # Call callbacks
cbkey = ('items', addr) cbkey = ('items', addr)
if self._cbs.has_key(cbkey): if cbkey in self._cbs:
for cb in self._cbs[cbkey]: for cb in self._cbs[cbkey]:
cb(jid, node, items) cb(jid, node, items)
# clean_closure may have beaten us to it # clean_closure may have beaten us to it
if self._cbs.has_key(cbkey): if cbkey in self._cbs:
del self._cbs[cbkey] del self._cbs[cbkey]
def agent_info_error(self, jid): def agent_info_error(self, jid):
@ -397,11 +397,11 @@ class ServicesCache:
# Call callbacks # Call callbacks
cbkey = ('info', addr) cbkey = ('info', addr)
if self._cbs.has_key(cbkey): if cbkey in self._cbs:
for cb in self._cbs[cbkey]: for cb in self._cbs[cbkey]:
cb(jid, '', 0, 0, 0) cb(jid, '', 0, 0, 0)
# clean_closure may have beaten us to it # clean_closure may have beaten us to it
if self._cbs.has_key(cbkey): if cbkey in self._cbs:
del self._cbs[cbkey] del self._cbs[cbkey]
def agent_items_error(self, jid): def agent_items_error(self, jid):
@ -411,11 +411,11 @@ class ServicesCache:
# Call callbacks # Call callbacks
cbkey = ('items', addr) cbkey = ('items', addr)
if self._cbs.has_key(cbkey): if cbkey in self._cbs:
for cb in self._cbs[cbkey]: for cb in self._cbs[cbkey]:
cb(jid, '', 0) cb(jid, '', 0)
# clean_closure may have beaten us to it # clean_closure may have beaten us to it
if self._cbs.has_key(cbkey): if cbkey in self._cbs:
del self._cbs[cbkey] del self._cbs[cbkey]
# object is needed so that @property works # object is needed so that @property works
@ -636,7 +636,7 @@ _('Without a connection, you can not browse available services'))
# Update the window list # Update the window list
if self.jid: if self.jid:
old_addr = get_agent_address(self.jid, self.node) old_addr = get_agent_address(self.jid, self.node)
if gajim.interface.instances[self.account]['disco'].has_key(old_addr): if old_addr in gajim.interface.instances[self.account]['disco']:
del gajim.interface.instances[self.account]['disco'][old_addr] del gajim.interface.instances[self.account]['disco'][old_addr]
addr = get_agent_address(jid, node) addr = get_agent_address(jid, node)
gajim.interface.instances[self.account]['disco'][addr] = self gajim.interface.instances[self.account]['disco'][addr] = self
@ -810,7 +810,7 @@ class AgentBrowser:
def _set_title(self, jid, node, identities, features, data): def _set_title(self, jid, node, identities, features, data):
'''Set the window title based on agent info.''' '''Set the window title based on agent info.'''
# Set the banner and window title # Set the banner and window title
if identities[0].has_key('name'): if 'name' in identities[0]:
name = identities[0]['name'] name = identities[0]['name']
self.window._set_window_banner_text(self._get_agent_address(), name) self.window._set_window_banner_text(self._get_agent_address(), name)
@ -992,7 +992,7 @@ _('This service does not contain any items to browse.'))
def _update_item(self, iter, jid, node, item): def _update_item(self, iter, jid, node, item):
'''Called when an item should be updated in the model. The result of a '''Called when an item should be updated in the model. The result of a
disco#items query. (seldom)''' disco#items query. (seldom)'''
if item.has_key('name'): if 'name' in item:
self.model[iter][2] = item['name'] self.model[iter][2] = item['name']
def _update_info(self, iter, jid, node, identities, features, data): def _update_info(self, iter, jid, node, identities, features, data):
@ -1238,7 +1238,7 @@ class ToplevelAgentBrowser(AgentBrowser):
if not iter: if not iter:
return return
service = model[iter][0].decode('utf-8') service = model[iter][0].decode('utf-8')
if gajim.interface.instances[self.account]['search'].has_key(service): if service in gajim.interface.instances[self.account]['search']:
gajim.interface.instances[self.account]['search'][service].present() gajim.interface.instances[self.account]['search'][service].present()
else: else:
gajim.interface.instances[self.account]['search'][service] = \ gajim.interface.instances[self.account]['search'][service] = \
@ -1283,7 +1283,7 @@ class ToplevelAgentBrowser(AgentBrowser):
if not iter: if not iter:
return return
service = model[iter][0].decode('utf-8') service = model[iter][0].decode('utf-8')
if not gajim.interface.instances[self.account].has_key('join_gc'): if 'join_gc' not in gajim.interface.instances[self.account]:
try: try:
dialogs.JoinGroupchatWindow(self.account, service) dialogs.JoinGroupchatWindow(self.account, service)
except GajimGeneralException: except GajimGeneralException:
@ -1459,7 +1459,7 @@ class ToplevelAgentBrowser(AgentBrowser):
def _add_item(self, jid, node, item, force): def _add_item(self, jid, node, item, force):
# Row text # Row text
addr = get_agent_address(jid, node) addr = get_agent_address(jid, node)
if item.has_key('name'): if 'name' in item:
descr = "<b>%s</b>\n%s" % (item['name'], addr) descr = "<b>%s</b>\n%s" % (item['name'], addr)
else: else:
descr = "<b>%s</b>" % addr descr = "<b>%s</b>" % addr
@ -1488,7 +1488,7 @@ class ToplevelAgentBrowser(AgentBrowser):
def _update_item(self, iter, jid, node, item): def _update_item(self, iter, jid, node, item):
addr = get_agent_address(jid, node) addr = get_agent_address(jid, node)
if item.has_key('name'): if 'name' in item:
descr = "<b>%s</b>\n%s" % (item['name'], addr) descr = "<b>%s</b>\n%s" % (item['name'], addr)
else: else:
descr = "<b>%s</b>" % addr descr = "<b>%s</b>" % addr

View file

@ -148,7 +148,7 @@ class FileTransfersWindow:
''' show a dialog saying that file (file_props) has been transferred''' ''' show a dialog saying that file (file_props) has been transferred'''
def on_open(widget, file_props): def on_open(widget, file_props):
dialog.destroy() dialog.destroy()
if not file_props.has_key('file-name'): if 'file-name' not in file_props:
return return
(path, file) = os.path.split(file_props['file-name']) (path, file) = os.path.split(file_props['file-name'])
if os.path.exists(path) and os.path.isdir(path): if os.path.exists(path) and os.path.isdir(path):
@ -296,15 +296,15 @@ _('Connection with peer cannot be established.'))
def show_file_request(self, account, contact, file_props): def show_file_request(self, account, contact, file_props):
''' show dialog asking for comfirmation and store location of new ''' show dialog asking for comfirmation and store location of new
file requested by a contact''' file requested by a contact'''
if file_props is None or not file_props.has_key('name'): if file_props is None or 'name' not in file_props:
return return
sec_text = '\t' + _('File: %s') % file_props['name'] sec_text = '\t' + _('File: %s') % file_props['name']
if file_props.has_key('size'): if 'size' in file_props:
sec_text += '\n\t' + _('Size: %s') % \ sec_text += '\n\t' + _('Size: %s') % \
helpers.convert_bytes(file_props['size']) helpers.convert_bytes(file_props['size'])
if file_props.has_key('mime-type'): if 'mime-type' in file_props:
sec_text += '\n\t' + _('Type: %s') % file_props['mime-type'] sec_text += '\n\t' + _('Type: %s') % file_props['mime-type']
if file_props.has_key('desc'): if 'desc' in file_props:
sec_text += '\n\t' + _('Description: %s') % file_props['desc'] sec_text += '\n\t' + _('Description: %s') % file_props['desc']
prim_text = _('%s wants to send you a file:') % contact.jid prim_text = _('%s wants to send you a file:') % contact.jid
dialog, dialog2 = None, None dialog, dialog2 = None, None
@ -460,10 +460,10 @@ _('Connection with peer cannot be established.'))
def _remove_transfer(self, iter, sid, file_props): def _remove_transfer(self, iter, sid, file_props):
self.model.remove(iter) self.model.remove(iter)
if file_props.has_key('tt_account'): if 'tt_account' in file_props:
# file transfer is set # file transfer is set
account = file_props['tt_account'] account = file_props['tt_account']
if gajim.connections.has_key(account): if account in gajim.connections:
# there is a connection to the account # there is a connection to the account
gajim.connections[account].remove_transfer(file_props) gajim.connections[account].remove_transfer(file_props)
if file_props['type'] == 'r': # we receive a file if file_props['type'] == 'r': # we receive a file
@ -486,7 +486,7 @@ _('Connection with peer cannot be established.'))
def set_progress(self, typ, sid, transfered_size, iter = None): def set_progress(self, typ, sid, transfered_size, iter = None):
''' change the progress of a transfer with new transfered size''' ''' change the progress of a transfer with new transfered size'''
if not self.files_props[typ].has_key(sid): if sid not in self.files_props[typ]:
return return
file_props = self.files_props[typ][sid] file_props = self.files_props[typ][sid]
full_size = int(file_props['size']) full_size = int(file_props['size'])
@ -509,7 +509,7 @@ _('Connection with peer cannot be established.'))
# Kb/s # Kb/s
# remaining time # remaining time
if file_props.has_key('offset') and file_props['offset']: if 'offset' in file_props and file_props['offset']:
transfered_size -= file_props['offset'] transfered_size -= file_props['offset']
full_size -= file_props['offset'] full_size -= file_props['offset']
@ -536,11 +536,11 @@ _('Connection with peer cannot be established.'))
status = 'download' status = 'download'
else: else:
status = 'upload' status = 'upload'
if file_props.has_key('paused') and file_props['paused'] == True: if 'paused' in file_props and file_props['paused'] == True:
status = 'pause' status = 'pause'
elif file_props.has_key('stalled') and file_props['stalled'] == True: elif 'stalled' in file_props and file_props['stalled'] == True:
status = 'waiting' status = 'waiting'
if file_props.has_key('connected') and file_props['connected'] == False: if 'connected' in file_props and file_props['connected'] == False:
status = 'stop' status = 'stop'
self.model.set(iter, 0, self.images[status]) self.model.set(iter, 0, self.images[status])
if transfered_size == full_size: if transfered_size == full_size:
@ -608,7 +608,7 @@ _('Connection with peer cannot be established.'))
self.model.set(iter, 1, text_labels, 2, text_props, C_SID, self.model.set(iter, 1, text_labels, 2, text_props, C_SID,
file_props['type'] + file_props['sid']) file_props['type'] + file_props['sid'])
self.set_progress(file_props['type'], file_props['sid'], 0, iter) self.set_progress(file_props['type'], file_props['sid'], 0, iter)
if file_props.has_key('started') and file_props['started'] is False: if 'started' in file_props and file_props['started'] is False:
status = 'waiting' status = 'waiting'
elif file_props['type'] == 'r': elif file_props['type'] == 'r':
status = 'download' status = 'download'
@ -660,33 +660,33 @@ _('Connection with peer cannot be established.'))
self.on_open_folder_menuitem_activate(widget) self.on_open_folder_menuitem_activate(widget)
def is_transfer_paused(self, file_props): def is_transfer_paused(self, file_props):
if file_props.has_key('stopped') and file_props['stopped']: if 'stopped' in file_props and file_props['stopped']:
return False return False
if file_props.has_key('completed') and file_props['completed']: if 'completed' in file_props and file_props['completed']:
return False return False
if not file_props.has_key('disconnect_cb'): if 'disconnect_cb' not in file_props:
return False return False
return file_props['paused'] return file_props['paused']
def is_transfer_active(self, file_props): def is_transfer_active(self, file_props):
if file_props.has_key('stopped') and file_props['stopped']: if 'stopped' in file_props and file_props['stopped']:
return False return False
if file_props.has_key('completed') and file_props['completed']: if 'completed' in file_props and file_props['completed']:
return False return False
if not file_props.has_key('started') or not file_props['started']: if 'started' not in file_props or not file_props['started']:
return False return False
if not file_props.has_key('paused'): if 'paused' not in file_props:
return True return True
return not file_props['paused'] return not file_props['paused']
def is_transfer_stopped(self, file_props): def is_transfer_stopped(self, file_props):
if file_props.has_key('error') and file_props['error'] != 0: if 'error' in file_props and file_props['error'] != 0:
return True return True
if file_props.has_key('completed') and file_props['completed']: if 'completed' in file_props and file_props['completed']:
return True return True
if file_props.has_key('connected') and file_props['connected'] == False: if 'connected' in file_props and file_props['connected'] == False:
return True return True
if not file_props.has_key('stopped') or not file_props['stopped']: if 'stopped' not in file_props or not file_props['stopped']:
return False return False
return True return True
@ -831,10 +831,10 @@ _('Connection with peer cannot be established.'))
s_iter = selected[1] s_iter = selected[1]
sid = self.model[s_iter][C_SID].decode('utf-8') sid = self.model[s_iter][C_SID].decode('utf-8')
file_props = self.files_props[sid[0]][sid[1:]] file_props = self.files_props[sid[0]][sid[1:]]
if not file_props.has_key('tt_account'): if 'tt_account' not in file_props:
return return
account = file_props['tt_account'] account = file_props['tt_account']
if not gajim.connections.has_key(account): if account not in gajim.connections:
return return
gajim.connections[account].disconnect_transfer(file_props) gajim.connections[account].disconnect_transfer(file_props)
self.set_status(file_props['type'], file_props['sid'], 'stop') self.set_status(file_props['type'], file_props['sid'], 'stop')
@ -941,7 +941,7 @@ _('Connection with peer cannot be established.'))
s_iter = selected[1] s_iter = selected[1]
sid = self.model[s_iter][C_SID].decode('utf-8') sid = self.model[s_iter][C_SID].decode('utf-8')
file_props = self.files_props[sid[0]][sid[1:]] file_props = self.files_props[sid[0]][sid[1:]]
if not file_props.has_key('file-name'): if 'file-name' not in file_props:
return return
(path, file) = os.path.split(file_props['file-name']) (path, file) = os.path.split(file_props['file-name'])
if os.path.exists(path) and os.path.isdir(path): if os.path.exists(path) and os.path.isdir(path):

View file

@ -585,7 +585,7 @@ class Interface:
sid = id sid = id
if len(id) > 3 and id[2] == '_': if len(id) > 3 and id[2] == '_':
sid = id[3:] sid = id[3:]
if ft.files_props['s'].has_key(sid): if sid in ft.files_props['s']:
file_props = ft.files_props['s'][sid] file_props = ft.files_props['s'][sid]
file_props['error'] = -4 file_props['error'] = -4
self.handle_event_file_request_error(account, self.handle_event_file_request_error(account,
@ -598,7 +598,7 @@ class Interface:
sid = id sid = id
if len(id) > 3 and id[2] == '_': if len(id) > 3 and id[2] == '_':
sid = id[3:] sid = id[3:]
if conn.files_props.has_key(sid): if sid in conn.files_props:
file_props = conn.files_props[sid] file_props = conn.files_props[sid]
self.handle_event_file_send_error(account, self.handle_event_file_send_error(account,
(jid_from, file_props)) (jid_from, file_props))
@ -644,7 +644,7 @@ class Interface:
# Inform all controls for this account of the connection state change # Inform all controls for this account of the connection state change
ctrls = self.msg_win_mgr.get_controls() ctrls = self.msg_win_mgr.get_controls()
if self.minimized_controls.has_key(account): if account in self.minimized_controls:
# Can not be the case when we remove account # Can not be the case when we remove account
ctrls += self.minimized_controls[account].values() ctrls += self.minimized_controls[account].values()
for ctrl in ctrls: for ctrl in ctrls:
@ -667,7 +667,7 @@ class Interface:
def edit_own_details(self, account): def edit_own_details(self, account):
jid = gajim.get_jid_from_account(account) jid = gajim.get_jid_from_account(account)
if not self.instances[account].has_key('profile'): if 'profile' not in self.instances[account]:
self.instances[account]['profile'] = \ self.instances[account]['profile'] = \
profile_window.ProfileWindow(account) profile_window.ProfileWindow(account)
gajim.connections[account].request_vcard(jid) gajim.connections[account].request_vcard(jid)
@ -811,7 +811,7 @@ class Interface:
self.unblock_signed_in_notifications, account_ji) self.unblock_signed_in_notifications, account_ji)
locations = (self.instances, self.instances[account]) locations = (self.instances, self.instances[account])
for location in locations: for location in locations:
if location.has_key('add_contact'): if 'add_contact' in location:
if old_show == 0 and new_show > 1: if old_show == 0 and new_show > 1:
location['add_contact'].transport_signed_in(jid) location['add_contact'].transport_signed_in(jid)
break break
@ -1042,7 +1042,7 @@ class Interface:
def handle_event_register_agent_info(self, account, array): def handle_event_register_agent_info(self, account, array):
# ('REGISTER_AGENT_INFO', account, (agent, infos, is_form)) # ('REGISTER_AGENT_INFO', account, (agent, infos, is_form))
# info in a dataform if is_form is True # info in a dataform if is_form is True
if array[2] or array[1].has_key('instructions'): if array[2] or 'instructions' in array[1]:
config.ServiceRegistrationWindow(array[0], array[1], account, config.ServiceRegistrationWindow(array[0], array[1], account,
array[2]) array[2])
else: else:
@ -1052,7 +1052,7 @@ class Interface:
def handle_event_agent_info_items(self, account, array): def handle_event_agent_info_items(self, account, array):
#('AGENT_INFO_ITEMS', account, (agent, node, items)) #('AGENT_INFO_ITEMS', account, (agent, node, items))
our_jid = gajim.get_jid_from_account(account) our_jid = gajim.get_jid_from_account(account)
if gajim.interface.instances[account].has_key('pep_services') and \ if 'pep_services' in gajim.interface.instances[account] and \
array[0] == our_jid: array[0] == our_jid:
gajim.interface.instances[account]['pep_services'].items_received( gajim.interface.instances[account]['pep_services'].items_received(
array[2]) array[2])
@ -1073,18 +1073,18 @@ class Interface:
def handle_event_new_acc_connected(self, account, array): def handle_event_new_acc_connected(self, account, array):
#('NEW_ACC_CONNECTED', account, (infos, is_form, ssl_msg, ssl_err, #('NEW_ACC_CONNECTED', account, (infos, is_form, ssl_msg, ssl_err,
# ssl_cert, ssl_fingerprint)) # ssl_cert, ssl_fingerprint))
if self.instances.has_key('account_creation_wizard'): if 'account_creation_wizard' in self.instances:
self.instances['account_creation_wizard'].new_acc_connected(array[0], self.instances['account_creation_wizard'].new_acc_connected(array[0],
array[1], array[2], array[3], array[4], array[5]) array[1], array[2], array[3], array[4], array[5])
def handle_event_new_acc_not_connected(self, account, array): def handle_event_new_acc_not_connected(self, account, array):
#('NEW_ACC_NOT_CONNECTED', account, (reason)) #('NEW_ACC_NOT_CONNECTED', account, (reason))
if self.instances.has_key('account_creation_wizard'): if 'account_creation_wizard' in self.instances:
self.instances['account_creation_wizard'].new_acc_not_connected(array) self.instances['account_creation_wizard'].new_acc_not_connected(array)
def handle_event_acc_ok(self, account, array): def handle_event_acc_ok(self, account, array):
#('ACC_OK', account, (config)) #('ACC_OK', account, (config))
if self.instances.has_key('account_creation_wizard'): if 'account_creation_wizard' in self.instances:
self.instances['account_creation_wizard'].acc_is_ok(array) self.instances['account_creation_wizard'].acc_is_ok(array)
if self.remote_ctrl: if self.remote_ctrl:
@ -1092,7 +1092,7 @@ class Interface:
def handle_event_acc_not_ok(self, account, array): def handle_event_acc_not_ok(self, account, array):
#('ACC_NOT_OK', account, (reason)) #('ACC_NOT_OK', account, (reason))
if self.instances.has_key('account_creation_wizard'): if 'account_creation_wizard' in self.instances:
self.instances['account_creation_wizard'].acc_is_not_ok(array) self.instances['account_creation_wizard'].acc_is_not_ok(array)
def handle_event_quit(self, p1, p2): def handle_event_quit(self, p1, p2):
@ -1100,17 +1100,17 @@ class Interface:
def handle_event_myvcard(self, account, array): def handle_event_myvcard(self, account, array):
nick = '' nick = ''
if array.has_key('NICKNAME') and array['NICKNAME']: if 'NICKNAME' in array and array['NICKNAME']:
gajim.nicks[account] = array['NICKNAME'] gajim.nicks[account] = array['NICKNAME']
elif array.has_key('FN') and array['FN']: elif 'FN' in array and array['FN']:
gajim.nicks[account] = array['FN'] gajim.nicks[account] = array['FN']
if self.instances[account].has_key('profile'): if 'profile' in self.instances[account]:
win = self.instances[account]['profile'] win = self.instances[account]['profile']
win.set_values(array) win.set_values(array)
if account in self.show_vcard_when_connect: if account in self.show_vcard_when_connect:
self.show_vcard_when_connect.remove(account) self.show_vcard_when_connect.remove(account)
jid = array['jid'] jid = array['jid']
if self.instances[account]['infos'].has_key(jid): if jid in self.instances[account]['infos']:
self.instances[account]['infos'][jid].set_values(array) self.instances[account]['infos'][jid].set_values(array)
def handle_event_vcard(self, account, vcard): def handle_event_vcard(self, account, vcard):
@ -1118,16 +1118,16 @@ class Interface:
'''vcard holds the vcard data''' '''vcard holds the vcard data'''
jid = vcard['jid'] jid = vcard['jid']
resource = '' resource = ''
if vcard.has_key('resource'): if 'resource' in vcard:
resource = vcard['resource'] resource = vcard['resource']
fjid = jid + '/' + str(resource) fjid = jid + '/' + str(resource)
# vcard window # vcard window
win = None win = None
if self.instances[account]['infos'].has_key(jid): if jid in self.instances[account]['infos']:
win = self.instances[account]['infos'][jid] win = self.instances[account]['infos'][jid]
elif resource and self.instances[account]['infos'].has_key(fjid): elif resource and fjid in self.instances[account]['infos']:
win = self.instances[account]['infos'][fjid] win = self.instances[account]['infos'][fjid]
if win: if win:
win.set_values(vcard) win.set_values(vcard)
@ -1163,9 +1163,9 @@ class Interface:
# Ann error occured # Ann error occured
return return
win = None win = None
if self.instances[account]['infos'].has_key(array[0]): if array[0] in self.instances[account]['infos']:
win = self.instances[account]['infos'][array[0]] win = self.instances[account]['infos'][array[0]]
elif self.instances[account]['infos'].has_key(array[0] + '/' + array[1]): elif array[0] + '/' + array[1] in self.instances[account]['infos']:
win = self.instances[account]['infos'][array[0] + '/' + array[1]] win = self.instances[account]['infos'][array[0] + '/' + array[1]]
if win: if win:
c = gajim.contacts.get_contact(account, array[0], array[1]) c = gajim.contacts.get_contact(account, array[0], array[1])
@ -1180,9 +1180,9 @@ class Interface:
def handle_event_os_info(self, account, array): def handle_event_os_info(self, account, array):
#'OS_INFO' (account, (jid, resource, client_info, os_info)) #'OS_INFO' (account, (jid, resource, client_info, os_info))
win = None win = None
if self.instances[account]['infos'].has_key(array[0]): if array[0] in self.instances[account]['infos']:
win = self.instances[account]['infos'][array[0]] win = self.instances[account]['infos'][array[0]]
elif self.instances[account]['infos'].has_key(array[0] + '/' + array[1]): elif array[0] + '/' + array[1] in self.instances[account]['infos']:
win = self.instances[account]['infos'][array[0] + '/' + array[1]] win = self.instances[account]['infos'][array[0] + '/' + array[1]]
if win: if win:
win.set_os_info(array[1], array[2], array[3]) win.set_os_info(array[1], array[2], array[3])
@ -1320,7 +1320,7 @@ class Interface:
#('GC_CONFIG', account, (jid, form)) config is a dict #('GC_CONFIG', account, (jid, form)) config is a dict
room_jid = array[0].split('/')[0] room_jid = array[0].split('/')[0]
if room_jid in gajim.automatic_rooms[account]: if room_jid in gajim.automatic_rooms[account]:
if gajim.automatic_rooms[account][room_jid].has_key('continue_tag'): if 'continue_tag' in gajim.automatic_rooms[account][room_jid]:
# We're converting chat to muc. allow participants to invite # We're converting chat to muc. allow participants to invite
form = dataforms.ExtendForm(node = array[1]) form = dataforms.ExtendForm(node = array[1])
for f in form.iter_fields(): for f in form.iter_fields():
@ -1339,14 +1339,14 @@ class Interface:
# invite contacts # invite contacts
# check if it is necessary to add <continue /> # check if it is necessary to add <continue />
continue_tag = False continue_tag = False
if gajim.automatic_rooms[account][room_jid].has_key('continue_tag'): if 'continue_tag' in gajim.automatic_rooms[account][room_jid]:
continue_tag = True continue_tag = True
if gajim.automatic_rooms[account][room_jid].has_key('invities'): if 'invities' in gajim.automatic_rooms[account][room_jid]:
for jid in gajim.automatic_rooms[account][room_jid]['invities']: for jid in gajim.automatic_rooms[account][room_jid]['invities']:
gajim.connections[account].send_invite(room_jid, jid, gajim.connections[account].send_invite(room_jid, jid,
continue_tag=continue_tag) continue_tag=continue_tag)
del gajim.automatic_rooms[account][room_jid] del gajim.automatic_rooms[account][room_jid]
elif not self.instances[account]['gc_config'].has_key(room_jid): elif room_jid not in self.instances[account]['gc_config']:
self.instances[account]['gc_config'][room_jid] = \ self.instances[account]['gc_config'][room_jid] = \
config.GroupchatConfigWindow(account, room_jid, array[1]) config.GroupchatConfigWindow(account, room_jid, array[1])
@ -1397,7 +1397,7 @@ class Interface:
def handle_event_gc_affiliation(self, account, array): def handle_event_gc_affiliation(self, account, array):
#('GC_AFFILIATION', account, (room_jid, users_dict)) #('GC_AFFILIATION', account, (room_jid, users_dict))
room_jid = array[0] room_jid = array[0]
if self.instances[account]['gc_config'].has_key(room_jid): if room_jid in self.instances[account]['gc_config']:
self.instances[account]['gc_config'][room_jid].\ self.instances[account]['gc_config'][room_jid].\
affiliation_list_received(array[1]) affiliation_list_received(array[1])
@ -1445,7 +1445,7 @@ class Interface:
event_type, room_jid) event_type, room_jid)
def forget_gpg_passphrase(self, keyid): def forget_gpg_passphrase(self, keyid):
if self.gpg_passphrase.has_key(keyid): if keyid in self.gpg_passphrase:
del self.gpg_passphrase[keyid] del self.gpg_passphrase[keyid]
return False return False
@ -1670,8 +1670,8 @@ class Interface:
file_props['received-len']) file_props['received-len'])
else: else:
ft.set_status(file_props['type'], file_props['sid'], 'stop') ft.set_status(file_props['type'], file_props['sid'], 'stop')
if file_props.has_key('stalled') and file_props['stalled'] or \ if 'stalled' in file_props and file_props['stalled'] or \
file_props.has_key('paused') and file_props['paused']: 'paused' in file_props and file_props['paused']:
return return
if file_props['type'] == 'r': # we receive a file if file_props['type'] == 'r': # we receive a file
jid = unicode(file_props['sender']) jid = unicode(file_props['sender'])
@ -1752,19 +1752,19 @@ class Interface:
title = event_type, text = txt) title = event_type, text = txt)
def handle_event_stanza_arrived(self, account, stanza): def handle_event_stanza_arrived(self, account, stanza):
if not self.instances.has_key(account): if account not in self.instances:
return return
if self.instances[account].has_key('xml_console'): if 'xml_console' in self.instances[account]:
self.instances[account]['xml_console'].print_stanza(stanza, 'incoming') self.instances[account]['xml_console'].print_stanza(stanza, 'incoming')
def handle_event_stanza_sent(self, account, stanza): def handle_event_stanza_sent(self, account, stanza):
if not self.instances.has_key(account): if account not in self.instances:
return return
if self.instances[account].has_key('xml_console'): if 'xml_console' in self.instances[account]:
self.instances[account]['xml_console'].print_stanza(stanza, 'outgoing') self.instances[account]['xml_console'].print_stanza(stanza, 'outgoing')
def handle_event_vcard_published(self, account, array): def handle_event_vcard_published(self, account, array):
if self.instances[account].has_key('profile'): if 'profile' in self.instances[account]:
win = self.instances[account]['profile'] win = self.instances[account]['profile']
win.vcard_published() win.vcard_published()
for gc_control in self.msg_win_mgr.get_controls(message_control.TYPE_GC) + \ for gc_control in self.msg_win_mgr.get_controls(message_control.TYPE_GC) + \
@ -1776,7 +1776,7 @@ class Interface:
gc_control.room_jid, show, status) gc_control.room_jid, show, status)
def handle_event_vcard_not_published(self, account, array): def handle_event_vcard_not_published(self, account, array):
if self.instances[account].has_key('profile'): if 'profile' in self.instances[account]:
win = self.instances[account]['profile'] win = self.instances[account]['profile']
win.vcard_not_published() win.vcard_not_published()
@ -1802,12 +1802,12 @@ class Interface:
if account != gc_control.account: if account != gc_control.account:
continue continue
room_jid = gc_control.room_jid room_jid = gc_control.room_jid
if gajim.gc_connected[account].has_key(room_jid) and\ if room_jid in gajim.gc_connected[account] and\
gajim.gc_connected[account][room_jid]: gajim.gc_connected[account][room_jid]:
continue continue
nick = gc_control.nick nick = gc_control.nick
password = '' password = ''
if gajim.gc_passwords.has_key(room_jid): if room_jid in gajim.gc_passwords:
password = gajim.gc_passwords[room_jid] password = gajim.gc_passwords[room_jid]
gajim.connections[account].join_gc(nick, room_jid, password) gajim.connections[account].join_gc(nick, room_jid, password)
@ -1840,18 +1840,18 @@ class Interface:
def handle_event_privacy_lists_received(self, account, data): def handle_event_privacy_lists_received(self, account, data):
# ('PRIVACY_LISTS_RECEIVED', account, list) # ('PRIVACY_LISTS_RECEIVED', account, list)
if not self.instances.has_key(account): if account not in self.instances:
return return
if self.instances[account].has_key('privacy_lists'): if 'privacy_lists' in self.instances[account]:
self.instances[account]['privacy_lists'].privacy_lists_received(data) self.instances[account]['privacy_lists'].privacy_lists_received(data)
def handle_event_privacy_list_received(self, account, data): def handle_event_privacy_list_received(self, account, data):
# ('PRIVACY_LISTS_RECEIVED', account, (name, rules)) # ('PRIVACY_LISTS_RECEIVED', account, (name, rules))
if not self.instances.has_key(account): if account not in self.instances:
return return
name = data[0] name = data[0]
rules = data[1] rules = data[1]
if self.instances[account].has_key('privacy_list_%s' % name): if 'privacy_list_%s' % name in self.instances[account]:
self.instances[account]['privacy_list_%s' % name].\ self.instances[account]['privacy_list_%s' % name].\
privacy_list_received(rules) privacy_list_received(rules)
if name == 'block': if name == 'block':
@ -1870,7 +1870,7 @@ class Interface:
# self.global_rules.append(rule) # self.global_rules.append(rule)
#else: #else:
# self.global_rules_to_append.append(rule) # self.global_rules_to_append.append(rule)
if self.instances[account].has_key('blocked_contacts'): if 'blocked_contacts' in self.instances[account]:
self.instances[account]['blocked_contacts'].\ self.instances[account]['blocked_contacts'].\
privacy_list_received(rules) privacy_list_received(rules)
@ -1884,9 +1884,9 @@ class Interface:
def handle_event_privacy_list_removed(self, account, name): def handle_event_privacy_list_removed(self, account, name):
# ('PRIVACY_LISTS_REMOVED', account, name) # ('PRIVACY_LISTS_REMOVED', account, name)
if not self.instances.has_key(account): if account not in self.instances:
return return
if self.instances[account].has_key('privacy_lists'): if 'privacy_lists' in self.instances[account]:
self.instances[account]['privacy_lists'].privacy_list_removed(name) self.instances[account]['privacy_lists'].privacy_list_removed(name)
def handle_event_zc_name_conflict(self, account, data): def handle_event_zc_name_conflict(self, account, data):
@ -1939,14 +1939,14 @@ class Interface:
def handle_event_search_form(self, account, data): def handle_event_search_form(self, account, data):
# ('SEARCH_FORM', account, (jid, dataform, is_dataform)) # ('SEARCH_FORM', account, (jid, dataform, is_dataform))
if not self.instances[account]['search'].has_key(data[0]): if data[0] not in self.instances[account]['search']:
return return
self.instances[account]['search'][data[0]].on_form_arrived(data[1], self.instances[account]['search'][data[0]].on_form_arrived(data[1],
data[2]) data[2])
def handle_event_search_result(self, account, data): def handle_event_search_result(self, account, data):
# ('SEARCH_RESULT', account, (jid, dataform, is_dataform)) # ('SEARCH_RESULT', account, (jid, dataform, is_dataform))
if not self.instances[account]['search'].has_key(data[0]): if data[0] not in self.instances[account]['search']:
return return
self.instances[account]['search'][data[0]].on_result_arrived(data[1], self.instances[account]['search'][data[0]].on_result_arrived(data[1],
data[2]) data[2])
@ -1966,7 +1966,7 @@ class Interface:
def handle_event_pep_config(self, account, data): def handle_event_pep_config(self, account, data):
# ('PEP_CONFIG', account, (node, form)) # ('PEP_CONFIG', account, (node, form))
if self.instances[account].has_key('pep_services'): if 'pep_services' in self.instances[account]:
self.instances[account]['pep_services'].config(data[0], data[1]) self.instances[account]['pep_services'].config(data[0], data[1])
def handle_event_unique_room_id_supported(self, account, data): def handle_event_unique_room_id_supported(self, account, data):
@ -2099,7 +2099,7 @@ class Interface:
def handle_event_pubsub_node_removed(self, account, data): def handle_event_pubsub_node_removed(self, account, data):
# ('PUBSUB_NODE_REMOVED', account, (jid, node)) # ('PUBSUB_NODE_REMOVED', account, (jid, node))
if self.instances[account].has_key('pep_services'): if 'pep_services' in self.instances[account]:
if data[0] == gajim.get_jid_from_account(account): if data[0] == gajim.get_jid_from_account(account):
self.instances[account]['pep_services'].node_removed(data[1]) self.instances[account]['pep_services'].node_removed(data[1])
@ -2776,7 +2776,7 @@ class Interface:
return False # stop looping in vain return False # stop looping in vain
state = self.sleeper.getState() state = self.sleeper.getState()
for account in gajim.connections: for account in gajim.connections:
if not gajim.sleeper_state.has_key(account) or \ if account not in gajim.sleeper_state or \
not gajim.sleeper_state[account]: not gajim.sleeper_state[account]:
continue continue
if state == common.sleepy.STATE_AWAKE and \ if state == common.sleepy.STATE_AWAKE and \
@ -3194,7 +3194,7 @@ class Interface:
# Don't go auto away if user disabled the option # Don't go auto away if user disabled the option
return return
for account in gajim.connections: for account in gajim.connections:
if not gajim.sleeper_state.has_key(account) or \ if account not in gajim.sleeper_state or \
not gajim.sleeper_state[account]: not gajim.sleeper_state[account]:
continue continue
if gajim.sleeper_state[account] == 'online': if gajim.sleeper_state[account] == 'online':

View file

@ -81,7 +81,7 @@ class GajimThemesWindow:
return True # do NOT destroy the window return True # do NOT destroy the window
def on_close_button_clicked(self, widget): def on_close_button_clicked(self, widget):
if gajim.interface.instances.has_key('preferences'): if 'preferences' in gajim.interface.instances:
gajim.interface.instances['preferences'].update_theme_list() gajim.interface.instances['preferences'].update_theme_list()
self.window.hide() self.window.hide()

View file

@ -120,7 +120,7 @@ class PrivateChatControl(ChatControl):
def __init__(self, parent_win, gc_contact, contact, account, session): def __init__(self, parent_win, gc_contact, contact, account, session):
room_jid = contact.jid.split('/')[0] room_jid = contact.jid.split('/')[0]
room_ctrl = gajim.interface.msg_win_mgr.get_gc_control(room_jid, account) room_ctrl = gajim.interface.msg_win_mgr.get_gc_control(room_jid, account)
if gajim.interface.minimized_controls[account].has_key(room_jid): if room_jid in gajim.interface.minimized_controls[account]:
room_ctrl = gajim.interface.minimized_controls[account][room_jid] room_ctrl = gajim.interface.minimized_controls[account][room_jid]
self.room_name = room_ctrl.name self.room_name = room_ctrl.name
self.gc_contact = gc_contact self.gc_contact = gc_contact
@ -555,12 +555,12 @@ class GroupchatControl(ChatControlBase):
def _update_banner_state_image(self): def _update_banner_state_image(self):
banner_status_img = self.xml.get_widget('gc_banner_status_image') banner_status_img = self.xml.get_widget('gc_banner_status_image')
images = gajim.interface.jabber_state_images images = gajim.interface.jabber_state_images
if gajim.gc_connected[self.account].has_key(self.room_jid) and \ if self.room_jid in gajim.gc_connected[self.account] and \
gajim.gc_connected[self.account][self.room_jid]: gajim.gc_connected[self.account][self.room_jid]:
image = 'muc_active' image = 'muc_active'
else: else:
image = 'muc_inactive' image = 'muc_inactive'
if images.has_key('32') and images['32'].has_key(image): if '32' in images and image in images['32']:
muc_icon = images['32'][image] muc_icon = images['32'][image]
if muc_icon.get_storage_type() != gtk.IMAGE_EMPTY: if muc_icon.get_storage_type() != gtk.IMAGE_EMPTY:
pix = muc_icon.get_pixbuf() pix = muc_icon.get_pixbuf()
@ -800,7 +800,7 @@ class GroupchatControl(ChatControlBase):
if kind == 'incoming': # it's a message NOT from us if kind == 'incoming': # it's a message NOT from us
# highlighting and sounds # highlighting and sounds
(highlight, sound) = self.highlighting_for_message(text, tim) (highlight, sound) = self.highlighting_for_message(text, tim)
if self.gc_custom_colors.has_key(contact): if contact in self.gc_custom_colors:
other_tags_for_name.append('gc_nickname_color_' + \ other_tags_for_name.append('gc_nickname_color_' + \
str(self.gc_custom_colors[contact])) str(self.gc_custom_colors[contact]))
else: else:
@ -1231,15 +1231,15 @@ class GroupchatControl(ChatControlBase):
real_jid += '/' + gc_c.resource real_jid += '/' + gc_c.resource
else: else:
real_jid = fake_jid real_jid = fake_jid
if con.vcard_shas.has_key(fake_jid): if fake_jid in con.vcard_shas:
if avatar_sha != con.vcard_shas[fake_jid]: if avatar_sha != con.vcard_shas[fake_jid]:
server = gajim.get_server_from_jid(self.room_jid) server = gajim.get_server_from_jid(self.room_jid)
if not server.startswith('irc'): if not server.startswith('irc'):
con.request_vcard(real_jid, fake_jid) con.request_vcard(real_jid, fake_jid)
else: else:
cached_vcard = con.get_cached_vcard(fake_jid, True) cached_vcard = con.get_cached_vcard(fake_jid, True)
if cached_vcard and cached_vcard.has_key('PHOTO') and \ if cached_vcard and 'PHOTO' in cached_vcard and \
cached_vcard['PHOTO'].has_key('SHA'): 'SHA' in cached_vcard['PHOTO']:
cached_sha = cached_vcard['PHOTO']['SHA'] cached_sha = cached_vcard['PHOTO']['SHA']
else: else:
cached_sha = '' cached_sha = ''
@ -1518,7 +1518,7 @@ class GroupchatControl(ChatControlBase):
else: else:
nick = '' nick = ''
# join_gc window is needed in order to provide for password entry. # join_gc window is needed in order to provide for password entry.
if gajim.interface.instances[self.account].has_key('join_gc'): if 'join_gc' in gajim.interface.instances[self.account]:
gajim.interface.instances[self.account]['join_gc'].\ gajim.interface.instances[self.account]['join_gc'].\
window.present() window.present()
else: else:
@ -1866,8 +1866,7 @@ class GroupchatControl(ChatControlBase):
if c.affiliation == 'owner': if c.affiliation == 'owner':
gajim.connections[self.account].request_gc_config(self.room_jid) gajim.connections[self.account].request_gc_config(self.room_jid)
elif c.affiliation == 'admin': elif c.affiliation == 'admin':
if not gajim.interface.instances[self.account]['gc_config'].has_key( if self.room_jid not in gajim.interface.instances[self.account]['gc_config']:
self.room_jid):
gajim.interface.instances[self.account]['gc_config'][self.room_jid]\ gajim.interface.instances[self.account]['gc_config'][self.room_jid]\
= config.GroupchatConfigWindow(self.account, self.room_jid) = config.GroupchatConfigWindow(self.account, self.room_jid)
@ -1893,7 +1892,7 @@ class GroupchatControl(ChatControlBase):
def _on_bookmark_room_menuitem_activate(self, widget): def _on_bookmark_room_menuitem_activate(self, widget):
'''bookmark the room, without autojoin and not minimized''' '''bookmark the room, without autojoin and not minimized'''
password = '' password = ''
if gajim.gc_passwords.has_key(self.room_jid): if self.room_jid in gajim.gc_passwords:
password = gajim.gc_passwords[self.room_jid] password = gajim.gc_passwords[self.room_jid]
gajim.interface.add_gc_bookmark(self.account, self.name, self.room_jid, \ gajim.interface.add_gc_bookmark(self.account, self.name, self.room_jid, \
'0', '0', password, self.nick) '0', '0', password, self.nick)
@ -2399,7 +2398,7 @@ class GroupchatControl(ChatControlBase):
'''Call vcard_information_window class to display user's information''' '''Call vcard_information_window class to display user's information'''
c = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick) c = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick)
c2 = gajim.contacts.contact_from_gc_contact(c) c2 = gajim.contacts.contact_from_gc_contact(c)
if gajim.interface.instances[self.account]['infos'].has_key(c2.jid): if c2.jid in gajim.interface.instances[self.account]['infos']:
gajim.interface.instances[self.account]['infos'][c2.jid].window.\ gajim.interface.instances[self.account]['infos'][c2.jid].window.\
present() present()
else: else:

View file

@ -587,7 +587,7 @@ def get_avatar_pixbuf_from_cache(fjid, is_fake_jid = False, use_local = True):
is_fake_jid) is_fake_jid)
if not vcard_dict: # This can happen if cached vcard is too old if not vcard_dict: # This can happen if cached vcard is too old
return 'ask' return 'ask'
if not vcard_dict.has_key('PHOTO'): if 'PHOTO' not in vcard_dict:
return None return None
pixbuf = vcard.get_avatar_pixbuf_encoded_mime(vcard_dict['PHOTO'])[0] pixbuf = vcard.get_avatar_pixbuf_encoded_mime(vcard_dict['PHOTO'])[0]
return pixbuf return pixbuf

View file

@ -234,7 +234,7 @@ class HistoryWindow:
def _load_history(self, jid_or_name, account = None): def _load_history(self, jid_or_name, account = None):
'''Load history for the given jid/name and show it''' '''Load history for the given jid/name and show it'''
if jid_or_name and self.completion_dict.has_key(jid_or_name): if jid_or_name and jid_or_name in self.completion_dict:
# a full qualified jid or a contact name was entered # a full qualified jid or a contact name was entered
info_jid, info_account, info_name, info_completion = self.completion_dict[jid_or_name] info_jid, info_account, info_name, info_completion = self.completion_dict[jid_or_name]
self.jids_to_search = [info_jid] self.jids_to_search = [info_jid]

View file

@ -155,7 +155,7 @@ class MessageWindow(object):
gtk.gdk.ACTION_MOVE) gtk.gdk.ACTION_MOVE)
def change_account_name(self, old_name, new_name): def change_account_name(self, old_name, new_name):
if self._controls.has_key(old_name): if old_name in self._controls:
self._controls[new_name] = self._controls[old_name] self._controls[new_name] = self._controls[old_name]
del self._controls[old_name] del self._controls[old_name]
@ -235,7 +235,7 @@ class MessageWindow(object):
def new_tab(self, control): def new_tab(self, control):
fjid = control.get_full_jid() fjid = control.get_full_jid()
if not self._controls.has_key(control.account): if control.account not in self._controls:
self._controls[control.account] = {} self._controls[control.account] = {}
self._controls[control.account][fjid] = control self._controls[control.account][fjid] = control

View file

@ -103,22 +103,22 @@ class MusicTrackListener(gobject.GObject):
def _mpris_properties_extract(self, song): def _mpris_properties_extract(self, song):
info = MusicTrackInfo() info = MusicTrackInfo()
if song.has_key('title'): if 'title' in song:
info.title = song['title'] info.title = song['title']
else: else:
info.title = '' info.title = ''
if song.has_key('album'): if 'album' in song:
info.album = song['album'] info.album = song['album']
else: else:
info.album = '' info.album = ''
if song.has_key('artist'): if 'artist' in song:
info.artist = song['artist'] info.artist = song['artist']
else: else:
info.artist = '' info.artist = ''
if song.has_key('length'): if 'length' in song:
info.duration = int(song['length']) info.duration = int(song['length'])
else: else:
info.duration = 0 info.duration = 0

View file

@ -402,7 +402,7 @@ class NotificationResponseManager:
def on_action_invoked(self, id, reason): def on_action_invoked(self, id, reason):
self.received.append((id, time.time(), reason)) self.received.append((id, time.time(), reason))
if self.pending.has_key(id): if id in self.pending:
notification = self.pending[id] notification = self.pending[id]
notification.on_action_invoked(id, reason) notification.on_action_invoked(id, reason)
del self.pending[id] del self.pending[id]
@ -414,7 +414,7 @@ class NotificationResponseManager:
self.received.remove(rec) self.received.remove(rec)
def on_closed(self, id, reason=None): def on_closed(self, id, reason=None):
if self.pending.has_key(id): if id in self.pending:
del self.pending[id] del self.pending[id]
def add_pending(self, id, object): def add_pending(self, id, object):

View file

@ -70,11 +70,11 @@ class netgrowl:
self.socket.sendto(data, (self.hostname, GROWL_UDP_PORT)) self.socket.sendto(data, (self.hostname, GROWL_UDP_PORT))
def PostNotification(self, userInfo): def PostNotification(self, userInfo):
if userInfo.has_key(GROWL_NOTIFICATION_PRIORITY): if GROWL_NOTIFICATION_PRIORITY in userInfo:
priority = userInfo[GROWL_NOTIFICATION_PRIORITY] priority = userInfo[GROWL_NOTIFICATION_PRIORITY]
else: else:
priority = 0 priority = 0
if userInfo.has_key(GROWL_NOTIFICATION_STICKY): if GROWL_NOTIFICATION_STICKY in userInfo:
sticky = userInfo[GROWL_NOTIFICATION_STICKY] sticky = userInfo[GROWL_NOTIFICATION_STICKY]
else: else:
priority = False priority = False

View file

@ -262,7 +262,7 @@ class ProfileWindow:
entries = entry.split('_') entries = entry.split('_')
loc = vcard_ loc = vcard_
if len(entries) == 3: # We need to use lists if len(entries) == 3: # We need to use lists
if not loc.has_key(entries[0]): if entries[0] not in loc:
loc[entries[0]] = [] loc[entries[0]] = []
found = False found = False
for e in loc[entries[0]]: for e in loc[entries[0]]:
@ -275,7 +275,7 @@ class ProfileWindow:
loc[entries[0]].append({entries[1]: '', entries[2]: txt}) loc[entries[0]].append({entries[1]: '', entries[2]: txt})
return vcard_ return vcard_
while len(entries) > 1: while len(entries) > 1:
if not loc.has_key(entries[0]): if entries[0] not in loc:
loc[entries[0]] = {} loc[entries[0]] = {}
loc = loc[entries[0]] loc = loc[entries[0]]
del entries[0] del entries[0]
@ -323,7 +323,7 @@ class ProfileWindow:
return return
vcard_ = self.make_vcard() vcard_ = self.make_vcard()
nick = '' nick = ''
if vcard_.has_key('NICKNAME'): if 'NICKNAME' in vcard_:
nick = vcard_['NICKNAME'] nick = vcard_['NICKNAME']
from common import pep from common import pep
pep.user_send_nickname(self.account, nick) pep.user_send_nickname(self.account, nick)

View file

@ -433,7 +433,7 @@ class SignalObject(dbus.service.Object):
def account_info(self, account): def account_info(self, account):
'''show info on account: resource, jid, nick, prio, message''' '''show info on account: resource, jid, nick, prio, message'''
result = DBUS_DICT_SS() result = DBUS_DICT_SS()
if gajim.connections.has_key(account): if account in gajim.connections:
# account is valid # account is valid
con = gajim.connections[account] con = gajim.connections[account]
index = con.connected index = con.connected

View file

@ -454,7 +454,7 @@ class RosterWindow:
if parent_type == 'group' and \ if parent_type == 'group' and \
self.model.iter_n_children(parent_i) == 1: self.model.iter_n_children(parent_i) == 1:
group = self.model[parent_i][C_JID].decode('utf-8') group = self.model[parent_i][C_JID].decode('utf-8')
if gajim.groups[account].has_key(group): if group in gajim.groups[account]:
del gajim.groups[account][group] del gajim.groups[account][group]
self.model.remove(parent_i) self.model.remove(parent_i)
else: else:
@ -985,7 +985,7 @@ class RosterWindow:
gajim.connections[account].mood['mood'].strip()).get_pixbuf() gajim.connections[account].mood['mood'].strip()).get_pixbuf()
elif gajim.config.get('show_mood_in_roster') \ elif gajim.config.get('show_mood_in_roster') \
and gajim.connections[account].mood.has_key('mood'): and 'mood' in gajim.connections[account].mood:
self.model[child_iter][C_MOOD_PIXBUF] = \ self.model[child_iter][C_MOOD_PIXBUF] = \
gtkgui_helpers.load_mood_icon('unknown'). \ gtkgui_helpers.load_mood_icon('unknown'). \
get_pixbuf() get_pixbuf()
@ -993,7 +993,7 @@ class RosterWindow:
self.model[child_iter][C_MOOD_PIXBUF] = None self.model[child_iter][C_MOOD_PIXBUF] = None
if gajim.config.get('show_activity_in_roster') \ if gajim.config.get('show_activity_in_roster') \
and gajim.connections[account].activity.has_key('activity') \ and 'activity' in gajim.connections[account].activity \
and gajim.connections[account].activity['activity'].strip() \ and gajim.connections[account].activity['activity'].strip() \
in ACTIVITIES: in ACTIVITIES:
self.model[child_iter][C_ACTIVITY_PIXBUF] = \ self.model[child_iter][C_ACTIVITY_PIXBUF] = \
@ -1001,7 +1001,7 @@ class RosterWindow:
gajim.connections[account]. \ gajim.connections[account]. \
activity['activity'].strip()).get_pixbuf() activity['activity'].strip()).get_pixbuf()
elif gajim.config.get('show_activity_in_roster') \ elif gajim.config.get('show_activity_in_roster') \
and gajim.connections[account].activity.has_key('activity'): and 'activity' in gajim.connections[account].activity:
self.model[child_iter][C_ACTIVITY_PIXBUF] = \ self.model[child_iter][C_ACTIVITY_PIXBUF] = \
gtkgui_helpers.load_activity_icon('unknown'). \ gtkgui_helpers.load_activity_icon('unknown'). \
get_pixbuf() get_pixbuf()
@ -1009,8 +1009,8 @@ class RosterWindow:
self.model[child_iter][C_ACTIVITY_PIXBUF] = None self.model[child_iter][C_ACTIVITY_PIXBUF] = None
if gajim.config.get('show_tunes_in_roster') \ if gajim.config.get('show_tunes_in_roster') \
and (gajim.connections[account].tune.has_key('artist') \ and ('artist' in gajim.connections[account].tune \
or gajim.connections[account].tune.has_key('title')): or 'title' in gajim.connections[account].tune):
self.model[child_iter][C_TUNE_PIXBUF] = \ self.model[child_iter][C_TUNE_PIXBUF] = \
gtk.gdk.pixbuf_new_from_file( gtk.gdk.pixbuf_new_from_file(
'../data/emoticons/static/music.png') '../data/emoticons/static/music.png')
@ -1266,7 +1266,7 @@ class RosterWindow:
jid = self.model[iters[0]][C_JID] jid = self.model[iters[0]][C_JID]
jid = jid.decode('utf-8') jid = jid.decode('utf-8')
contact = gajim.contacts.get_contact(account, jid) contact = gajim.contacts.get_contact(account, jid)
if contact.tune.has_key('artist') or contact.tune.has_key('title'): if 'artist' in contact.tune or 'title' in contact.tune:
pixbuf = gtk.gdk.pixbuf_new_from_file( pixbuf = gtk.gdk.pixbuf_new_from_file(
'../data/emoticons/static/music.png') '../data/emoticons/static/music.png')
else: else:
@ -1966,9 +1966,9 @@ class RosterWindow:
gajim.SHOW_LIST.index('invisible') gajim.SHOW_LIST.index('invisible')
gajim.connections[account].change_status(status, txt, auto) gajim.connections[account].change_status(status, txt, auto)
if gajim.interface.status_sent_to_users.has_key(account): if account in gajim.interface.status_sent_to_users:
gajim.interface.status_sent_to_users[account] = {} gajim.interface.status_sent_to_users[account] = {}
if gajim.interface.status_sent_to_groups.has_key(account): if account in gajim.interface.status_sent_to_groups:
gajim.interface.status_sent_to_groups[account] = {} gajim.interface.status_sent_to_groups[account] = {}
for gc_control in gajim.interface.msg_win_mgr.get_controls( for gc_control in gajim.interface.msg_win_mgr.get_controls(
message_control.TYPE_GC) + \ message_control.TYPE_GC) + \
@ -2034,7 +2034,7 @@ class RosterWindow:
ctrl.update_status_display(name, uf_show, status) ctrl.update_status_display(name, uf_show, status)
# unset custom status # unset custom status
if gajim.interface.status_sent_to_users.has_key(account) and \ if account in gajim.interface.status_sent_to_users and \
contact.jid in gajim.interface.status_sent_to_users[account]: contact.jid in gajim.interface.status_sent_to_users[account]:
del gajim.interface.status_sent_to_users[account][contact.jid] del gajim.interface.status_sent_to_users[account][contact.jid]
@ -2264,7 +2264,7 @@ class RosterWindow:
for win in gajim.interface.msg_win_mgr.windows(): for win in gajim.interface.msg_win_mgr.windows():
for ctrl in win.controls(): for ctrl in win.controls():
fjid = ctrl.get_full_jid() fjid = ctrl.get_full_jid()
if gajim.last_message_time[ctrl.account].has_key(fjid): if fjid in gajim.last_message_time[ctrl.account]:
if time.time() - gajim.last_message_time[ctrl.account][fjid] \ if time.time() - gajim.last_message_time[ctrl.account][fjid] \
< 2: < 2:
recent = True recent = True
@ -2307,14 +2307,14 @@ class RosterWindow:
dialogs.SingleMessageWindow(account, server, 'send') dialogs.SingleMessageWindow(account, server, 'send')
def on_xml_console_menuitem_activate(self, widget, account): def on_xml_console_menuitem_activate(self, widget, account):
if gajim.interface.instances[account].has_key('xml_console'): if 'xml_console' in gajim.interface.instances[account]:
gajim.interface.instances[account]['xml_console'].window.present() gajim.interface.instances[account]['xml_console'].window.present()
else: else:
gajim.interface.instances[account]['xml_console'] = \ gajim.interface.instances[account]['xml_console'] = \
dialogs.XMLConsoleWindow(account) dialogs.XMLConsoleWindow(account)
def on_privacy_lists_menuitem_activate(self, widget, account): def on_privacy_lists_menuitem_activate(self, widget, account):
if gajim.interface.instances[account].has_key('privacy_lists'): if 'privacy_lists' in gajim.interface.instances[account]:
gajim.interface.instances[account]['privacy_lists'].window.present() gajim.interface.instances[account]['privacy_lists'].window.present()
else: else:
gajim.interface.instances[account]['privacy_lists'] = \ gajim.interface.instances[account]['privacy_lists'] = \
@ -2351,14 +2351,14 @@ class RosterWindow:
return return
info = gajim.interface.instances[account]['infos'] info = gajim.interface.instances[account]['infos']
if info.has_key(contact.jid): if contact.jid in info:
info[contact.jid].window.present() info[contact.jid].window.present()
else: else:
info[contact.jid] = vcard.VcardWindow(contact, account) info[contact.jid] = vcard.VcardWindow(contact, account)
def on_info_zeroconf(self, widget, contact, account): def on_info_zeroconf(self, widget, contact, account):
info = gajim.interface.instances[account]['infos'] info = gajim.interface.instances[account]['infos']
if info.has_key(contact.jid): if contact.jid in info:
info[contact.jid].window.present() info[contact.jid].window.present()
else: else:
contact = gajim.contacts.get_first_contact_from_jid(account, contact = gajim.contacts.get_first_contact_from_jid(account,
@ -2625,7 +2625,7 @@ class RosterWindow:
gajim.connections[account].set_default_list('') gajim.connections[account].set_default_list('')
gajim.connections[account].set_active_list('') gajim.connections[account].set_active_list('')
gajim.connections[account].del_privacy_list('block') gajim.connections[account].del_privacy_list('block')
if gajim.interface.instances[account].has_key('blocked_contacts'): if 'blocked_contacts' in gajim.interface.instances[account]:
gajim.interface.instances[account]['blocked_contacts'].\ gajim.interface.instances[account]['blocked_contacts'].\
privacy_list_received([]) privacy_list_received([])
for (contact, account) in list_: for (contact, account) in list_:
@ -2647,7 +2647,7 @@ class RosterWindow:
def on_rename(self, widget, row_type, jid, account): def on_rename(self, widget, row_type, jid, account):
# this function is called either by F2 or by Rename menuitem # this function is called either by F2 or by Rename menuitem
if gajim.interface.instances.has_key('rename'): if 'rename' in gajim.interface.instances:
gajim.interface.instances['rename'].dialog.present() gajim.interface.instances['rename'].dialog.present()
return return
model = self.modelfilter model = self.modelfilter
@ -2669,7 +2669,7 @@ class RosterWindow:
message = _('Enter a new name for group %s') % jid message = _('Enter a new name for group %s') % jid
def on_renamed(new_text, account, row_type, jid, old_text): def on_renamed(new_text, account, row_type, jid, old_text):
if gajim.interface.instances.has_key('rename'): if 'rename' in gajim.interface.instances:
del gajim.interface.instances['rename'] del gajim.interface.instances['rename']
if row_type in ('contact', 'agent'): if row_type in ('contact', 'agent'):
if old_text == new_text: if old_text == new_text:
@ -2706,7 +2706,7 @@ class RosterWindow:
self.add_contact_to_groups(jid, acc, [new_text,]) self.add_contact_to_groups(jid, acc, [new_text,])
def on_canceled(): def on_canceled():
if gajim.interface.instances.has_key('rename'): if 'rename' in gajim.interface.instances:
del gajim.interface.instances['rename'] del gajim.interface.instances['rename']
gajim.interface.instances['rename'] = dialogs.InputDialog(title, message, gajim.interface.instances['rename'] = dialogs.InputDialog(title, message,
@ -2812,7 +2812,7 @@ class RosterWindow:
def on_history(self, widget, contact, account): def on_history(self, widget, contact, account):
'''When history menuitem is activated: call log window''' '''When history menuitem is activated: call log window'''
if gajim.interface.instances.has_key('logs'): if 'logs' in gajim.interface.instances:
gajim.interface.instances['logs'].window.present() gajim.interface.instances['logs'].window.present()
gajim.interface.instances['logs'].open_history(contact.jid, account) gajim.interface.instances['logs'].open_history(contact.jid, account)
else: else:
@ -2865,7 +2865,7 @@ class RosterWindow:
for account in account_list: for account in account_list:
if gajim.connections[account].muc_jid[type_]: if gajim.connections[account].muc_jid[type_]:
# create the room on this muc server # create the room on this muc server
if gajim.interface.instances[account].has_key('join_gc'): if 'join_gc' in gajim.interface.instances[account]:
gajim.interface.instances[account]['join_gc'].window.destroy() gajim.interface.instances[account]['join_gc'].window.destroy()
try: try:
gajim.interface.instances[account]['join_gc'] = \ gajim.interface.instances[account]['join_gc'] = \
@ -2906,14 +2906,14 @@ class RosterWindow:
self.remove_groupchat(jid, account) self.remove_groupchat(jid, account)
def on_edit_account(self, widget, account): def on_edit_account(self, widget, account):
if gajim.interface.instances.has_key('accounts'): if 'accounts' in gajim.interface.instances:
gajim.interface.instances['accounts'].window.present() gajim.interface.instances['accounts'].window.present()
else: else:
gajim.interface.instances['accounts'] = config.AccountsWindow() gajim.interface.instances['accounts'] = config.AccountsWindow()
gajim.interface.instances['accounts'].select_account(account) gajim.interface.instances['accounts'].select_account(account)
def on_zeroconf_properties(self, widget, account): def on_zeroconf_properties(self, widget, account):
if gajim.interface.instances.has_key('accounts'): if 'accounts' in gajim.interface.instances:
gajim.interface.instances['accounts'].window.present() gajim.interface.instances['accounts'].window.present()
else: else:
gajim.interface.instances['accounts'] = config.AccountsWindow() gajim.interface.instances['accounts'] = config.AccountsWindow()
@ -3156,7 +3156,7 @@ class RosterWindow:
our_jid = gajim.get_jid_from_account(account) our_jid = gajim.get_jid_from_account(account)
accounts = [] accounts = []
if group and account not in accounts: if group and account not in accounts:
if not gajim.interface.status_sent_to_groups.has_key(account): if account not in gajim.interface.status_sent_to_groups:
gajim.interface.status_sent_to_groups[account] = {} gajim.interface.status_sent_to_groups[account] = {}
gajim.interface.status_sent_to_groups[account][group] = show gajim.interface.status_sent_to_groups[account][group] = show
accounts.append(group) accounts.append(group)
@ -3164,7 +3164,7 @@ class RosterWindow:
if jid == our_jid: if jid == our_jid:
jid += '/' + contact.resource jid += '/' + contact.resource
self.send_status(account, show, message, to=jid) self.send_status(account, show, message, to=jid)
if not gajim.interface.status_sent_to_users.has_key(account): if account not in gajim.interface.status_sent_to_users:
gajim.interface.status_sent_to_users[account] = {} gajim.interface.status_sent_to_users[account] = {}
gajim.interface.status_sent_to_users[account][contact.jid] = show gajim.interface.status_sent_to_users[account][contact.jid] = show
dialogs.ChangeStatusMessageDialog(on_response, show) dialogs.ChangeStatusMessageDialog(on_response, show)
@ -3266,7 +3266,7 @@ class RosterWindow:
self.get_status_message(status, on_continue) self.get_status_message(status, on_continue)
def on_preferences_menuitem_activate(self, widget): def on_preferences_menuitem_activate(self, widget):
if gajim.interface.instances.has_key('preferences'): if 'preferences' in gajim.interface.instances:
gajim.interface.instances['preferences'].window.present() gajim.interface.instances['preferences'].window.present()
else: else:
gajim.interface.instances['preferences'] = config.PreferencesWindow() gajim.interface.instances['preferences'] = config.PreferencesWindow()
@ -3300,7 +3300,7 @@ class RosterWindow:
helpers.update_optional_features(account) helpers.update_optional_features(account)
def on_pep_services_menuitem_activate(self, widget, account): def on_pep_services_menuitem_activate(self, widget, account):
if gajim.interface.instances[account].has_key('pep_services'): if 'pep_services' in gajim.interface.instances[account]:
gajim.interface.instances[account]['pep_services'].window.present() gajim.interface.instances[account]['pep_services'].window.present()
else: else:
gajim.interface.instances[account]['pep_services'] = \ gajim.interface.instances[account]['pep_services'] = \
@ -3316,7 +3316,7 @@ class RosterWindow:
dialogs.ErrorDialog(_('You cannot join a group chat while you are ' dialogs.ErrorDialog(_('You cannot join a group chat while you are '
'invisible')) 'invisible'))
return return
if gajim.interface.instances[account].has_key('join_gc'): if 'join_gc' in gajim.interface.instances[account]:
gajim.interface.instances[account]['join_gc'].window.present() gajim.interface.instances[account]['join_gc'].window.present()
else: else:
# c http://nkour.blogspot.com/2005/05/pythons-init-return-none-doesnt-return.html # c http://nkour.blogspot.com/2005/05/pythons-init-return-none-doesnt-return.html
@ -3343,7 +3343,7 @@ class RosterWindow:
dialogs.AboutDialog() dialogs.AboutDialog()
def on_accounts_menuitem_activate(self, widget): def on_accounts_menuitem_activate(self, widget):
if gajim.interface.instances.has_key('accounts'): if 'accounts' in gajim.interface.instances:
gajim.interface.instances['accounts'].window.present() gajim.interface.instances['accounts'].window.present()
else: else:
gajim.interface.instances['accounts'] = config.AccountsWindow() gajim.interface.instances['accounts'] = config.AccountsWindow()
@ -3356,7 +3356,7 @@ class RosterWindow:
gajim.interface.instances['file_transfers'].window.show_all() gajim.interface.instances['file_transfers'].window.show_all()
def on_history_menuitem_activate(self, widget): def on_history_menuitem_activate(self, widget):
if gajim.interface.instances.has_key('logs'): if 'logs' in gajim.interface.instances:
gajim.interface.instances['logs'].window.present() gajim.interface.instances['logs'].window.present()
else: else:
gajim.interface.instances['logs'] = history_window.\ gajim.interface.instances['logs'] = history_window.\
@ -3638,7 +3638,7 @@ class RosterWindow:
def on_service_disco_menuitem_activate(self, widget, account): def on_service_disco_menuitem_activate(self, widget, account):
server_jid = gajim.config.get_per('accounts', account, 'hostname') server_jid = gajim.config.get_per('accounts', account, 'hostname')
if gajim.interface.instances[account]['disco'].has_key(server_jid): if server_jid in gajim.interface.instances[account]['disco']:
gajim.interface.instances[account]['disco'][server_jid].\ gajim.interface.instances[account]['disco'][server_jid].\
window.present() window.present()
else: else:
@ -4022,11 +4022,11 @@ class RosterWindow:
transport: transport iconset doesn't contain all icons, so we fall back transport: transport iconset doesn't contain all icons, so we fall back
to jabber one''' to jabber one'''
transport = gajim.get_transport_name_from_jid(jid) transport = gajim.get_transport_name_from_jid(jid)
if transport and self.transports_state_images.has_key(size): if transport and size in self.transports_state_images:
if not self.transports_state_images[size].has_key(transport): if transport not in self.transports_state_images[size]:
# we don't have iconset for this transport loaded yet. Let's do it # we don't have iconset for this transport loaded yet. Let's do it
self.make_transport_state_images(transport) self.make_transport_state_images(transport)
if self.transports_state_images[size].has_key(transport) and \ if transport in self.transports_state_images[size] and \
icon_name in self.transports_state_images[size][transport]: icon_name in self.transports_state_images[size][transport]:
return self.transports_state_images[size][transport] return self.transports_state_images[size][transport]
return gajim.interface.jabber_state_images[size] return gajim.interface.jabber_state_images[size]
@ -5334,7 +5334,7 @@ class RosterWindow:
send_custom_status_menuitem.set_image( \ send_custom_status_menuitem.set_image( \
gtkgui_helpers.load_icon('offline')) gtkgui_helpers.load_icon('offline'))
send_custom_status_menuitem.set_sensitive(False) send_custom_status_menuitem.set_sensitive(False)
elif gajim.interface.status_sent_to_users.has_key(account) and \ elif account in gajim.interface.status_sent_to_users and \
jid in gajim.interface.status_sent_to_users[account]: jid in gajim.interface.status_sent_to_users[account]:
send_custom_status_menuitem.set_image( send_custom_status_menuitem.set_image(
gtkgui_helpers.load_icon( \ gtkgui_helpers.load_icon( \
@ -5655,7 +5655,7 @@ class RosterWindow:
'offline')) 'offline'))
send_custom_status_menuitem.set_sensitive(False) send_custom_status_menuitem.set_sensitive(False)
else: else:
if gajim.interface.status_sent_to_users.has_key(account) and \ if account in gajim.interface.status_sent_to_users and \
jid in gajim.interface.status_sent_to_users[account]: jid in gajim.interface.status_sent_to_users[account]:
send_custom_status_menuitem.set_image(gtkgui_helpers.load_icon( send_custom_status_menuitem.set_image(gtkgui_helpers.load_icon(
gajim.interface.status_sent_to_users[account][jid])) gajim.interface.status_sent_to_users[account][jid]))
@ -5885,7 +5885,7 @@ class RosterWindow:
for account in connected_accounts: for account in connected_accounts:
for t in gajim.connections[account].muc_jid: for t in gajim.connections[account].muc_jid:
muc_jid[t] = gajim.connections[account].muc_jid[t] muc_jid[t] = gajim.connections[account].muc_jid[t]
if not muc_jid.has_key(c_t): if c_t not in muc_jid:
invite_to_new_room_menuitem.set_sensitive(False) invite_to_new_room_menuitem.set_sensitive(False)
rooms = [] # a list of (room_jid, account) tuple rooms = [] # a list of (room_jid, account) tuple
invite_to_submenu.append(invite_to_new_room_menuitem) invite_to_submenu.append(invite_to_new_room_menuitem)
@ -5898,7 +5898,7 @@ class RosterWindow:
message_control.TYPE_GC) + minimized_controls: message_control.TYPE_GC) + minimized_controls:
acct = gc_control.account acct = gc_control.account
room_jid = gc_control.room_jid room_jid = gc_control.room_jid
if gajim.gc_connected[acct].has_key(room_jid) and \ if room_jid in gajim.gc_connected[acct] and \
gajim.gc_connected[acct][room_jid] and \ gajim.gc_connected[acct][room_jid] and \
contacts_transport == gajim.get_transport_name_from_jid(room_jid): contacts_transport == gajim.get_transport_name_from_jid(room_jid):
rooms.append((room_jid, acct)) rooms.append((room_jid, acct))

View file

@ -82,7 +82,7 @@ class SearchWindow:
self.data_form_widget.data_form.get_purged(), True) self.data_form_widget.data_form.get_purged(), True)
else: else:
infos = self.data_form_widget.get_infos() infos = self.data_form_widget.get_infos()
if infos.has_key('instructions'): if 'instructions' in infos:
del infos['instructions'] del infos['instructions']
gajim.connections[self.account].send_search_form(self.jid, infos, gajim.connections[self.account].send_search_form(self.jid, infos,
False) False)
@ -107,7 +107,7 @@ class SearchWindow:
if not iter: if not iter:
return return
jid = model[iter][self.jid_column] jid = model[iter][self.jid_column]
if gajim.interface.instances[self.account]['infos'].has_key(jid): if jid in gajim.interface.instances[self.account]['infos']:
gajim.interface.instances[self.account]['infos'][jid].window.present() gajim.interface.instances[self.account]['infos'][jid].window.present()
else: else:
contact = gajim.contacts.create_contact(jid = jid, name='', groups=[], contact = gajim.contacts.create_contact(jid = jid, name='', groups=[],

View file

@ -166,7 +166,7 @@ class Systray:
path = os.path.join(helpers.get_iconset_path(iconset), '16x16') path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
state_images = gtkgui_helpers.load_iconset(path) state_images = gtkgui_helpers.load_iconset(path)
if state_images.has_key('muc_active'): if 'muc_active' in state_images:
join_gc_menuitem.set_image(state_images['muc_active']) join_gc_menuitem.set_image(state_images['muc_active'])
for show in ('online', 'chat', 'away', 'xa', 'dnd', 'invisible'): for show in ('online', 'chat', 'away', 'xa', 'dnd', 'invisible'):
@ -372,7 +372,7 @@ class Systray:
win.present() win.present()
def on_preferences_menuitem_activate(self, widget): def on_preferences_menuitem_activate(self, widget):
if gajim.interface.instances.has_key('preferences'): if 'preferences' in gajim.interface.instances:
gajim.interface.instances['preferences'].window.present() gajim.interface.instances['preferences'].window.present()
else: else:
gajim.interface.instances['preferences'] = config.PreferencesWindow() gajim.interface.instances['preferences'] = config.PreferencesWindow()

View file

@ -254,7 +254,7 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable):
message = unicode(message, encoding = 'utf-8') message = unicode(message, encoding = 'utf-8')
message = helpers.reduce_chars_newlines(message, 100, 1) message = helpers.reduce_chars_newlines(message, 100, 1)
message = gobject.markup_escape_text(message) message = gobject.markup_escape_text(message)
if gajim.con_types.has_key(acct['name']) and \ if acct['name'] in gajim.con_types and \
gajim.con_types[acct['name']] in ('tls', 'ssl'): gajim.con_types[acct['name']] in ('tls', 'ssl'):
show_lock = True show_lock = True
else: else:
@ -431,7 +431,7 @@ class RosterTooltip(NotificationAreaTooltip):
self.account].blocked_contacts: self.account].blocked_contacts:
name_markup += _(' [blocked]') name_markup += _(' [blocked]')
if self.account and \ if self.account and \
gajim.interface.minimized_controls.has_key(self.account) and \ self.account in gajim.interface.minimized_controls and \
prim_contact.jid in gajim.interface.minimized_controls[self.account]: prim_contact.jid in gajim.interface.minimized_controls[self.account]:
name_markup += _(' [minimized]') name_markup += _(' [minimized]')
properties.append((name_markup, None)) properties.append((name_markup, None))
@ -497,7 +497,7 @@ class RosterTooltip(NotificationAreaTooltip):
text = text % local_time text = text % local_time
show += text show += text
if self.account and \ if self.account and \
gajim.gc_connected[self.account].has_key(prim_contact.jid): prim_contact.jid in gajim.gc_connected[self.account]:
if gajim.gc_connected[self.account][prim_contact.jid]: if gajim.gc_connected[self.account][prim_contact.jid]:
show = _('Connected') show = _('Connected')
else: else:
@ -528,7 +528,7 @@ class RosterTooltip(NotificationAreaTooltip):
' (' + unicode(contact.priority) + ')')) ' (' + unicode(contact.priority) + ')'))
if self.account and prim_contact.sub and prim_contact.sub != 'both' and\ if self.account and prim_contact.sub and prim_contact.sub != 'both' and\
not gajim.gc_connected[self.account].has_key(prim_contact.jid): prim_contact.jid not in gajim.gc_connected[self.account]:
# ('both' is the normal sub so we don't show it) # ('both' is the normal sub so we don't show it)
properties.append(( _('Subscription: '), properties.append(( _('Subscription: '),
gobject.markup_escape_text(helpers.get_uf_sub(prim_contact.sub)))) gobject.markup_escape_text(helpers.get_uf_sub(prim_contact.sub))))
@ -581,13 +581,13 @@ class RosterTooltip(NotificationAreaTooltip):
Append Tune, Mood, Activity information of the specified contact Append Tune, Mood, Activity information of the specified contact
to the given property list. to the given property list.
''' '''
if contact.mood.has_key('mood'): if 'mood' in contact.mood:
mood = contact.mood['mood'].strip() mood = contact.mood['mood'].strip()
if mood in MOODS: if mood in MOODS:
mood = MOODS[mood] mood = MOODS[mood]
mood = gobject.markup_escape_text(mood) mood = gobject.markup_escape_text(mood)
mood_string = _('Mood:') + ' <b>%s</b>' % mood mood_string = _('Mood:') + ' <b>%s</b>' % mood
if contact.mood.has_key('text') \ if 'text' in contact.mood \
and contact.mood['text'] != '': and contact.mood['text'] != '':
mood_text = contact.mood['text'].strip() mood_text = contact.mood['text'].strip()
mood_text = \ mood_text = \
@ -595,14 +595,14 @@ class RosterTooltip(NotificationAreaTooltip):
mood_string += ' (%s)' % mood_text mood_string += ' (%s)' % mood_text
properties.append((mood_string, None)) properties.append((mood_string, None))
if contact.activity.has_key('activity'): if 'activity' in contact.activity:
activity = act_plain = \ activity = act_plain = \
contact.activity['activity'].strip() contact.activity['activity'].strip()
activity = gobject.markup_escape_text(activity) activity = gobject.markup_escape_text(activity)
if act_plain in ACTIVITIES: if act_plain in ACTIVITIES:
activity = ACTIVITIES[activity]['category'] activity = ACTIVITIES[activity]['category']
activity_string = _('Activity:') + ' <b>%s' % activity activity_string = _('Activity:') + ' <b>%s' % activity
if contact.activity.has_key('subactivity'): if 'subactivity' in contact.activity:
activity_sub = \ activity_sub = \
contact.activity['subactivity'].strip() contact.activity['subactivity'].strip()
if act_plain in ACTIVITIES and activity_sub in \ if act_plain in ACTIVITIES and activity_sub in \
@ -613,26 +613,26 @@ class RosterTooltip(NotificationAreaTooltip):
activity_string += ': %s</b>' % activity_sub activity_string += ': %s</b>' % activity_sub
else: else:
activity_string += '</b>' activity_string += '</b>'
if contact.activity.has_key('text'): if 'text' in contact.activity:
activity_text = contact.activity['text'].strip() activity_text = contact.activity['text'].strip()
activity_text = gobject.markup_escape_text( activity_text = gobject.markup_escape_text(
activity_text) activity_text)
activity_string += ' (%s)' % activity_text activity_string += ' (%s)' % activity_text
properties.append((activity_string, None)) properties.append((activity_string, None))
if contact.tune.has_key('artist') \ if 'artist' in contact.tune \
or contact.tune.has_key('title'): or 'title' in contact.tune:
if contact.tune.has_key('artist'): if 'artist' in contact.tune:
artist = contact.tune['artist'].strip() artist = contact.tune['artist'].strip()
artist = gobject.markup_escape_text(artist) artist = gobject.markup_escape_text(artist)
else: else:
artist = _('Unknown Artist') artist = _('Unknown Artist')
if contact.tune.has_key('title'): if 'title' in contact.tune:
title = contact.tune['title'].strip() title = contact.tune['title'].strip()
title = gobject.markup_escape_text(title) title = gobject.markup_escape_text(title)
else: else:
title = _('Unknown Title') title = _('Unknown Title')
if contact.tune.has_key('source'): if 'source' in contact.tune:
source = contact.tune['source'].strip() source = contact.tune['source'].strip()
source = gobject.markup_escape_text(source) source = gobject.markup_escape_text(source)
else: else:
@ -680,14 +680,14 @@ class FileTransfersTooltip(BaseTooltip):
properties.append((actor, gobject.markup_escape_text(name))) properties.append((actor, gobject.markup_escape_text(name)))
transfered_len = 0 transfered_len = 0
if file_props.has_key('received-len'): if 'received-len' in file_props:
transfered_len = file_props['received-len'] transfered_len = file_props['received-len']
properties.append((_('Transferred: '), helpers.convert_bytes(transfered_len))) properties.append((_('Transferred: '), helpers.convert_bytes(transfered_len)))
status = '' status = ''
if not file_props.has_key('started') or not file_props['started']: if 'started' not in file_props or not file_props['started']:
status = _('Not started') status = _('Not started')
elif file_props.has_key('connected'): elif 'connected' in file_props:
if file_props.has_key('stopped') and \ if 'stopped' in file_props and \
file_props['stopped'] == True: file_props['stopped'] == True:
status = _('Stopped') status = _('Stopped')
elif file_props['completed']: elif file_props['completed']:
@ -696,10 +696,10 @@ class FileTransfersTooltip(BaseTooltip):
if file_props['completed']: if file_props['completed']:
status = _('Completed') status = _('Completed')
else: else:
if file_props.has_key('paused') and \ if 'paused' in file_props and \
file_props['paused'] == True: file_props['paused'] == True:
status = _('?transfer status:Paused') status = _('?transfer status:Paused')
elif file_props.has_key('stalled') and \ elif 'stalled' in file_props and \
file_props['stalled'] == True: file_props['stalled'] == True:
#stalled is not paused. it is like 'frozen' it stopped alone #stalled is not paused. it is like 'frozen' it stopped alone
status = _('Stalled') status = _('Stalled')

View file

@ -53,7 +53,7 @@ def get_avatar_pixbuf_encoded_mime(photo):
img_decoded = None img_decoded = None
avatar_encoded = None avatar_encoded = None
avatar_mime_type = None avatar_mime_type = None
if photo.has_key('BINVAL'): if 'BINVAL' in photo:
img_encoded = photo['BINVAL'] img_encoded = photo['BINVAL']
avatar_encoded = img_encoded avatar_encoded = img_encoded
try: try:
@ -61,7 +61,7 @@ def get_avatar_pixbuf_encoded_mime(photo):
except: except:
pass pass
if img_decoded: if img_decoded:
if photo.has_key('TYPE'): if 'TYPE' in photo:
avatar_mime_type = photo['TYPE'] avatar_mime_type = photo['TYPE']
pixbuf = gtkgui_helpers.get_pixbuf_from_data(img_decoded) pixbuf = gtkgui_helpers.get_pixbuf_from_data(img_decoded)
else: else:
@ -230,7 +230,7 @@ class VcardWindow:
i = 0 i = 0
client = '' client = ''
os = '' os = ''
while self.os_info.has_key(i): while i in self.os_info:
if not self.os_info[i]['resource'] or \ if not self.os_info[i]['resource'] or \
self.os_info[i]['resource'] == resource: self.os_info[i]['resource'] == resource:
self.os_info[i]['client'] = client_info self.os_info[i]['client'] = client_info
@ -525,7 +525,7 @@ class ZeroconfVcardWindow:
def fill_personal_page(self): def fill_personal_page(self):
contact = gajim.connections[gajim.ZEROCONF_ACC_NAME].roster.getItem(self.contact.jid) contact = gajim.connections[gajim.ZEROCONF_ACC_NAME].roster.getItem(self.contact.jid)
for key in ('1st', 'last', 'jid', 'email'): for key in ('1st', 'last', 'jid', 'email'):
if not contact['txt_dict'].has_key(key): if key not in contact['txt_dict']:
contact['txt_dict'][key] = '' contact['txt_dict'][key] = ''
self.xml.get_widget('first_name_label').set_text(contact['txt_dict']['1st']) self.xml.get_widget('first_name_label').set_text(contact['txt_dict']['1st'])
self.xml.get_widget('last_name_label').set_text(contact['txt_dict']['last']) self.xml.get_widget('last_name_label').set_text(contact['txt_dict']['last'])

View file

@ -87,7 +87,7 @@ class Mock:
if realClass: if realClass:
self.realClassMethods = dict(inspect.getmembers(realClass, inspect.isroutine)) self.realClassMethods = dict(inspect.getmembers(realClass, inspect.isroutine))
for retMethod in self.mockReturnValues.keys(): for retMethod in self.mockReturnValues.keys():
if not self.realClassMethods.has_key(retMethod): if retMethod not in self.realClassMethods:
raise MockInterfaceError("Return value supplied for method '%s' that was not in the original class" % retMethod) raise MockInterfaceError("Return value supplied for method '%s' that was not in the original class" % retMethod)
self._setupSubclassMethodInterceptors() self._setupSubclassMethodInterceptors()
@ -118,7 +118,7 @@ class Mock:
""" """
if self.realClassMethods == None: if self.realClassMethods == None:
return return
if not self.realClassMethods.has_key(name): if name not in self.realClassMethods:
raise MockInterfaceError("Calling mock method '%s' that was not found in the original class" % name) raise MockInterfaceError("Calling mock method '%s' that was not found in the original class" % name)
func = self.realClassMethods[name] func = self.realClassMethods[name]
@ -181,7 +181,7 @@ def _getNumPosSeenAndCheck(numPosCallParams, callKwParams, args, varkw):
for arg in args[:numPosCallParams]: for arg in args[:numPosCallParams]:
posSeen[arg] = True posSeen[arg] = True
for kwp in callKwParams: for kwp in callKwParams:
if posSeen.has_key(kwp): if kwp in posSeen:
raise MockInterfaceError("%s appears as both a positional and named parameter." % kwp) raise MockInterfaceError("%s appears as both a positional and named parameter." % kwp)
if kwp in args: if kwp in args:
posSeen[kwp] = True posSeen[kwp] = True
@ -289,7 +289,7 @@ class MockCallable:
def _findFunc(cl, name): def _findFunc(cl, name):
""" Depth first search for a method with a given name. """ """ Depth first search for a method with a given name. """
if cl.__dict__.has_key(name): if name in cl.__dict__:
return cl.__dict__[name] return cl.__dict__[name]
for base in cl.__bases__: for base in cl.__bases__:
func = _findFunc(base, name) func = _findFunc(base, name)