http://python.org/dev/peps/pep-0008/ " Comparisons to singletons like None should always be done with

'is' or 'is not', never the equality operators."
Comparisons to None part; second one...
roster_win.py is NOT checked here (waiting for modelfilter)
This commit is contained in:
Jean-Marie Traissard 2008-04-18 00:26:07 +00:00
parent 2ce13dc40e
commit 968b2acc4f
17 changed files with 56 additions and 49 deletions

View File

@ -1700,7 +1700,7 @@ class ChatControl(ChatControlBase):
gajim.jid_is_transport(jid):
toggle_gpg_menuitem.set_sensitive(False)
else:
e2e_is_active = int(self.session != None and self.session.enable_encryption)
e2e_is_active = int(self.session is not None and self.session.enable_encryption)
toggle_gpg_menuitem.set_sensitive(not e2e_is_active)
toggle_gpg_menuitem.set_active(self.gpg_is_active)
@ -1708,7 +1708,8 @@ class ChatControl(ChatControlBase):
if not gajim.HAVE_PYCRYPTO:
toggle_e2e_menuitem.set_sensitive(False)
else:
isactive = int(self.session != None and self.session.enable_encryption)
isactive = int(self.session is not None and \
self.session.enable_encryption)
toggle_e2e_menuitem.set_active(isactive)
toggle_e2e_menuitem.set_sensitive(not self.gpg_is_active)

View File

@ -350,7 +350,7 @@ class GnuPG:
handle_passphrase = 0
if self.passphrase != None \
if self.passphrase is not None \
and not attach_fhs.has_key('passphrase') \
and 'passphrase' not in create_fhs:
handle_passphrase = 1
@ -567,11 +567,16 @@ class Options:
def get_standard_args( self ):
"""Generate a list of standard, non-meta or extra arguments"""
args = []
if self.homedir != None: args.extend( [ '--homedir', self.homedir ] )
if self.options != None: args.extend( [ '--options', self.options ] )
if self.comment != None: args.extend( [ '--comment', self.comment ] )
if self.compress_algo != None: args.extend( [ '--compress-algo', self.compress_algo ] )
if self.default_key != None: args.extend( [ '--default-key', self.default_key ] )
if self.homedir is not None:
args.extend( [ '--homedir', self.homedir ] )
if self.options is not None:
args.extend( [ '--options', self.options ] )
if self.comment is not None:
args.extend( [ '--comment', self.comment ] )
if self.compress_algo is not None:
args.extend( [ '--compress-algo', self.compress_algo ] )
if self.default_key is not None:
args.extend( [ '--default-key', self.default_key ] )
if self.no_options: args.append( '--no-options' )
if self.armor: args.append( '--armor' )

View File

@ -489,7 +489,7 @@ class ConnectionBytestream:
if proxyhost['jid'] == jid:
proxy = proxyhost
if proxy != None:
if proxy is not None:
file_props['streamhost-used'] = True
if not file_props.has_key('streamhosts'):
file_props['streamhosts'] = []
@ -1104,7 +1104,7 @@ class ConnectionVcard:
order = int(order)
except:
order = 0
if order != None:
if order is not None:
data['order'] = order
if meta_list.has_key(tag):
meta_list[tag].append(data)
@ -1602,7 +1602,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
invite = msg.getTag('x', namespace = common.xmpp.NS_MUC_USER)
if invite and not invite.getTag('invite'):
invite = None
delayed = msg.getTag('x', namespace = common.xmpp.NS_DELAY) != None
delayed = msg.getTag('x', namespace = common.xmpp.NS_DELAY) is not None
msg_id = None
composing_xep = None
# FIXME: Msn transport (CMSN1.2.1 and PyMSN0.10) do NOT RECOMMENDED
@ -1675,7 +1675,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
has_timestamp = False
if msg.timestamp:
has_timestamp = True
if subject != None:
if subject is not None:
self.dispatch('GC_SUBJECT', (frm, subject, msgtxt, has_timestamp))
else:
statusCode = msg.getStatusCode()

View File

@ -908,7 +908,7 @@ advanced_notif_num = None, is_first_message = True):
def allow_popup_window(account, advanced_notif_num = None):
'''is it allowed to popup windows?'''
if advanced_notif_num != None:
if advanced_notif_num is not None:
popup = gajim.config.get_per('notifications', str(advanced_notif_num),
'auto_open')
if popup == 'yes':

View File

@ -20,9 +20,9 @@ def user_mood(items, name, jid):
del acc.mood['mood']
if acc.mood.has_key('text'):
del acc.mood['text']
if mood != None:
if mood is not None:
acc.mood['mood'] = mood
if text != None:
if text is not None:
acc.mood['text'] = text
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
@ -34,9 +34,9 @@ def user_mood(items, name, jid):
del contact.mood['mood']
if contact.mood.has_key('text'):
del contact.mood['text']
if mood != None:
if mood is not None:
contact.mood['mood'] = mood
if text != None:
if text is not None:
contact.mood['text'] = text
def user_tune(items, name, jid):
@ -76,15 +76,15 @@ def user_tune(items, name, jid):
del acc.tune['track']
if acc.tune.has_key('length'):
del acc.tune['length']
if artist != None:
if artist is not None:
acc.tune['artist'] = artist
if title != None:
if title is not None:
acc.tune['title'] = title
if source != None:
if source is not None:
acc.tune['source'] = source
if track != None:
if track is not None:
acc.tune['track'] = track
if length != None:
if length is not None:
acc.tune['length'] = length
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
@ -102,15 +102,15 @@ def user_tune(items, name, jid):
del contact.tune['track']
if contact.tune.has_key('length'):
del contact.tune['length']
if artist != None:
if artist is not None:
contact.tune['artist'] = artist
if title != None:
if title is not None:
contact.tune['title'] = title
if source != None:
if source is not None:
contact.tune['source'] = source
if track != None:
if track is not None:
contact.tune['track'] = track
if length != None:
if length is not None:
contact.tune['length'] = length
def user_geoloc(items, name, jid):
@ -143,11 +143,11 @@ def user_activity(items, name, jid):
del acc.activity['subactivity']
if acc.activity.has_key('text'):
del acc.activity['text']
if activity != None:
if activity is not None:
acc.activity['activity'] = activity
if subactivity != None:
if subactivity is not None:
acc.activity['subactivity'] = subactivity
if text != None:
if text is not None:
acc.activity['text'] = text
(user, resource) = gajim.get_room_and_nick_from_fjid(jid)
@ -161,11 +161,11 @@ def user_activity(items, name, jid):
del contact.activity['subactivity']
if contact.activity.has_key('text'):
del contact.activity['text']
if activity != None:
if activity is not None:
contact.activity['activity'] = activity
if subactivity != None:
if subactivity is not None:
contact.activity['subactivity'] = subactivity
if text != None:
if text is not None:
contact.activity['text'] = text
def user_send_mood(account, mood, message = ''):

View File

@ -201,7 +201,7 @@ class SocksQueue:
self.idx += 1
result = sock5_receiver.connect()
self.connected += 1
if result != None:
if result is not None:
result = sock5_receiver.main()
self.process_result(result, sock5_receiver)
return 1
@ -547,7 +547,7 @@ class Socks5:
self.file_props['completed'] = True
return 0
# return number of read bytes. It can be used in progressbar
if fd != None:
if fd is not None:
self.file_props['stalled'] = False
if fd is None and self.file_props['stalled'] is False:
return None

View File

@ -283,7 +283,7 @@ class Component(CommonClient):
self.Namespace=auth.NS_COMPONENT_1
self.Server=server[0]
CommonClient.connect(self,server=server,proxy=proxy)
if self.connected and (self.typ=='jabberd2' or not self.typ and self.Dispatcher.Stream.features != None):
if self.connected and (self.typ=='jabberd2' or not self.typ and self.Dispatcher.Stream.features is not None):
self.defaultNamespace=auth.NS_CLIENT
self.Dispatcher.RegisterNamespace(self.defaultNamespace)
self.Dispatcher.RegisterProtocol('iq',dispatcher.Iq)

View File

@ -354,7 +354,7 @@ class Component(NBCommonClient):
on_connect = self._on_connect, on_connect_failure = self.on_connect_failure)
def _on_connect(self):
if self.typ=='jabberd2' or not self.typ and self.Dispatcher.Stream.features != None:
if self.typ=='jabberd2' or not self.typ and self.Dispatcher.Stream.features is not None:
self.defaultNamespace=auth.NS_CLIENT
self.Dispatcher.RegisterNamespace(self.defaultNamespace)
self.Dispatcher.RegisterProtocol('iq',dispatcher.Iq)

View File

@ -115,7 +115,7 @@ class Commands(PlugIn):
if items != []:
for each in items:
i = self._handlers[each[0]][each[1]]['disco'](conn,request,'list')
if i != None:
if i is not None:
list.append(Node(tag='item',attrs={'jid':i[0],'node':i[1],'name':i[2]}))
iq = request.buildReply('result')
if request.getQuerynode(): iq.setQuerynode(request.getQuerynode())
@ -243,7 +243,7 @@ class Command_Handler_Prototype(PlugIn):
# Jid and session don't match. Go away imposter
self._owner.send(Error(request,ERR_BAD_REQUEST))
raise NodeProcessed
elif session != None:
elif session is not None:
# Not on this sessionid you won't.
self._owner.send(Error(request,ERR_BAD_REQUEST))
raise NodeProcessed

View File

@ -246,7 +246,7 @@ class Dispatcher(PlugIn):
if not direct and self._owner._component:
if name == 'route':
if stanza.getAttr('error') == None:
if stanza.getAttr('error') is None:
if len(stanza.getChildren()) == 1:
stanza = stanza.getChildren()[0]
name=stanza.getName()

View File

@ -405,7 +405,7 @@ class Message(Protocol):
Protocol.__init__(self, 'message', to=to, typ=typ, attrs=attrs, frm=frm, payload=payload, timestamp=timestamp, xmlns=xmlns, node=node)
if body: self.setBody(body)
if xhtml: self.setXHTML(xhtml)
if subject != None: self.setSubject(subject)
if subject is not None: self.setSubject(subject)
def getBody(self):
""" Returns text of the message. """
return self.getTagData('body')

View File

@ -973,7 +973,7 @@ class ConversationTextview:
imagepath = self.latex_to_image(special_text)
end_iter = buffer.get_end_iter()
anchor = buffer.create_child_anchor(end_iter)
if imagepath != None:
if imagepath is not None:
img = gtk.Image()
img.set_from_file(imagepath)
img.show()

View File

@ -1457,7 +1457,7 @@ class Interface:
title = _('Wrong Passphrase')
second = _('Please retype your GPG passphrase or press Cancel.')
self.gpg_dialog = None
if passphrase != None:
if passphrase is not None:
self.gpg_passphrase[keyid] = passphrase
gobject.timeout_add(30000, self.forget_gpg_passphrase, keyid)
gajim.connections[account].gpg_passphrase(passphrase)

View File

@ -660,7 +660,7 @@ def possibly_set_gajim_as_xmpp_handler():
path_to_kde_file = None
def set_gajim_as_xmpp_handler(is_checked=None):
if is_checked != None:
if is_checked is not None:
# come from confirmation dialog
gajim.config.set('check_if_gajim_is_default', is_checked)
path_to_gajim_script, typ = get_abspath_for_script('gajim-remote', True)

View File

@ -192,7 +192,7 @@ class LastFM:
if songTuple is None:
songTuple = self.getLastRecentSong()
if songTuple != None:
if songTuple is not None:
dict = {
'a': songTuple[0],
'n': songTuple[1],

View File

@ -784,11 +784,12 @@ class MessageWindowMgr(gobject.GObject):
return None
def has_window(self, jid, acct):
return self.get_window(jid, acct) != None
return self.get_window(jid, acct) is not None
def one_window_opened(self, contact=None, acct=None, type=None):
try:
return self._windows[self._mode_to_key(contact, acct, type)] != None
return \
self._windows[self._mode_to_key(contact, acct, type)] is not None
except KeyError:
return False

View File

@ -59,7 +59,7 @@ def get_show_in_roster(event, account, contact):
if event == 'gc_message_received':
return True
num = get_advanced_notification(event, account, contact)
if num != None:
if num is not None:
if gajim.config.get_per('notifications', str(num), 'roster') == 'yes':
return True
if gajim.config.get_per('notifications', str(num), 'roster') == 'no':
@ -73,7 +73,7 @@ def get_show_in_roster(event, account, contact):
def get_show_in_systray(event, account, contact, type_=None):
'''Return True if this event must be shown in systray, else False'''
num = get_advanced_notification(event, account, contact)
if num != None:
if num is not None:
if gajim.config.get_per('notifications', str(num), 'systray') == 'yes':
return True
if gajim.config.get_per('notifications', str(num), 'systray') == 'no':