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): gajim.jid_is_transport(jid):
toggle_gpg_menuitem.set_sensitive(False) toggle_gpg_menuitem.set_sensitive(False)
else: 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_sensitive(not e2e_is_active)
toggle_gpg_menuitem.set_active(self.gpg_is_active) toggle_gpg_menuitem.set_active(self.gpg_is_active)
@ -1708,7 +1708,8 @@ class ChatControl(ChatControlBase):
if not gajim.HAVE_PYCRYPTO: if not gajim.HAVE_PYCRYPTO:
toggle_e2e_menuitem.set_sensitive(False) toggle_e2e_menuitem.set_sensitive(False)
else: 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_active(isactive)
toggle_e2e_menuitem.set_sensitive(not self.gpg_is_active) toggle_e2e_menuitem.set_sensitive(not self.gpg_is_active)

View File

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

View File

@ -489,7 +489,7 @@ class ConnectionBytestream:
if proxyhost['jid'] == jid: if proxyhost['jid'] == jid:
proxy = proxyhost proxy = proxyhost
if proxy != None: if proxy is not None:
file_props['streamhost-used'] = True file_props['streamhost-used'] = True
if not file_props.has_key('streamhosts'): if not file_props.has_key('streamhosts'):
file_props['streamhosts'] = [] file_props['streamhosts'] = []
@ -1104,7 +1104,7 @@ class ConnectionVcard:
order = int(order) order = int(order)
except: except:
order = 0 order = 0
if order != None: if order is not None:
data['order'] = order data['order'] = order
if meta_list.has_key(tag): if meta_list.has_key(tag):
meta_list[tag].append(data) meta_list[tag].append(data)
@ -1602,7 +1602,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
invite = msg.getTag('x', namespace = common.xmpp.NS_MUC_USER) invite = msg.getTag('x', namespace = common.xmpp.NS_MUC_USER)
if invite and not invite.getTag('invite'): if invite and not invite.getTag('invite'):
invite = None 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 msg_id = None
composing_xep = None composing_xep = None
# FIXME: Msn transport (CMSN1.2.1 and PyMSN0.10) do NOT RECOMMENDED # FIXME: Msn transport (CMSN1.2.1 and PyMSN0.10) do NOT RECOMMENDED
@ -1675,7 +1675,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
has_timestamp = False has_timestamp = False
if msg.timestamp: if msg.timestamp:
has_timestamp = True has_timestamp = True
if subject != None: if subject is not None:
self.dispatch('GC_SUBJECT', (frm, subject, msgtxt, has_timestamp)) self.dispatch('GC_SUBJECT', (frm, subject, msgtxt, has_timestamp))
else: else:
statusCode = msg.getStatusCode() 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): def allow_popup_window(account, advanced_notif_num = None):
'''is it allowed to popup windows?''' '''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), popup = gajim.config.get_per('notifications', str(advanced_notif_num),
'auto_open') 'auto_open')
if popup == 'yes': if popup == 'yes':

View File

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

View File

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

View File

@ -283,7 +283,7 @@ class Component(CommonClient):
self.Namespace=auth.NS_COMPONENT_1 self.Namespace=auth.NS_COMPONENT_1
self.Server=server[0] self.Server=server[0]
CommonClient.connect(self,server=server,proxy=proxy) 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.defaultNamespace=auth.NS_CLIENT
self.Dispatcher.RegisterNamespace(self.defaultNamespace) self.Dispatcher.RegisterNamespace(self.defaultNamespace)
self.Dispatcher.RegisterProtocol('iq',dispatcher.Iq) 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) on_connect = self._on_connect, on_connect_failure = self.on_connect_failure)
def _on_connect(self): 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.defaultNamespace=auth.NS_CLIENT
self.Dispatcher.RegisterNamespace(self.defaultNamespace) self.Dispatcher.RegisterNamespace(self.defaultNamespace)
self.Dispatcher.RegisterProtocol('iq',dispatcher.Iq) self.Dispatcher.RegisterProtocol('iq',dispatcher.Iq)

View File

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

View File

@ -246,7 +246,7 @@ class Dispatcher(PlugIn):
if not direct and self._owner._component: if not direct and self._owner._component:
if name == 'route': if name == 'route':
if stanza.getAttr('error') == None: if stanza.getAttr('error') is None:
if len(stanza.getChildren()) == 1: if len(stanza.getChildren()) == 1:
stanza = stanza.getChildren()[0] stanza = stanza.getChildren()[0]
name=stanza.getName() 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) 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 body: self.setBody(body)
if xhtml: self.setXHTML(xhtml) if xhtml: self.setXHTML(xhtml)
if subject != None: self.setSubject(subject) if subject is not None: self.setSubject(subject)
def getBody(self): def getBody(self):
""" Returns text of the message. """ """ Returns text of the message. """
return self.getTagData('body') return self.getTagData('body')

View File

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

View File

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

View File

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

View File

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

View File

@ -784,11 +784,12 @@ class MessageWindowMgr(gobject.GObject):
return None return None
def has_window(self, jid, acct): 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): def one_window_opened(self, contact=None, acct=None, type=None):
try: 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: except KeyError:
return False return False

View File

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