[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)'))
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)
else:
self.changed_opts[option] = (oldval, newval)

View File

@ -764,7 +764,7 @@ class ChatControlBase(MessageControl):
if not 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'].open_history(jid, self.account)
else:
@ -1190,9 +1190,9 @@ class ChatControl(ChatControlBase):
if isinstance(self.contact, GC_Contact):
return
if self.contact.mood.has_key('mood'):
if 'mood' in self.contact.mood:
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()
if mood is not None:
@ -1230,11 +1230,11 @@ class ChatControl(ChatControlBase):
if isinstance(self.contact, GC_Contact):
return
if self.contact.activity.has_key('activity'):
if 'activity' in self.contact.activity:
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()
if self.contact.activity.has_key('text'):
if 'text' in self.contact.activity:
text = self.contact.activity['text'].strip()
if activity is not None:
@ -1280,15 +1280,15 @@ class ChatControl(ChatControlBase):
if isinstance(self.contact, GC_Contact):
return
if self.contact.tune.has_key('artist'):
if 'artist' in self.contact.tune:
artist = self.contact.tune['artist'].strip()
if HAVE_MARKUP_TOOLTIPS:
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()
if HAVE_MARKUP_TOOLTIPS:
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()
if HAVE_MARKUP_TOOLTIPS:
source = gobject.markup_escape_text(source)
@ -1396,7 +1396,7 @@ class ChatControl(ChatControlBase):
size = '32', icon_name = show)
img_16 = gajim.interface.roster.get_appropriate_state_images(jid,
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!
banner_image = img_32[show]
use_size_32 = True

View File

@ -140,7 +140,7 @@ if gajim.HAVE_GPG:
try: proc.wait()
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 'BAD_PASSPHRASE'
@ -168,7 +168,7 @@ if gajim.HAVE_GPG:
except IOError: pass
keyid = ''
if resp.has_key('GOODSIG'):
if 'GOODSIG' in resp:
keyid = resp['GOODSIG'].split()[0]
return keyid

View File

@ -342,14 +342,14 @@ class GnuPG:
if attach_fhs is None: attach_fhs = {}
for std in _stds:
if not attach_fhs.has_key(std) \
if std not in attach_fhs \
and std not in create_fhs:
attach_fhs.setdefault(std, getattr(sys, std))
handle_passphrase = 0
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:
handle_passphrase = 1
create_fhs.append('passphrase')
@ -373,7 +373,7 @@ class GnuPG:
process = Process()
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, \
"unrecognized filehandle name '%s'; must be one of %s" \
% (fh_name, _fd_modes.keys())
@ -381,7 +381,7 @@ class GnuPG:
for fh_name in create_fhs:
# make sure the user doesn't specify a filehandle
# to be created *and* attached
if attach_fhs.has_key(fh_name):
if fh_name in attach_fhs:
raise ValueError, \
"cannot have filehandle '%s' in both create_fhs and attach_fhs" \
% 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'
or without rel attribute). '''
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:
return element.attrs['href']
except AttributeError:

View File

@ -166,7 +166,7 @@ def find_current_groupchats(account):
continue
room_jid = gc_control.room_jid
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]:
rooms.append((room_jid, nick,))
return rooms

View File

@ -518,7 +518,7 @@ class Config:
return None
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
return
opt = self.__options[optname]
@ -532,35 +532,35 @@ class Config:
def get(self, optname = None):
if not optname:
return self.__options.keys()
if not self.__options.has_key(optname):
if optname not in self.__options:
return None
return self.__options[optname][OPT_VAL]
def get_desc(self, optname):
if not self.__options.has_key(optname):
if optname not in self.__options:
return None
if len(self.__options[optname]) > OPT_DESC:
return self.__options[optname][OPT_DESC]
def get_restart(self, optname):
if not self.__options.has_key(optname):
if optname not in self.__options:
return None
if len(self.__options[optname]) > OPT_RESTART:
return self.__options[optname][OPT_RESTART]
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
return
opt = self.__options_per_key[typename]
if opt[1].has_key(name):
if name in opt[1]:
# we already have added group name before
return 'you already have added %s before' % name
opt[1][name] = copy.deepcopy(opt[0])
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
return
@ -568,21 +568,21 @@ class Config:
if subname is None:
del opt[1][name]
# 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]
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
return
if not key:
return
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)
self.add_per(optname, 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)
return
subobj = obj[subname]
@ -593,53 +593,53 @@ class Config:
subobj[OPT_VAL] = value
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
dict = self.__options_per_key[optname][1]
if not key:
return dict.keys()
if not dict.has_key(key):
if self.__options_per_key.has_key(optname) \
and self.__options_per_key[optname][0].has_key(subname):
if key not in dict:
if optname in self.__options_per_key \
and subname in self.__options_per_key[optname][0]:
return self.__options_per_key \
[optname][0][subname][1]
return None
obj = dict[key]
if not subname:
return obj
if not obj.has_key(subname):
if subname not in obj:
return None
return obj[subname][OPT_VAL]
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
dict = self.__options_per_key[optname][1]
if not key:
return None
if not dict.has_key(key):
if key not in dict:
return None
obj = dict[key]
if not subname:
return None
if not obj.has_key(subname):
if subname not in obj:
return None
if len(obj[subname]) > OPT_DESC:
return obj[subname][OPT_DESC]
return 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
dict = self.__options_per_key[optname][1]
if not key:
return False
if not dict.has_key(key):
if key not in dict:
return False
obj = dict[key]
if not subname:
return False
if not obj.has_key(subname):
if subname not in obj:
return False
if len(obj[subname]) > OPT_RESTART:
return obj[subname][OPT_RESTART]

View File

@ -181,7 +181,7 @@ class Connection(ConnectionHandlers):
# END __init__
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])
def dispatch(self, event, data):
@ -362,7 +362,7 @@ class Connection(ConnectionHandlers):
for child in data.getTag('query').getTag('list').getChildren():
dict_item = child.getAttrs()
childs = []
if dict_item.has_key('type'):
if 'type' in dict_item:
for scnd_child in child.getChildren():
childs += [scnd_child.getName()]
rules.append({'action':dict_item['action'],
@ -1322,9 +1322,9 @@ class Connection(ConnectionHandlers):
self.new_account_info['password'] = field.value
else:
# 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']
if form.has_key('password'):
if 'password' in form:
self.new_account_info['password'] = form['password']
self.new_account_form = form
self.new_account(self.name, self.new_account_info)
@ -1484,7 +1484,7 @@ class Connection(ConnectionHandlers):
for data in tags_list[tag]:
jid = data['jid']
dict_ = {'jid': jid, 'tag': tag}
if data.has_key('order'):
if 'order' in data:
dict_['order'] = data['order']
iq3.addChild(name = 'meta', attrs = dict_)
self.connection.send(iq)
@ -1530,7 +1530,7 @@ class Connection(ConnectionHandlers):
self.connection.send(p)
# 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
last_log = None
# Do not check if we are not logging for this room
@ -1644,7 +1644,7 @@ class Connection(ConnectionHandlers):
for jid in users_dict:
item_tag = item.addChild('item', {'jid': jid,
'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'])
self.connection.send(iq)

View File

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

View File

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

View File

@ -242,7 +242,7 @@ def get_contact_dict_for_account(account):
jid)
contacts_dict[jid] = contact
name = contact.name
if contacts_dict.has_key(name):
if name in contacts_dict:
contact1 = contacts_dict[name]
del contacts_dict[name]
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,
contact.get_full_jid()):
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.\
minimized_controls[account][contact.jid].get_nb_unread_pm() > 0:
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]:
return 'muc_active'
else:
@ -787,7 +787,7 @@ def get_os_info():
(2, 5, 2): '2003',
(2, 6, 0): 'Vista',
}
if win_version.has_key(ver_format):
if ver_format in win_version:
return 'Windows' + ' ' + win_version[ver_format]
else:
return 'Windows'
@ -1175,7 +1175,7 @@ def prepare_and_validate_gpg_keyID(account, jid, keyID):
elif keyID:
public_keys = gajim.connections[account].ask_gpg_keys()
# 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):
u.keyID = keyID
keys_str = gajim.config.get_per('accounts', account, 'attached_gpg_keys')
@ -1192,11 +1192,11 @@ def sort_identities_func(i1, i2):
return -1
if cat1 > cat2:
return 1
if i1.has_key('type'):
if 'type' in i1:
type1 = i1['type']
else:
type1 = ''
if i2.has_key('type'):
if 'type' in i2:
type2 = i2['type']
else:
type2 = ''
@ -1204,11 +1204,11 @@ def sort_identities_func(i1, i2):
return -1
if type1 > type2:
return 1
if i1.has_key('xml:lang'):
if 'xml:lang' in i1:
lang1 = i1['xml:lang']
else:
lang1 = ''
if i2.has_key('xml:lang'):
if 'xml:lang' in i2:
lang2 = i2['xml:lang']
else:
lang2 = ''
@ -1234,15 +1234,15 @@ def compute_caps_hash(identities, features, dataforms=[], hash_method='sha-1'):
identities.sort(cmp=sort_identities_func)
for i in identities:
c = i['category']
if i.has_key('type'):
if 'type' in i:
type_ = i['type']
else:
type_ = ''
if i.has_key('xml:lang'):
if 'xml:lang' in i:
lang = i['xml:lang']
else:
lang = ''
if i.has_key('name'):
if 'name' in i:
name = i['name']
else:
name = ''

View File

@ -150,9 +150,9 @@ class Resolver:
result_list = self.parse_srv_result(host, result)
# 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
if self.handlers.has_key(host):
if host in self.handlers:
for callback in self.handlers[host]:
callback(host, result_list)
del(self.handlers[host])
@ -169,11 +169,11 @@ class Resolver:
# empty host, return empty list of srv records
on_ready([])
return
if self.resolved_hosts.has_key(host):
if host in self.resolved_hosts:
# host is already resolved, return cached values
on_ready(host, self.resolved_hosts[host])
return
if self.handlers.has_key(host):
if host in self.handlers:
# host is about to be resolved by another connection,
# attach our callback
self.handlers[host].append(on_ready)

View File

@ -199,14 +199,14 @@ class OptionsParser:
def update_config_x_to_09(self):
# Var name that changed:
# 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'])
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'])
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'])
# 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',
self.old_values['always_compact_view'])
gajim.config.set('always_compact_view_gc',
@ -269,19 +269,19 @@ class OptionsParser:
con.close()
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']:
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:
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']:
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':
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':
gajim.config.set('always_hide_groupchat_buttons', True)
@ -306,14 +306,14 @@ class OptionsParser:
gajim.config.set('version', '0.10')
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):
gajim.config.set('print_status_in_muc', 'in_and_out')
gajim.config.set('version', '0.10.1.1')
def update_config_to_01012(self):
# 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':
gajim.config.set('emoticons_theme', '')
gajim.config.set('version', '0.10.1.2')
@ -387,7 +387,7 @@ class OptionsParser:
def update_config_to_01016(self):
'''#2494 : Now we play gc_received_message sound even if
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 \
gajim.config.get_per('soundevents', 'muc_message_received', 'enabled'):
gajim.config.set_per('soundevents',\
@ -397,43 +397,43 @@ class OptionsParser:
def update_config_to_01017(self):
'''trayicon_notification_on_new_messages ->
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',
self.old_values['trayicon_notification_on_new_messages'])
gajim.config.set('version', '0.10.1.7')
def update_config_to_01018(self):
'''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',
self.old_values['chat_state_notifications'])
gajim.config.set('version', '0.10.1.8')
def update_config_to_01101(self):
'''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 ' % (
self.old_values['before_time'], self.old_values['after_time']))
gajim.config.set('version', '0.11.0.1')
def update_config_to_01102(self):
'''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',
self.old_values['ft_override_host_to_send'])
gajim.config.set('version', '0.11.0.2')
def update_config_to_01111(self):
'''always_hide_chatbuttons -> compact_view'''
if self.old_values.has_key('always_hide_groupchat_buttons') and \
self.old_values.has_key('always_hide_chat_buttons'):
if 'always_hide_groupchat_buttons' in self.old_values and \
'always_hide_chat_buttons' in self.old_values:
gajim.config.set('compact_view', self.old_values['always_hide_groupchat_buttons'] and \
self.old_values['always_hide_chat_buttons'])
gajim.config.set('version', '0.11.1.1')
def update_config_to_01112(self):
'''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+':
gajim.config.set('roster_theme', _('default'))
gajim.config.set('version', '0.11.1.2')

View File

@ -101,7 +101,7 @@ class GnomePasswordStorage(PasswordStorage):
return
token = 'gnomekeyring:%i' % auth_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
storage = None

View File

@ -155,35 +155,35 @@ def user_mood(items, name, jid):
if jid == gajim.get_jid_from_account(name):
acc = gajim.connections[name]
if has_child:
if acc.mood.has_key('mood'):
if 'mood' in acc.mood:
del acc.mood['mood']
if acc.mood.has_key('text'):
if 'text' in acc.mood:
del acc.mood['text']
if mood is not None:
acc.mood['mood'] = mood
if text is not None:
acc.mood['text'] = text
elif retract:
if acc.mood.has_key('mood'):
if 'mood' in acc.mood:
del acc.mood['mood']
if acc.mood.has_key('text'):
if 'text' in acc.mood:
del acc.mood['text']
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
for contact in gajim.contacts.get_contacts(name, user):
if has_child:
if contact.mood.has_key('mood'):
if 'mood' in contact.mood:
del contact.mood['mood']
if contact.mood.has_key('text'):
if 'text' in contact.mood:
del contact.mood['text']
if mood is not None:
contact.mood['mood'] = mood
if text is not None:
contact.mood['text'] = text
elif retract:
if contact.mood.has_key('mood'):
if 'mood' in contact.mood:
del contact.mood['mood']
if contact.mood.has_key('text'):
if 'text' in contact.mood:
del contact.mood['text']
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):
acc = gajim.connections[name]
if has_child:
if acc.tune.has_key('artist'):
if 'artist' in acc.tune:
del acc.tune['artist']
if acc.tune.has_key('title'):
if 'title' in acc.tune:
del acc.tune['title']
if acc.tune.has_key('source'):
if 'source' in acc.tune:
del acc.tune['source']
if acc.tune.has_key('track'):
if 'track' in acc.tune:
del acc.tune['track']
if acc.tune.has_key('length'):
if 'length' in acc.tune:
del acc.tune['length']
if artist is not None:
acc.tune['artist'] = artist
@ -244,29 +244,29 @@ def user_tune(items, name, jid):
if length is not None:
acc.tune['length'] = length
elif retract:
if acc.tune.has_key('artist'):
if 'artist' in acc.tune:
del acc.tune['artist']
if acc.tune.has_key('title'):
if 'title' in acc.tune:
del acc.tune['title']
if acc.tune.has_key('source'):
if 'source' in acc.tune:
del acc.tune['source']
if acc.tune.has_key('track'):
if 'track' in acc.tune:
del acc.tune['track']
if acc.tune.has_key('length'):
if 'length' in acc.tune:
del acc.tune['length']
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
for contact in gajim.contacts.get_contacts(name, user):
if has_child:
if contact.tune.has_key('artist'):
if 'artist' in contact.tune:
del contact.tune['artist']
if contact.tune.has_key('title'):
if 'title' in contact.tune:
del contact.tune['title']
if contact.tune.has_key('source'):
if 'source' in contact.tune:
del contact.tune['source']
if contact.tune.has_key('track'):
if 'track' in contact.tune:
del contact.tune['track']
if contact.tune.has_key('length'):
if 'length' in contact.tune:
del contact.tune['length']
if artist is not None:
contact.tune['artist'] = artist
@ -279,15 +279,15 @@ def user_tune(items, name, jid):
if length is not None:
contact.tune['length'] = length
elif retract:
if contact.tune.has_key('artist'):
if 'artist' in contact.tune:
del contact.tune['artist']
if contact.tune.has_key('title'):
if 'title' in contact.tune:
del contact.tune['title']
if contact.tune.has_key('source'):
if 'source' in contact.tune:
del contact.tune['source']
if contact.tune.has_key('track'):
if 'track' in contact.tune:
del contact.tune['track']
if contact.tune.has_key('length'):
if 'length' in contact.tune:
del contact.tune['length']
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):
acc = gajim.connections[name]
if has_child:
if acc.activity.has_key('activity'):
if 'activity' in acc.activity:
del acc.activity['activity']
if acc.activity.has_key('subactivity'):
if 'subactivity' in acc.activity:
del acc.activity['subactivity']
if acc.activity.has_key('text'):
if 'text' in acc.activity:
del acc.activity['text']
if activity is not None:
acc.activity['activity'] = activity
@ -337,21 +337,21 @@ def user_activity(items, name, jid):
if text is not None:
acc.activity['text'] = text
elif retract:
if acc.activity.has_key('activity'):
if 'activity' in acc.activity:
del acc.activity['activity']
if acc.activity.has_key('subactivity'):
if 'subactivity' in acc.activity:
del acc.activity['subactivity']
if acc.activity.has_key('text'):
if 'text' in acc.activity:
del acc.activity['text']
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
for contact in gajim.contacts.get_contacts(name, user):
if has_child:
if contact.activity.has_key('activity'):
if 'activity' in contact.activity:
del contact.activity['activity']
if contact.activity.has_key('subactivity'):
if 'subactivity' in contact.activity:
del contact.activity['subactivity']
if contact.activity.has_key('text'):
if 'text' in contact.activity:
del contact.activity['text']
if activity is not None:
contact.activity['activity'] = activity
@ -360,11 +360,11 @@ def user_activity(items, name, jid):
if text is not None:
contact.activity['text'] = text
elif retract:
if contact.activity.has_key('activity'):
if 'activity' in contact.activity:
del contact.activity['activity']
if contact.activity.has_key('subactivity'):
if 'subactivity' in contact.activity:
del contact.activity['subactivity']
if contact.activity.has_key('text'):
if 'text' in contact.activity:
del contact.activity['text']
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):
''' start '''
if self.proxies.has_key(proxy):
if proxy in self.proxies:
resolver = self.proxies[proxy]
else:
# proxy is being ressolved for the first time
@ -68,7 +68,7 @@ class Proxy65Manager:
resolver.disconnect(connection)
def resolve_result(self, proxy, query):
if not self.proxies.has_key(proxy):
if proxy not in self.proxies:
return
jid = None
for item in query.getChildren():
@ -88,11 +88,11 @@ class Proxy65Manager:
break
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]
def get_proxy(self, proxy, account):
if self.proxies.has_key(proxy):
if proxy in self.proxies:
resolver = self.proxies[proxy]
if resolver.state == S_FINISHED:
return (resolver.host, resolver.port, resolver.jid)

View File

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

View File

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

View File

@ -100,7 +100,7 @@ class SASL(PlugIn):
self.on_sasl = on_sasl
self.realm = None
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'
elif self._owner.Dispatcher.Stream.features:
try:
@ -212,9 +212,9 @@ class SASL(PlugIn):
payload=response).__str__())
raise NodeProcessed
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']
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'])):
resp={}
@ -248,7 +248,7 @@ class SASL(PlugIn):
node=Node('response', attrs={'xmlns':NS_SASL},
payload=[base64.encodestring(sasl_data[:-1]).replace('\r','').replace('\n','')])
self._owner.send(node.__str__())
elif chal.has_key('rspauth'):
elif 'rspauth' in chal:
self._owner.send(Node('response', attrs={'xmlns':NS_SASL}).__str__())
else:
self.startsasl='failure'

View File

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

View File

@ -62,15 +62,15 @@ class PlugIn:
if self.DBG_LINE not in owner.debug_flags:
owner.debug_flags.append(self.DBG_LINE)
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')
self._old_owners_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__])
owner.__dict__[method.__name__]=method
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):
""" 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._old_owners_methods: self._owner.__dict__[method.__name__]=method
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
def DEBUG(self,text,severity='info'):
@ -130,7 +130,7 @@ class CommonClient:
self.disconnect_handlers.reverse()
for i in self.disconnect_handlers: i()
self.disconnect_handlers.reverse()
if self.__dict__.has_key('TLS'): self.TLS.PlugOut()
if 'TLS' in self.__dict__: self.TLS.PlugOut()
def DisconnectHandler(self):
""" 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. """
handlerssave=self.Dispatcher.dumpHandlers()
self.Dispatcher.PlugOut()
if self.__dict__.has_key('NonSASL'): self.NonSASL.PlugOut()
if self.__dict__.has_key('SASL'): self.SASL.PlugOut()
if self.__dict__.has_key('TLS'): self.TLS.PlugOut()
if self.__dict__.has_key('HTTPPROXYsocket'): self.HTTPPROXYsocket.PlugOut()
if self.__dict__.has_key('TCPsocket'): self.TCPsocket.PlugOut()
if 'NonSASL' in self.__dict__: self.NonSASL.PlugOut()
if 'SASL' in self.__dict__: self.SASL.PlugOut()
if 'TLS' in self.__dict__: self.TLS.PlugOut()
if 'HTTPPROXYsocket' in self.__dict__: self.HTTPPROXYsocket.PlugOut()
if 'TCPsocket' in self.__dict__: self.TCPsocket.PlugOut()
if not self.connect(server=self._Server,proxy=self._Proxy): return
if not self.auth(self._User,self._Password,self._Resource): return
self.Dispatcher.restoreHandlers(handlerssave)
@ -188,7 +188,7 @@ class CommonClient:
dispatcher.Dispatcher().PlugIn(self)
while self.Dispatcher.Stream._document_attrs is None:
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
return self.connected
@ -205,7 +205,7 @@ class Client(CommonClient):
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
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
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
@ -218,7 +218,7 @@ class Client(CommonClient):
random one or library name used. """
self._User,self._Password,self._Resource=user,password,resource
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
if sasl: auth.SASL(user,password).PlugIn(self)
if not sasl or self.SASL.startsasl=='not-supported':
@ -238,7 +238,7 @@ class Client(CommonClient):
def initRoster(self):
""" 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):
""" 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')
for i in reversed(self.disconnect_handlers):
i()
if self.__dict__.has_key('NonBlockingRoster'):
if 'NonBlockingRoster' in self.__dict__:
self.NonBlockingRoster.PlugOut()
if self.__dict__.has_key('NonBlockingBind'):
if 'NonBlockingBind' in self.__dict__:
self.NonBlockingBind.PlugOut()
if self.__dict__.has_key('NonBlockingNonSASL'):
if 'NonBlockingNonSASL' in self.__dict__:
self.NonBlockingNonSASL.PlugOut()
if self.__dict__.has_key('SASL'):
if 'SASL' in self.__dict__:
self.SASL.PlugOut()
if self.__dict__.has_key('NonBlockingTLS'):
if 'NonBlockingTLS' in self.__dict__:
self.NonBlockingTLS.PlugOut()
if self.__dict__.has_key('NBHTTPPROXYsocket'):
if 'NBHTTPPROXYsocket' in self.__dict__:
self.NBHTTPPROXYsocket.PlugOut()
if self.__dict__.has_key('NBSOCKS5PROXYsocket'):
if 'NBSOCKS5PROXYsocket' in self.__dict__:
self.NBSOCKS5PROXYsocket.PlugOut()
if self.__dict__.has_key('NonBlockingTcp'):
if 'NonBlockingTcp' in self.__dict__:
self.NonBlockingTcp.PlugOut()
def reconnectAndReauth(self):
@ -106,7 +106,7 @@ class NBCommonClient(CommonClient):
self._Server, self._Proxy, self._Ssl = server , proxy, ssl
self.on_stream_start = on_stream_start
if proxy:
if proxy.has_key('type'):
if 'type' in proxy:
type_ = proxy['type']
if type_ == 'socks5':
self.socket = transports_nb.NBSOCKS5PROXYsocket(
@ -164,7 +164,7 @@ class NBCommonClient(CommonClient):
self.Dispatcher.Stream._document_attrs is None:
return
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.onreceive(self._on_receive_stream_features)
return
@ -219,7 +219,7 @@ class NonBlockingClient(NBCommonClient):
transports_nb.NonBlockingTLS().PlugIn(self)
if not self.Connection: # ssl error, stream is closed
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':
self._is_connected()
return
@ -273,7 +273,7 @@ class NonBlockingClient(NBCommonClient):
def _on_start_sasl(self, data=None):
if data:
self.Dispatcher.ProcessNonBlocking(data)
if not self.__dict__.has_key('SASL'):
if 'SASL' not in self.__dict__:
# SASL is pluged out, possible disconnect
return
if self.SASL.startsasl == 'in-process':
@ -307,13 +307,13 @@ class NonBlockingClient(NBCommonClient):
def initRoster(self):
''' Plug in the roster. '''
if not self.__dict__.has_key('NonBlockingRoster'):
if 'NonBlockingRoster' not in self.__dict__:
roster_nb.NonBlockingRoster().PlugIn(self)
def getRoster(self, on_ready = None):
''' Return the Roster instance, previously plugging it in and
requesting roster from server if needed. '''
if self.__dict__.has_key('NonBlockingRoster'):
if 'NonBlockingRoster' in self.__dict__:
return self.NonBlockingRoster.getRoster(on_ready)
return None

View File

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

View File

@ -46,7 +46,7 @@ import os
import types
if os.environ.has_key('TERM'):
if 'TERM' in os.environ:
colors_enabled=True
else:
colors_enabled=False
@ -377,10 +377,10 @@ class Debug:
def Show(self, flag, msg, prefix=''):
msg=msg.replace('\r','\\r').replace('\n','\\n').replace('><','>\n <')
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
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
if prefix=='error':

View File

@ -175,9 +175,9 @@ class Dispatcher(PlugIn):
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')
if not typ and not ns: typ='default'
if not self.handlers.has_key(xmlns): self.RegisterNamespace(xmlns,'warn')
if not self.handlers[xmlns].has_key(name): self.RegisterProtocol(name,Protocol,xmlns,'warn')
if not self.handlers[xmlns][name].has_key(typ+ns): self.handlers[xmlns][name][typ+ns]=[]
if xmlns not in self.handlers: self.RegisterNamespace(xmlns,'warn')
if name not in self.handlers[xmlns]: self.RegisterProtocol(name,Protocol,xmlns,'warn')
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})
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."""
if not xmlns: xmlns=self._owner.defaultNamespace
if not typ and not ns: typ='default'
if not self.handlers[xmlns].has_key(name): return
if not self.handlers[xmlns][name].has_key(typ+ns): return
if name not in self.handlers[xmlns]: return
if typ+ns not in self.handlers[xmlns][name]: return
for pack in self.handlers[xmlns][name][typ+ns]:
if handler==pack['func']: break
else: pack=None
@ -264,10 +264,10 @@ class Dispatcher(PlugIn):
if name=='features': session.Stream.features=stanza
xmlns=stanza.getNamespace()
if not self.handlers.has_key(xmlns):
if xmlns not in self.handlers:
self.DEBUG("Unknown namespace: " + xmlns,'warn')
xmlns='unknown'
if not self.handlers[xmlns].has_key(name):
if name not in self.handlers[xmlns]:
self.DEBUG("Unknown stanza: " + name,'warn')
name='unknown'
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')
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:
if self.handlers[xmlns][name].has_key(prop): list.append(prop)
if typ and self.handlers[xmlns][name].has_key(typ+prop): list.append(typ+prop) # ...to very particular
if prop in self.handlers[xmlns][name]: list.append(prop)
if typ and typ+prop in self.handlers[xmlns][name]: list.append(typ+prop) # ...to very particular
chain=self.handlers[xmlns]['default']['default']
for key in list:
if key: chain = chain + self.handlers[xmlns][name][key]
output=''
if session._expected.has_key(ID):
if ID in session._expected:
user=0
if type(session._expected[ID])==type(()):
cb,args=session._expected[ID]

View File

@ -193,11 +193,11 @@ class Dispatcher(PlugIn):
(handler, name, typ, ns, xmlns), 'info')
if not typ and not ns:
typ='default'
if not self.handlers.has_key(xmlns):
if xmlns not in self.handlers:
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')
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]=[]
if makefirst:
self.handlers[xmlns][name][typ+ns].insert(0,{'func':handler,'system':system})
@ -216,11 +216,11 @@ class Dispatcher(PlugIn):
xmlns=self._owner.defaultNamespace
if not typ and not ns:
typ='default'
if not self.handlers.has_key(xmlns):
if xmlns not in self.handlers:
return
if not self.handlers[xmlns].has_key(name):
if name not in self.handlers[xmlns]:
return
if not self.handlers[xmlns][name].has_key(typ+ns):
if typ+ns not in self.handlers[xmlns][name]:
return
for pack in self.handlers[xmlns][name][typ+ns]:
if handler==pack['func']:
@ -306,10 +306,10 @@ class Dispatcher(PlugIn):
session.Stream.features=stanza
xmlns=stanza.getNamespace()
if not self.handlers.has_key(xmlns):
if xmlns not in self.handlers:
self.DEBUG("Unknown namespace: " + xmlns, 'warn')
xmlns='unknown'
if not self.handlers[xmlns].has_key(name):
if name not in self.handlers[xmlns]:
self.DEBUG("Unknown stanza: " + name, 'warn')
name='unknown'
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')
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:
if self.handlers[xmlns][name].has_key(prop): list.append(prop)
if typ and self.handlers[xmlns][name].has_key(typ+prop): list.append(typ+prop) # ...to very particular
if prop in self.handlers[xmlns][name]: list.append(prop)
if typ and typ+prop in self.handlers[xmlns][name]: list.append(typ+prop) # ...to very particular
chain=self.handlers[xmlns]['default']['default']
for key in list:
if key: chain = chain + self.handlers[xmlns][name][key]
output=''
if session._expected.has_key(ID):
if ID in session._expected:
user=0
if type(session._expected[ID]) == type(()):
cb,args = session._expected[ID]
@ -372,7 +372,7 @@ class Dispatcher(PlugIn):
self._owner.remove_timeout()
if self._expected[self._witid] is None:
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
self._owner.onreceive(None)
resp, args = self.on_responses[self._witid]

View File

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

View File

@ -53,14 +53,14 @@ class IdleQueue:
self.selector = select.poll()
def remove_timeout(self, fd):
if self.read_timeouts.has_key(fd):
if fd in self.read_timeouts:
del(self.read_timeouts[fd])
def set_alarm(self, alarm_cb, seconds):
''' set up a new alarm, to be called after alarm_cb sec. '''
alarm_time = self.current_time() + seconds
# 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)
else:
self.alarms[alarm_time] = [alarm_cb]
@ -76,7 +76,7 @@ class IdleQueue:
for fd, timeout in self.read_timeouts.items():
if timeout > current_time:
continue
if self.queue.has_key(fd):
if fd in self.queue:
self.queue[fd].read_timeout()
else:
self.remove_timeout(fd)
@ -91,7 +91,7 @@ class IdleQueue:
def plug_idle(self, obj, writable = True, readable = True):
if obj.fd == -1:
return
if self.queue.has_key(obj.fd):
if obj.fd in self.queue:
self.unplug_idle(obj.fd)
self.queue[obj.fd] = obj
if writable:
@ -111,7 +111,7 @@ class IdleQueue:
self.selector.register(fd, flags)
def unplug_idle(self, fd):
if self.queue.has_key(fd):
if fd in self.queue:
del(self.queue[fd])
self.remove_idle(fd)
@ -187,11 +187,11 @@ class SelectIdleQueue(IdleQueue):
''' this method is called when we unplug a new idle object.
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])
if self.write_fds.has_key(fd):
if fd in self.write_fds:
del(self.write_fds[fd])
if self.error_fds.has_key(fd):
if fd in self.error_fds:
del(self.error_fds[fd])
def process(self):

View File

@ -321,7 +321,7 @@ class Protocol(Node):
if not node and xmlns: self.setNamespace(xmlns)
if self['to']: self.setTo(self['to'])
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
for d in self.getTags('delay',namespace=NS_DELAY2):
try:
@ -598,7 +598,7 @@ class ErrorNode(Node):
""" Create new error node object.
Mandatory parameter: name - name of error condition.
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]
ns=name.split()[0]
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'):
jid=item.getAttr('jid')
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
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]['ask']=item.getAttr('ask')
self._data[jid]['subscription']=item.getAttr('subscription')
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())
self._data[self._owner.User+'@'+self._owner.Server]={'resources':{},'name':None,'ask':None,'subscription':None,'groups':None,}
self.set=1
@ -92,7 +92,7 @@ class Roster(PlugIn):
# If no from attribue, it's from server
jid=self._owner.Server
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()):
self._data[jid.getStripped()]['resources']={}
item=self._data[jid.getStripped()]
@ -106,7 +106,7 @@ class Roster(PlugIn):
if pres.getTag('priority'): res['priority']=pres.getPriority()
if not pres.getTimestamp(): pres.setTimestamp()
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
def _getItemData(self,jid,dataname):
@ -117,7 +117,7 @@ class Roster(PlugIn):
""" Return specific jid's resource representation in internal format. Used internally. """
if jid.find('/')+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():
lastpri=-129
for r in self._data[jid]['resources'].keys():
@ -176,7 +176,7 @@ class Roster(PlugIn):
return self._data[item]
def getItem(self,item):
""" 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):
""" Send subscription request to JID 'jid'."""
self._owner.send(Presence(jid,'subscribe'))

View File

@ -213,10 +213,10 @@ class Session:
def _catch_stream_id(self,ns=None,tag='stream',attrs={}):
""" 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)
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={}):
""" This callback is used to handle opening stream tag of the incoming stream.
@ -228,23 +228,23 @@ class Session:
text+=' to="%s"'%self.peer
else:
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']
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
else: xmlns=NS_SERVER
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.set_stream_state(STREAM__OPENED)
if self.TYP=='client': return
if tag<>'stream': return self.terminate_stream(STREAM_INVALID_XML)
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 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)
self.ourname=attrs['to'].lower()
if self.TYP=='server' and attrs.has_key('version'):
if self.TYP=='server' and 'version' in attrs:
# send features
features=Node('stream: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 node.getName() == name:
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)
if one and nodes: return nodes[0]
if not one: return nodes
@ -228,7 +228,7 @@ class Node(object):
if namespace is not None and namespace!=node.getNamespace(): continue
if node.getName() == name:
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
else:
yield node
@ -273,7 +273,7 @@ class Node(object):
except: self.addChild(tag,attrs,payload=[ustr(val)])
def has_attr(self,key):
""" Checks if node have attribute "key"."""
return self.attrs.has_key(key)
return key in self.attrs
def __getitem__(self,item):
""" Returns node's attribute "item" value. """
return self.getAttr(item)

View File

@ -194,7 +194,7 @@ class HTTPPROXYsocket(TCPsocket):
'Pragma: no-cache',
'Host: %s:%s'%self._server,
'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 = base64.encodestring(credentials).strip()
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
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)
DBG_LINE='TLS'
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
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.
PlugIn.PlugIn(self, owner)
DBG_LINE='NonBlockingTLS'
@ -704,7 +704,7 @@ class NonBlockingTLS(PlugIn):
''' 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.'''
# 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.Dispatcher.PlugOut()
self._owner = None
@ -906,7 +906,7 @@ class NBHTTPPROXYsocket(NonBlockingTcp):
'Pragma: no-cache',
'Host: %s:%s'%self.server,
'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 = base64.encodestring(credentials).strip()
connector.append('Proxy-Authorization: Basic '+credentials)
@ -988,7 +988,7 @@ class NBSOCKS5PROXYsocket(NonBlockingTcp):
def _on_tcp_connect(self):
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'
else:
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('size', file_props['size'])
desc = file_tag.setTag('desc')
if file_props.has_key('desc'):
if 'desc' in file_props:
desc.setData(file_props['desc'])
file_tag.setTag('range')
feature = si.setTag('feature')
@ -180,11 +180,11 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
host_dict[attr] = item.getAttr(attr)
streamhosts.append(host_dict)
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['fast'] = streamhosts
if file_props['type'] == 's':
if file_props.has_key('streamhosts'):
if 'streamhosts' in file_props:
file_props['streamhosts'].extend(streamhosts)
else:
file_props['streamhosts'] = streamhosts
@ -209,11 +209,11 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
return
frm = unicode(iq_obj.getFrom())
id = real_id[3:]
if self.files_props.has_key(id):
if id in self.files_props:
file_props = self.files_props[id]
if file_props['streamhost-used']:
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'])
raise common.xmpp.NodeProcessed
@ -229,7 +229,7 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
except: # this bytestream result is not what we need
pass
id = real_id[3:]
if self.files_props.has_key(id):
if id in self.files_props:
file_props = self.files_props[id]
else:
raise common.xmpp.NodeProcessed
@ -237,10 +237,10 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
# proxy approves the activate query
if real_id[:3] == 'au_':
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:
raise common.xmpp.NodeProcessed
if not file_props.has_key('proxyhosts'):
if 'proxyhosts' not in file_props:
raise common.xmpp.NodeProcessed
for host in file_props['proxyhosts']:
if host['initiator'] == frm and \
@ -249,7 +249,7 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
break
raise common.xmpp.NodeProcessed
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:
raise common.xmpp.NodeProcessed
@ -258,14 +258,14 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
raise common.xmpp.NodeProcessed
proxy = None
if file_props.has_key('proxyhosts'):
if 'proxyhosts' in file_props:
for proxyhost in file_props['proxyhosts']:
if proxyhost['jid'] == jid:
proxy = proxyhost
if proxy != None:
file_props['streamhost-used'] = True
if not file_props.has_key('streamhosts'):
if 'streamhosts' not in file_props:
file_props['streamhosts'] = []
file_props['streamhosts'].append(proxy)
file_props['is_a_proxy'] = True
@ -277,7 +277,7 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
else:
gajim.socks5queue.send_file(file_props, self.name)
if file_props.has_key('fast'):
if 'fast' in file_props:
fasts = file_props['fast']
if len(fasts) > 0:
self._connect_error(frm, fasts[0]['id'], file_props['sid'],
@ -289,14 +289,14 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
gajim.log.debug('_siResultCB')
self.peerhost = con._owner.Connection._sock.getsockname()
id = iq_obj.getAttr('id')
if not self.files_props.has_key(id):
if id not in self.files_props:
# no such jid
return
file_props = self.files_props[id]
if file_props is None:
# file properties for jid is none
return
if file_props.has_key('request-id'):
if 'request-id' in file_props:
# we have already sent streamhosts info
return
file_props['receiver'] = unicode(iq_obj.getFrom())
@ -362,7 +362,7 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
if profile != common.xmpp.NS_FILE:
return
id = iq_obj.getAttr('id')
if not self.files_props.has_key(id):
if id not in self.files_props:
# no such jid
return
file_props = self.files_props[id]

View File

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

View File

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

View File

@ -243,7 +243,7 @@ class Zeroconf:
txt['txtvers'] = 1
# 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'])
else:
txt['status'] = 'avail'

View File

@ -1122,7 +1122,7 @@ class PreferencesWindow:
helpers.play_sound(snd_event_config_name)
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()
else:
gajim.interface.instances['advanced_config'] = \
@ -1165,7 +1165,7 @@ class ManageProxiesWindow:
self.xml.get_widget('proxytype_combobox').set_active(0)
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'].\
update_proxy_list()
del gajim.interface.instances['manage_proxies']
@ -1376,7 +1376,7 @@ class AccountsWindow:
def check_resend_relog(self):
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()
return
@ -1524,7 +1524,7 @@ class AccountsWindow:
# Personal tab
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:
self.xml.get_widget('gpg_choose_button2').set_sensitive(True)
self.init_account_gpg()
@ -1651,7 +1651,7 @@ class AccountsWindow:
def on_add_button_clicked(self, widget):
'''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()
else:
gajim.interface.instances['account_creation_wizard'] = \
@ -1683,7 +1683,7 @@ class AccountsWindow:
break
# Detect if we have opened windows for this 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.\
present()
else:
@ -1972,7 +1972,7 @@ class AccountsWindow:
gajim.config.set_per('accounts', self.current_account, 'proxy', proxy)
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()
else:
gajim.interface.instances['manage_proxies'] = ManageProxiesWindow()
@ -2026,7 +2026,7 @@ class AccountsWindow:
custom_port)
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:
secret_keys = gajim.connections[self.current_account].\
ask_gpg_secrete_keys()
@ -2085,14 +2085,14 @@ class AccountsWindow:
self.on_checkbutton_toggled(widget, 'use_gpg_agent')
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'),
_('You must create your account before editing your personal '
'information.'))
return
# 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:
dialogs.ErrorDialog(_('You are not connected to the server'),
_('Without a connection, you can not edit your personal information.'))
@ -2128,7 +2128,7 @@ class AccountsWindow:
def on_enable_zeroconf_checkbutton2_toggled(self, widget):
# don't do anything if there is an account with the local name but is a
# 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].dispatch('ERROR',
(_('Account Local already exists.'),
@ -2264,7 +2264,7 @@ class FakeDataForm(gtk.Table, object):
def _draw_table(self):
'''Draw the table'''
nbrow = 0
if self.infos.has_key('instructions'):
if 'instructions' in self.infos:
nbrow = 1
self.resize(rows = nbrow, columns = 2)
label = gtk.Label(self.infos['instructions'])
@ -2314,7 +2314,7 @@ class ServiceRegistrationWindow:
table = self.xml.get_widget('table')
table.attach(self.data_form_widget, 0, 2, 0, 1)
else:
if infos.has_key('registered'):
if 'registered' in infos:
self.window.set_title(_('Edit %s') % service)
else:
self.window.set_title(_('Register to %s') % service)
@ -2336,9 +2336,9 @@ class ServiceRegistrationWindow:
form, True) # True is for is_form
else:
infos = self.data_form_widget.get_infos()
if infos.has_key('instructions'):
if 'instructions' in infos:
del infos['instructions']
if infos.has_key('registered'):
if 'registered' in infos:
del infos['registered']
gajim.connections[self.account].register_agent(self.service, infos)
@ -2500,13 +2500,13 @@ class GroupchatConfigWindow:
tv = self.affiliation_treeview[affiliation]
model = tv.get_model()
reason = ''
if users_dict[jid].has_key('reason'):
if 'reason' in users_dict[jid]:
reason = users_dict[jid]['reason']
nick = ''
if users_dict[jid].has_key('nick'):
if 'nick' in users_dict[jid]:
nick = users_dict[jid]['nick']
role = ''
if users_dict[jid].has_key('role'):
if 'role' in users_dict[jid]:
role = users_dict[jid]['role']
model.append((jid, reason, nick, role))
@ -2527,8 +2527,8 @@ class GroupchatConfigWindow:
jid = model[iter][0].decode('utf-8')
actual_jid_list.append(jid)
if jid not in self.start_users_dict[affiliation] or \
(affiliation == 'outcast' and self.start_users_dict[affiliation]\
[jid].has_key('reason') and self.start_users_dict[affiliation][jid]\
(affiliation == 'outcast' and 'reason' in self.start_users_dict[affiliation]\
[jid] and self.start_users_dict[affiliation][jid]\
['reason'] != model[iter][1].decode('utf-8')):
users_dict[jid] = {'affiliation': affiliation}
if affiliation == 'outcast':
@ -2549,7 +2549,7 @@ class RemoveAccountWindow:
and do removing of the account given'''
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']
def on_cancel_button_clicked(self, widget):
@ -2635,7 +2635,7 @@ class RemoveAccountWindow:
gajim.interface.roster.regroup = False
gajim.interface.roster.setup_and_draw_roster()
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()
self.window.destroy()
@ -3231,7 +3231,7 @@ class AccountCreationWizardWindow:
proxies_combobox.set_active(0)
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()
else:
gajim.interface.instances['manage_proxies'] = \
@ -3341,7 +3341,7 @@ class AccountCreationWizardWindow:
gobject.source_remove(self.update_progressbar_timeout_id)
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()
else:
gajim.interface.instances['accounts'] = AccountsWindow()
@ -3462,7 +3462,7 @@ class AccountCreationWizardWindow:
gajim.gajim_optional_features[self.account] = []
gajim.caps_hash[self.account] = ''
# refresh accounts window
if gajim.interface.instances.has_key('accounts'):
if 'accounts' in gajim.interface.instances:
gajim.interface.instances['accounts'].init_accounts()
# refresh roster
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()
def show_xep0184_warning(self, id):
if self.xep0184_marks.has_key(id):
if id in self.xep0184_marks:
return
buffer = self.tv.get_buffer()
@ -444,7 +444,7 @@ class ConversationTextview:
buffer.end_user_action()
def hide_xep0184_warning(self, id):
if not self.xep0184_marks.has_key(id):
if id not in self.xep0184_marks:
return
if self.xep0184_shown[id] == NOT_SHOWN:

View File

@ -392,8 +392,7 @@ class ChangeActivityDialog:
if 'activity' in con.activity \
and con.activity['activity'] in pep.ACTIVITIES:
if 'subactivity' in con.activity \
and pep.ACTIVITIES[con.activity['activity']].has_key(
con.activity['subactivity']):
and con.activity['subactivity'] in pep.ACTIVITIES[con.activity['activity']]:
subactivity = con.activity['subactivity']
else:
subactivity = 'other'
@ -691,7 +690,7 @@ class AddNewContactWindow:
location = gajim.interface.instances[self.account]
else:
location = gajim.interface.instances
if location.has_key('add_contact'):
if 'add_contact' in location:
location['add_contact'].window.present()
# An instance is already opened
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)
if not type_:
continue
if self.agents.has_key(type_):
if type_ in self.agents:
self.agents[type_].append(j)
else:
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
imgs = gajim.interface.roster.transports_state_images
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']
if type_ in uf_type:
liststore.append([uf_type[type_], img.get_pixbuf(), type_])
@ -1620,7 +1619,7 @@ class SubscriptionRequestWindow:
def on_contact_info_activate(self, widget):
'''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()
else:
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)
return
if self.completion_dict.has_key(jid):
if jid in self.completion_dict:
jid = self.completion_dict[jid].jid
else:
try:
@ -2343,7 +2342,7 @@ class SingleMessageWindow:
sender_list = [self.to_entry.get_text().decode('utf-8')]
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
subject = self.subject_entry.get_text().decode('utf-8')
@ -2608,7 +2607,7 @@ class PrivacyListWindow:
self.list_of_rules_combobox.get_model().clear()
self.global_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'
', value: %(value)s') % {'order': rule['order'],
'action': rule['action'], 'type': rule['type'],
@ -2666,13 +2665,13 @@ class PrivacyListWindow:
if self.active_rule != '':
rule_info = self.global_rules[self.active_rule]
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':
self.edit_type_jabberid_radiobutton.set_active(True)
self.edit_type_jabberid_entry.set_text(rule_info['value'])
elif rule_info['type'] == 'group':
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.list_of_groups[rule_info['value']])
else:
@ -2915,7 +2914,7 @@ class PrivacyListsWindow:
_('You must enter a name to create a privacy list.'))
return
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()
else:
gajim.interface.instances[self.account][key_name] = \
@ -2929,8 +2928,7 @@ class PrivacyListsWindow:
name = self.privacy_lists_save[
self.list_of_privacy_lists_combobox.get_active()]
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()
else:
gajim.interface.instances[self.account][key_name] = \

View File

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

View File

@ -148,7 +148,7 @@ class FileTransfersWindow:
''' show a dialog saying that file (file_props) has been transferred'''
def on_open(widget, file_props):
dialog.destroy()
if not file_props.has_key('file-name'):
if 'file-name' not in file_props:
return
(path, file) = os.path.split(file_props['file-name'])
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):
''' show dialog asking for comfirmation and store location of new
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
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') % \
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']
if file_props.has_key('desc'):
if 'desc' in file_props:
sec_text += '\n\t' + _('Description: %s') % file_props['desc']
prim_text = _('%s wants to send you a file:') % contact.jid
dialog, dialog2 = None, None
@ -460,10 +460,10 @@ _('Connection with peer cannot be established.'))
def _remove_transfer(self, iter, sid, file_props):
self.model.remove(iter)
if file_props.has_key('tt_account'):
if 'tt_account' in file_props:
# file transfer is set
account = file_props['tt_account']
if gajim.connections.has_key(account):
if account in gajim.connections:
# there is a connection to the account
gajim.connections[account].remove_transfer(file_props)
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):
''' 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
file_props = self.files_props[typ][sid]
full_size = int(file_props['size'])
@ -509,7 +509,7 @@ _('Connection with peer cannot be established.'))
# Kb/s
# 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']
full_size -= file_props['offset']
@ -536,11 +536,11 @@ _('Connection with peer cannot be established.'))
status = 'download'
else:
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'
elif file_props.has_key('stalled') and file_props['stalled'] == True:
elif 'stalled' in file_props and file_props['stalled'] == True:
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'
self.model.set(iter, 0, self.images[status])
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,
file_props['type'] + file_props['sid'])
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'
elif file_props['type'] == 'r':
status = 'download'
@ -660,33 +660,33 @@ _('Connection with peer cannot be established.'))
self.on_open_folder_menuitem_activate(widget)
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
if file_props.has_key('completed') and file_props['completed']:
if 'completed' in file_props and file_props['completed']:
return False
if not file_props.has_key('disconnect_cb'):
if 'disconnect_cb' not in file_props:
return False
return file_props['paused']
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
if file_props.has_key('completed') and file_props['completed']:
if 'completed' in file_props and file_props['completed']:
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
if not file_props.has_key('paused'):
if 'paused' not in file_props:
return True
return not file_props['paused']
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
if file_props.has_key('completed') and file_props['completed']:
if 'completed' in file_props and file_props['completed']:
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
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 True
@ -831,10 +831,10 @@ _('Connection with peer cannot be established.'))
s_iter = selected[1]
sid = self.model[s_iter][C_SID].decode('utf-8')
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
account = file_props['tt_account']
if not gajim.connections.has_key(account):
if account not in gajim.connections:
return
gajim.connections[account].disconnect_transfer(file_props)
self.set_status(file_props['type'], file_props['sid'], 'stop')
@ -941,7 +941,7 @@ _('Connection with peer cannot be established.'))
s_iter = selected[1]
sid = self.model[s_iter][C_SID].decode('utf-8')
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
(path, file) = os.path.split(file_props['file-name'])
if os.path.exists(path) and os.path.isdir(path):

View File

@ -585,7 +585,7 @@ class Interface:
sid = id
if len(id) > 3 and id[2] == '_':
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['error'] = -4
self.handle_event_file_request_error(account,
@ -598,7 +598,7 @@ class Interface:
sid = id
if len(id) > 3 and id[2] == '_':
sid = id[3:]
if conn.files_props.has_key(sid):
if sid in conn.files_props:
file_props = conn.files_props[sid]
self.handle_event_file_send_error(account,
(jid_from, file_props))
@ -644,7 +644,7 @@ class Interface:
# Inform all controls for this account of the connection state change
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
ctrls += self.minimized_controls[account].values()
for ctrl in ctrls:
@ -667,7 +667,7 @@ class Interface:
def edit_own_details(self, 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'] = \
profile_window.ProfileWindow(account)
gajim.connections[account].request_vcard(jid)
@ -811,7 +811,7 @@ class Interface:
self.unblock_signed_in_notifications, account_ji)
locations = (self.instances, self.instances[account])
for location in locations:
if location.has_key('add_contact'):
if 'add_contact' in location:
if old_show == 0 and new_show > 1:
location['add_contact'].transport_signed_in(jid)
break
@ -1042,7 +1042,7 @@ class Interface:
def handle_event_register_agent_info(self, account, array):
# ('REGISTER_AGENT_INFO', account, (agent, infos, is_form))
# 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,
array[2])
else:
@ -1052,7 +1052,7 @@ class Interface:
def handle_event_agent_info_items(self, account, array):
#('AGENT_INFO_ITEMS', account, (agent, node, items))
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:
gajim.interface.instances[account]['pep_services'].items_received(
array[2])
@ -1073,18 +1073,18 @@ class Interface:
def handle_event_new_acc_connected(self, account, array):
#('NEW_ACC_CONNECTED', account, (infos, is_form, ssl_msg, ssl_err,
# 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],
array[1], array[2], array[3], array[4], array[5])
def handle_event_new_acc_not_connected(self, account, array):
#('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)
def handle_event_acc_ok(self, account, array):
#('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)
if self.remote_ctrl:
@ -1092,7 +1092,7 @@ class Interface:
def handle_event_acc_not_ok(self, account, array):
#('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)
def handle_event_quit(self, p1, p2):
@ -1100,17 +1100,17 @@ class Interface:
def handle_event_myvcard(self, account, array):
nick = ''
if array.has_key('NICKNAME') and array['NICKNAME']:
if 'NICKNAME' in array and 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']
if self.instances[account].has_key('profile'):
if 'profile' in self.instances[account]:
win = self.instances[account]['profile']
win.set_values(array)
if account in self.show_vcard_when_connect:
self.show_vcard_when_connect.remove(account)
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)
def handle_event_vcard(self, account, vcard):
@ -1118,16 +1118,16 @@ class Interface:
'''vcard holds the vcard data'''
jid = vcard['jid']
resource = ''
if vcard.has_key('resource'):
if 'resource' in vcard:
resource = vcard['resource']
fjid = jid + '/' + str(resource)
# vcard window
win = None
if self.instances[account]['infos'].has_key(jid):
if jid in self.instances[account]['infos']:
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]
if win:
win.set_values(vcard)
@ -1163,9 +1163,9 @@ class Interface:
# Ann error occured
return
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]]
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]]
if win:
c = gajim.contacts.get_contact(account, array[0], array[1])
@ -1180,9 +1180,9 @@ class Interface:
def handle_event_os_info(self, account, array):
#'OS_INFO' (account, (jid, resource, client_info, os_info))
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]]
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]]
if win:
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
room_jid = array[0].split('/')[0]
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
form = dataforms.ExtendForm(node = array[1])
for f in form.iter_fields():
@ -1339,14 +1339,14 @@ class Interface:
# invite contacts
# check if it is necessary to add <continue />
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
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']:
gajim.connections[account].send_invite(room_jid, jid,
continue_tag=continue_tag)
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] = \
config.GroupchatConfigWindow(account, room_jid, array[1])
@ -1397,7 +1397,7 @@ class Interface:
def handle_event_gc_affiliation(self, account, array):
#('GC_AFFILIATION', account, (room_jid, users_dict))
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].\
affiliation_list_received(array[1])
@ -1445,7 +1445,7 @@ class Interface:
event_type, room_jid)
def forget_gpg_passphrase(self, keyid):
if self.gpg_passphrase.has_key(keyid):
if keyid in self.gpg_passphrase:
del self.gpg_passphrase[keyid]
return False
@ -1670,8 +1670,8 @@ class Interface:
file_props['received-len'])
else:
ft.set_status(file_props['type'], file_props['sid'], 'stop')
if file_props.has_key('stalled') and file_props['stalled'] or \
file_props.has_key('paused') and file_props['paused']:
if 'stalled' in file_props and file_props['stalled'] or \
'paused' in file_props and file_props['paused']:
return
if file_props['type'] == 'r': # we receive a file
jid = unicode(file_props['sender'])
@ -1752,19 +1752,19 @@ class Interface:
title = event_type, text = txt)
def handle_event_stanza_arrived(self, account, stanza):
if not self.instances.has_key(account):
if account not in self.instances:
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')
def handle_event_stanza_sent(self, account, stanza):
if not self.instances.has_key(account):
if account not in self.instances:
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')
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.vcard_published()
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)
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.vcard_not_published()
@ -1802,12 +1802,12 @@ class Interface:
if account != gc_control.account:
continue
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]:
continue
nick = gc_control.nick
password = ''
if gajim.gc_passwords.has_key(room_jid):
if room_jid in gajim.gc_passwords:
password = gajim.gc_passwords[room_jid]
gajim.connections[account].join_gc(nick, room_jid, password)
@ -1840,18 +1840,18 @@ class Interface:
def handle_event_privacy_lists_received(self, account, data):
# ('PRIVACY_LISTS_RECEIVED', account, list)
if not self.instances.has_key(account):
if account not in self.instances:
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)
def handle_event_privacy_list_received(self, account, data):
# ('PRIVACY_LISTS_RECEIVED', account, (name, rules))
if not self.instances.has_key(account):
if account not in self.instances:
return
name = data[0]
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].\
privacy_list_received(rules)
if name == 'block':
@ -1870,7 +1870,7 @@ class Interface:
# self.global_rules.append(rule)
#else:
# 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'].\
privacy_list_received(rules)
@ -1884,9 +1884,9 @@ class Interface:
def handle_event_privacy_list_removed(self, account, name):
# ('PRIVACY_LISTS_REMOVED', account, name)
if not self.instances.has_key(account):
if account not in self.instances:
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)
def handle_event_zc_name_conflict(self, account, data):
@ -1939,14 +1939,14 @@ class Interface:
def handle_event_search_form(self, account, data):
# ('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
self.instances[account]['search'][data[0]].on_form_arrived(data[1],
data[2])
def handle_event_search_result(self, account, data):
# ('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
self.instances[account]['search'][data[0]].on_result_arrived(data[1],
data[2])
@ -1966,7 +1966,7 @@ class Interface:
def handle_event_pep_config(self, account, data):
# ('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])
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):
# ('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):
self.instances[account]['pep_services'].node_removed(data[1])
@ -2776,7 +2776,7 @@ class Interface:
return False # stop looping in vain
state = self.sleeper.getState()
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]:
continue
if state == common.sleepy.STATE_AWAKE and \
@ -3194,7 +3194,7 @@ class Interface:
# Don't go auto away if user disabled the option
return
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]:
continue
if gajim.sleeper_state[account] == 'online':

View File

@ -81,7 +81,7 @@ class GajimThemesWindow:
return True # do NOT destroy the window
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()
self.window.hide()

View File

@ -120,7 +120,7 @@ class PrivateChatControl(ChatControl):
def __init__(self, parent_win, gc_contact, contact, account, session):
room_jid = contact.jid.split('/')[0]
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]
self.room_name = room_ctrl.name
self.gc_contact = gc_contact
@ -555,12 +555,12 @@ class GroupchatControl(ChatControlBase):
def _update_banner_state_image(self):
banner_status_img = self.xml.get_widget('gc_banner_status_image')
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]:
image = 'muc_active'
else:
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]
if muc_icon.get_storage_type() != gtk.IMAGE_EMPTY:
pix = muc_icon.get_pixbuf()
@ -800,7 +800,7 @@ class GroupchatControl(ChatControlBase):
if kind == 'incoming': # it's a message NOT from us
# highlighting and sounds
(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_' + \
str(self.gc_custom_colors[contact]))
else:
@ -1231,15 +1231,15 @@ class GroupchatControl(ChatControlBase):
real_jid += '/' + gc_c.resource
else:
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]:
server = gajim.get_server_from_jid(self.room_jid)
if not server.startswith('irc'):
con.request_vcard(real_jid, fake_jid)
else:
cached_vcard = con.get_cached_vcard(fake_jid, True)
if cached_vcard and cached_vcard.has_key('PHOTO') and \
cached_vcard['PHOTO'].has_key('SHA'):
if cached_vcard and 'PHOTO' in cached_vcard and \
'SHA' in cached_vcard['PHOTO']:
cached_sha = cached_vcard['PHOTO']['SHA']
else:
cached_sha = ''
@ -1518,7 +1518,7 @@ class GroupchatControl(ChatControlBase):
else:
nick = ''
# 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'].\
window.present()
else:
@ -1866,8 +1866,7 @@ class GroupchatControl(ChatControlBase):
if c.affiliation == 'owner':
gajim.connections[self.account].request_gc_config(self.room_jid)
elif c.affiliation == 'admin':
if not gajim.interface.instances[self.account]['gc_config'].has_key(
self.room_jid):
if self.room_jid not in gajim.interface.instances[self.account]['gc_config']:
gajim.interface.instances[self.account]['gc_config'][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):
'''bookmark the room, without autojoin and not minimized'''
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]
gajim.interface.add_gc_bookmark(self.account, self.name, self.room_jid, \
'0', '0', password, self.nick)
@ -2399,7 +2398,7 @@ class GroupchatControl(ChatControlBase):
'''Call vcard_information_window class to display user's information'''
c = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick)
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.\
present()
else:

View File

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

View File

@ -234,7 +234,7 @@ class HistoryWindow:
def _load_history(self, jid_or_name, account = None):
'''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
info_jid, info_account, info_name, info_completion = self.completion_dict[jid_or_name]
self.jids_to_search = [info_jid]

View File

@ -155,7 +155,7 @@ class MessageWindow(object):
gtk.gdk.ACTION_MOVE)
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]
del self._controls[old_name]
@ -235,7 +235,7 @@ class MessageWindow(object):
def new_tab(self, control):
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][fjid] = control

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -454,7 +454,7 @@ class RosterWindow:
if parent_type == 'group' and \
self.model.iter_n_children(parent_i) == 1:
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]
self.model.remove(parent_i)
else:
@ -985,7 +985,7 @@ class RosterWindow:
gajim.connections[account].mood['mood'].strip()).get_pixbuf()
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] = \
gtkgui_helpers.load_mood_icon('unknown'). \
get_pixbuf()
@ -993,7 +993,7 @@ class RosterWindow:
self.model[child_iter][C_MOOD_PIXBUF] = None
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() \
in ACTIVITIES:
self.model[child_iter][C_ACTIVITY_PIXBUF] = \
@ -1001,7 +1001,7 @@ class RosterWindow:
gajim.connections[account]. \
activity['activity'].strip()).get_pixbuf()
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] = \
gtkgui_helpers.load_activity_icon('unknown'). \
get_pixbuf()
@ -1009,8 +1009,8 @@ class RosterWindow:
self.model[child_iter][C_ACTIVITY_PIXBUF] = None
if gajim.config.get('show_tunes_in_roster') \
and (gajim.connections[account].tune.has_key('artist') \
or gajim.connections[account].tune.has_key('title')):
and ('artist' in gajim.connections[account].tune \
or 'title' in gajim.connections[account].tune):
self.model[child_iter][C_TUNE_PIXBUF] = \
gtk.gdk.pixbuf_new_from_file(
'../data/emoticons/static/music.png')
@ -1266,7 +1266,7 @@ class RosterWindow:
jid = self.model[iters[0]][C_JID]
jid = jid.decode('utf-8')
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(
'../data/emoticons/static/music.png')
else:
@ -1966,9 +1966,9 @@ class RosterWindow:
gajim.SHOW_LIST.index('invisible')
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] = {}
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] = {}
for gc_control in gajim.interface.msg_win_mgr.get_controls(
message_control.TYPE_GC) + \
@ -2034,7 +2034,7 @@ class RosterWindow:
ctrl.update_status_display(name, uf_show, 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]:
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 ctrl in win.controls():
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] \
< 2:
recent = True
@ -2307,14 +2307,14 @@ class RosterWindow:
dialogs.SingleMessageWindow(account, server, 'send')
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()
else:
gajim.interface.instances[account]['xml_console'] = \
dialogs.XMLConsoleWindow(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()
else:
gajim.interface.instances[account]['privacy_lists'] = \
@ -2351,14 +2351,14 @@ class RosterWindow:
return
info = gajim.interface.instances[account]['infos']
if info.has_key(contact.jid):
if contact.jid in info:
info[contact.jid].window.present()
else:
info[contact.jid] = vcard.VcardWindow(contact, account)
def on_info_zeroconf(self, widget, contact, account):
info = gajim.interface.instances[account]['infos']
if info.has_key(contact.jid):
if contact.jid in info:
info[contact.jid].window.present()
else:
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_active_list('')
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'].\
privacy_list_received([])
for (contact, account) in list_:
@ -2647,7 +2647,7 @@ class RosterWindow:
def on_rename(self, widget, row_type, jid, account):
# 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()
return
model = self.modelfilter
@ -2669,7 +2669,7 @@ class RosterWindow:
message = _('Enter a new name for group %s') % jid
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']
if row_type in ('contact', 'agent'):
if old_text == new_text:
@ -2706,7 +2706,7 @@ class RosterWindow:
self.add_contact_to_groups(jid, acc, [new_text,])
def on_canceled():
if gajim.interface.instances.has_key('rename'):
if 'rename' in gajim.interface.instances:
del gajim.interface.instances['rename']
gajim.interface.instances['rename'] = dialogs.InputDialog(title, message,
@ -2812,7 +2812,7 @@ class RosterWindow:
def on_history(self, widget, contact, account):
'''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'].open_history(contact.jid, account)
else:
@ -2865,7 +2865,7 @@ class RosterWindow:
for account in account_list:
if gajim.connections[account].muc_jid[type_]:
# 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()
try:
gajim.interface.instances[account]['join_gc'] = \
@ -2906,14 +2906,14 @@ class RosterWindow:
self.remove_groupchat(jid, 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()
else:
gajim.interface.instances['accounts'] = config.AccountsWindow()
gajim.interface.instances['accounts'].select_account(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()
else:
gajim.interface.instances['accounts'] = config.AccountsWindow()
@ -3156,7 +3156,7 @@ class RosterWindow:
our_jid = gajim.get_jid_from_account(account)
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][group] = show
accounts.append(group)
@ -3164,7 +3164,7 @@ class RosterWindow:
if jid == our_jid:
jid += '/' + contact.resource
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][contact.jid] = show
dialogs.ChangeStatusMessageDialog(on_response, show)
@ -3266,7 +3266,7 @@ class RosterWindow:
self.get_status_message(status, on_continue)
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()
else:
gajim.interface.instances['preferences'] = config.PreferencesWindow()
@ -3300,7 +3300,7 @@ class RosterWindow:
helpers.update_optional_features(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()
else:
gajim.interface.instances[account]['pep_services'] = \
@ -3316,7 +3316,7 @@ class RosterWindow:
dialogs.ErrorDialog(_('You cannot join a group chat while you are '
'invisible'))
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()
else:
# c http://nkour.blogspot.com/2005/05/pythons-init-return-none-doesnt-return.html
@ -3343,7 +3343,7 @@ class RosterWindow:
dialogs.AboutDialog()
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()
else:
gajim.interface.instances['accounts'] = config.AccountsWindow()
@ -3356,7 +3356,7 @@ class RosterWindow:
gajim.interface.instances['file_transfers'].window.show_all()
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()
else:
gajim.interface.instances['logs'] = history_window.\
@ -3638,7 +3638,7 @@ class RosterWindow:
def on_service_disco_menuitem_activate(self, widget, account):
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].\
window.present()
else:
@ -4022,11 +4022,11 @@ class RosterWindow:
transport: transport iconset doesn't contain all icons, so we fall back
to jabber one'''
transport = gajim.get_transport_name_from_jid(jid)
if transport and self.transports_state_images.has_key(size):
if not self.transports_state_images[size].has_key(transport):
if transport and size in self.transports_state_images:
if transport not in self.transports_state_images[size]:
# we don't have iconset for this transport loaded yet. Let's do it
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]:
return self.transports_state_images[size][transport]
return gajim.interface.jabber_state_images[size]
@ -5334,7 +5334,7 @@ class RosterWindow:
send_custom_status_menuitem.set_image( \
gtkgui_helpers.load_icon('offline'))
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]:
send_custom_status_menuitem.set_image(
gtkgui_helpers.load_icon( \
@ -5655,7 +5655,7 @@ class RosterWindow:
'offline'))
send_custom_status_menuitem.set_sensitive(False)
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]:
send_custom_status_menuitem.set_image(gtkgui_helpers.load_icon(
gajim.interface.status_sent_to_users[account][jid]))
@ -5885,7 +5885,7 @@ class RosterWindow:
for account in connected_accounts:
for t in gajim.connections[account].muc_jid:
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)
rooms = [] # a list of (room_jid, account) tuple
invite_to_submenu.append(invite_to_new_room_menuitem)
@ -5898,7 +5898,7 @@ class RosterWindow:
message_control.TYPE_GC) + minimized_controls:
acct = gc_control.account
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 \
contacts_transport == gajim.get_transport_name_from_jid(room_jid):
rooms.append((room_jid, acct))

View File

@ -82,7 +82,7 @@ class SearchWindow:
self.data_form_widget.data_form.get_purged(), True)
else:
infos = self.data_form_widget.get_infos()
if infos.has_key('instructions'):
if 'instructions' in infos:
del infos['instructions']
gajim.connections[self.account].send_search_form(self.jid, infos,
False)
@ -107,7 +107,7 @@ class SearchWindow:
if not iter:
return
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()
else:
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')
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'])
for show in ('online', 'chat', 'away', 'xa', 'dnd', 'invisible'):
@ -372,7 +372,7 @@ class Systray:
win.present()
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()
else:
gajim.interface.instances['preferences'] = config.PreferencesWindow()

View File

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

View File

@ -53,7 +53,7 @@ def get_avatar_pixbuf_encoded_mime(photo):
img_decoded = None
avatar_encoded = None
avatar_mime_type = None
if photo.has_key('BINVAL'):
if 'BINVAL' in photo:
img_encoded = photo['BINVAL']
avatar_encoded = img_encoded
try:
@ -61,7 +61,7 @@ def get_avatar_pixbuf_encoded_mime(photo):
except:
pass
if img_decoded:
if photo.has_key('TYPE'):
if 'TYPE' in photo:
avatar_mime_type = photo['TYPE']
pixbuf = gtkgui_helpers.get_pixbuf_from_data(img_decoded)
else:
@ -230,7 +230,7 @@ class VcardWindow:
i = 0
client = ''
os = ''
while self.os_info.has_key(i):
while i in self.os_info:
if not self.os_info[i]['resource'] or \
self.os_info[i]['resource'] == resource:
self.os_info[i]['client'] = client_info
@ -525,7 +525,7 @@ class ZeroconfVcardWindow:
def fill_personal_page(self):
contact = gajim.connections[gajim.ZEROCONF_ACC_NAME].roster.getItem(self.contact.jid)
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] = ''
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'])

View File

@ -87,7 +87,7 @@ class Mock:
if realClass:
self.realClassMethods = dict(inspect.getmembers(realClass, inspect.isroutine))
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)
self._setupSubclassMethodInterceptors()
@ -118,7 +118,7 @@ class Mock:
"""
if self.realClassMethods == None:
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)
func = self.realClassMethods[name]
@ -181,7 +181,7 @@ def _getNumPosSeenAndCheck(numPosCallParams, callKwParams, args, varkw):
for arg in args[:numPosCallParams]:
posSeen[arg] = True
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)
if kwp in args:
posSeen[kwp] = True
@ -289,7 +289,7 @@ class MockCallable:
def _findFunc(cl, 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]
for base in cl.__bases__:
func = _findFunc(base, name)