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
roster_win.py is NOT checked here (waiting for modelfilter)
This commit is contained in:
Jean-Marie Traissard 2008-04-18 00:02:56 +00:00
parent b35b2f9ad0
commit 2ce13dc40e
16 changed files with 29 additions and 29 deletions

View File

@ -150,7 +150,7 @@ if gajim.HAVE_GPG:
return 'BAD_PASSPHRASE'
def verify(self, str, sign):
if str == None:
if str is None:
return ''
f = tmpfile()
fd = f.fileno()

View File

@ -339,9 +339,9 @@ class GnuPG:
and can be written to.
"""
if args == None: args = []
if create_fhs == None: create_fhs = []
if attach_fhs == None: attach_fhs = {}
if args is None: args = []
if create_fhs is None: create_fhs = []
if attach_fhs is None: attach_fhs = {}
for std in _stds:
if not attach_fhs.has_key(std) \

View File

@ -191,7 +191,7 @@ class ConnectionBytestream:
ft_add_hosts.append(ft_host)
listener = gajim.socks5queue.start_listener(port,
sha_str, self._result_socks5_sid, file_props['sid'])
if listener == None:
if listener is None:
file_props['error'] = -5
self.dispatch('FILE_REQUEST_ERROR', (unicode(receiver), file_props,
''))

View File

@ -644,7 +644,7 @@ def statuses_unified():
if not gajim.config.get_per('accounts', account,
'sync_with_global_status'):
continue
if reference == None:
if reference is None:
reference = gajim.connections[account].connected
elif reference != gajim.connections[account].connected:
return False

View File

@ -83,7 +83,7 @@ class OptionsParser:
return True
def write_line(self, fd, opt, parents, value):
if value == None:
if value is None:
return
value = value[1]
# convert to utf8 before writing to file if needed

View File

@ -81,7 +81,7 @@ class SocksQueue:
and do a socks5 authentication using sid for generated sha
'''
self.sha_handlers[sha_str] = (sha_handler, sid)
if self.listener == None:
if self.listener is None:
self.listener = Socks5Listener(self.idlequeue, port)
self.listener.queue = self
self.listener.bind()
@ -372,7 +372,7 @@ class Socks5:
self.file = None
def open_file_for_reading(self):
if self.file == None:
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']:
@ -549,7 +549,7 @@ class Socks5:
# return number of read bytes. It can be used in progressbar
if fd != None:
self.file_props['stalled'] = False
if fd == None and self.file_props['stalled'] is False:
if fd is None and self.file_props['stalled'] is False:
return None
if self.file_props.has_key('received-len'):
if self.file_props['received-len'] != 0:
@ -1019,7 +1019,7 @@ class Socks5Receiver(Socks5, IdleObject):
if version != 0x05 or method == 0xff:
self.disconnect()
elif self.state == 4: # get approve of our request
if buff == None:
if buff is None:
return None
sub_buff = buff[:4]
if len(sub_buff) < 4:

View File

@ -226,11 +226,11 @@ class EncryptedStanzaSession(StanzaSession):
self.hmac(k, 'Responder SIGMA Key') )
def compress(self, plaintext):
if self.compression == None:
if self.compression is None:
return plaintext
def decompress(self, compressed):
if self.compression == None:
if self.compression is None:
return compressed
def encrypt(self, encryptable):
@ -865,7 +865,7 @@ class EncryptedStanzaSession(StanzaSession):
def fail_bad_negotiation(self, reason, fields = None):
'''sends an error and cancels everything.
if fields == None, the remote party has given us a bad cryptographic value of some kind
if fields is None, the remote party has given us a bad cryptographic value of some kind
otherwise, list the fields we haven't implemented'''

View File

@ -227,7 +227,7 @@ class Command_Handler_Prototype(PlugIn):
action = request.getTagAttr('command','action')
except:
action = None
if action == None: action = 'execute'
if action is None: action = 'execute'
# Check session is in session list
if self.sessions.has_key(session):
if self.sessions[session]['jid']==request.getFrom():
@ -279,7 +279,7 @@ class TestCommand(Command_Handler_Prototype):
session = request.getTagAttr('command','sessionid')
except:
session = None
if session == None:
if session is None:
session = self.getSessionID()
sessions[session]={'jid':request.getFrom(),'actions':{'cancel':self.cmdCancel,'next':self.cmdSecondStage},'data':{'type':None}}
# As this is the first stage we only send a form

View File

@ -355,7 +355,7 @@ class Debug:
lst2 = self._as_one_list( l )
for l2 in lst2:
self._append_unique_str(r, l2 )
elif l == None:
elif l is None:
continue
else:
self._append_unique_str(r, l )

View File

@ -287,7 +287,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

@ -65,7 +65,7 @@ class Roster(PlugIn):
""" Subscription tracker. Used internally for setting items state in
internal roster representation. """
sender = stanza.getAttr('from')
if not sender == None and not sender.bareMatch(
if not sender is None and not sender.bareMatch(
self._owner.User + '@' + self._owner.Server):
return
for item in stanza.getTag('query').getTags('item'):

View File

@ -653,7 +653,7 @@ class AddNewContactWindow:
def __init__(self, account = None, jid = None, user_nick = None,
group = None):
self.account = account
if account == None:
if account is None:
# fill accounts with active accounts
accounts = []
for account in gajim.connections.keys():

View File

@ -2166,7 +2166,7 @@ class Interface:
def handle_event_ping_sent(self, account, contact):
ctrl = self.msg_win_mgr.get_control(contact.get_full_jid(), account)
if ctrl == None:
if ctrl is None:
ctrl = self.msg_win_mgr.get_control(contact.jid, account)
ctrl.print_conversation(_('Ping?'), 'status')
@ -2174,14 +2174,14 @@ class Interface:
contact = data[0]
seconds = data[1]
ctrl = self.msg_win_mgr.get_control(contact.get_full_jid(), account)
if ctrl == None:
if ctrl is None:
ctrl = self.msg_win_mgr.get_control(contact.jid, account)
if ctrl:
ctrl.print_conversation(_('Pong! (%s s.)') % seconds, 'status')
def handle_event_ping_error(self, account, contact):
ctrl = self.msg_win_mgr.get_control(contact.get_full_jid(), account)
if ctrl == None:
if ctrl is None:
ctrl = self.msg_win_mgr.get_control(contact.jid, account)
if ctrl:
ctrl.print_conversation(_('Error.'), 'status')
@ -2393,7 +2393,7 @@ class Interface:
shows[show].append(a)
for show in shows:
message = self.roster.get_status_message(show)
if message == None:
if message is None:
continue
for a in shows[show]:
self.roster.send_status(a, show, message)

View File

@ -147,7 +147,7 @@ class LastFM:
lst, the Unix time at which a song has been scrobbled, defaults to that
of the last song
"""
if lst == None:
if lst is None:
lst = self.getLastScrobbledTime()
return int(time()) - lst
@ -158,7 +158,7 @@ class LastFM:
delay, the delay to use, defaults to self.MAX_DELAY
"""
if delay == None:
if delay is None:
delay = self.MAX_DELAY
return self.timeSinceLastScrobbled() < delay
@ -189,7 +189,7 @@ class LastFM:
songTuple, the tuple representing the song, defaults to the last song
"""
str = ''
if songTuple == None:
if songTuple is None:
songTuple = self.getLastRecentSong()
if songTuple != None:

View File

@ -547,7 +547,7 @@ class MessageWindow(object):
else:
page_num = key
notebook = self.notebook
if page_num == None:
if page_num is None:
page_num = notebook.get_current_page()
nth_child = notebook.get_nth_page(page_num)
return self._widget_to_control(nth_child)

View File

@ -610,7 +610,7 @@ class SignalObject(dbus.service.Object):
return None
prim_contact = None # primary contact
for contact in contacts:
if prim_contact == None or contact.priority > prim_contact.priority:
if prim_contact is None or contact.priority > prim_contact.priority:
prim_contact = contact
contact_dict = DBUS_DICT_SV()
contact_dict['name'] = DBUS_STRING(prim_contact.name)