Author: jim++ Date: 2008-04-18 02:02:56 +0200 (Fri, 18 Apr 2008) New Revision: 9487
Modified: trunk/src/common/GnuPG.py trunk/src/common/GnuPGInterface.py trunk/src/common/connection_handlers.py trunk/src/common/helpers.py trunk/src/common/optparser.py trunk/src/common/socks5.py trunk/src/common/stanza_session.py trunk/src/common/xmpp/commands.py trunk/src/common/xmpp/debug.py trunk/src/common/xmpp/dispatcher_nb.py trunk/src/common/xmpp/roster.py trunk/src/dialogs.py trunk/src/gajim.py trunk/src/lastfm.py trunk/src/message_window.py trunk/src/remote_control.py Log: 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)
Modified: trunk/src/common/GnuPG.py =================================================================== --- trunk/src/common/GnuPG.py 2008-04-17 19:26:09 UTC (rev 9486) +++ trunk/src/common/GnuPG.py 2008-04-18 00:02:56 UTC (rev 9487) @@ -150,7 +150,7 @@ return 'BAD_PASSPHRASE'
def verify(self, str, sign): - if str == None: + if str is None: return '' f = tmpfile() fd = f.fileno()
Modified: trunk/src/common/GnuPGInterface.py =================================================================== --- trunk/src/common/GnuPGInterface.py 2008-04-17 19:26:09 UTC (rev 9486) +++ trunk/src/common/GnuPGInterface.py 2008-04-18 00:02:56 UTC (rev 9487) @@ -339,9 +339,9 @@ 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) \
Modified: trunk/src/common/connection_handlers.py =================================================================== --- trunk/src/common/connection_handlers.py 2008-04-17 19:26:09 UTC (rev 9486) +++ trunk/src/common/connection_handlers.py 2008-04-18 00:02:56 UTC (rev 9487) @@ -191,7 +191,7 @@ 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, ''))
Modified: trunk/src/common/helpers.py =================================================================== --- trunk/src/common/helpers.py 2008-04-17 19:26:09 UTC (rev 9486) +++ trunk/src/common/helpers.py 2008-04-18 00:02:56 UTC (rev 9487) @@ -644,7 +644,7 @@ 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
Modified: trunk/src/common/optparser.py =================================================================== --- trunk/src/common/optparser.py 2008-04-17 19:26:09 UTC (rev 9486) +++ trunk/src/common/optparser.py 2008-04-18 00:02:56 UTC (rev 9487) @@ -83,7 +83,7 @@ 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
Modified: trunk/src/common/socks5.py =================================================================== --- trunk/src/common/socks5.py 2008-04-17 19:26:09 UTC (rev 9486) +++ trunk/src/common/socks5.py 2008-04-18 00:02:56 UTC (rev 9487) @@ -81,7 +81,7 @@ 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 @@ 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 @@ # 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 @@ 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:
Modified: trunk/src/common/stanza_session.py =================================================================== --- trunk/src/common/stanza_session.py 2008-04-17 19:26:09 UTC (rev 9486) +++ trunk/src/common/stanza_session.py 2008-04-18 00:02:56 UTC (rev 9487) @@ -226,11 +226,11 @@ 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 @@ 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'''
Modified: trunk/src/common/xmpp/commands.py =================================================================== --- trunk/src/common/xmpp/commands.py 2008-04-17 19:26:09 UTC (rev 9486) +++ trunk/src/common/xmpp/commands.py 2008-04-18 00:02:56 UTC (rev 9487) @@ -227,7 +227,7 @@ 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 @@ 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
Modified: trunk/src/common/xmpp/debug.py =================================================================== --- trunk/src/common/xmpp/debug.py 2008-04-17 19:26:09 UTC (rev 9486) +++ trunk/src/common/xmpp/debug.py 2008-04-18 00:02:56 UTC (rev 9487) @@ -355,7 +355,7 @@ 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 )
Modified: trunk/src/common/xmpp/dispatcher_nb.py =================================================================== --- trunk/src/common/xmpp/dispatcher_nb.py 2008-04-17 19:26:09 UTC (rev 9486) +++ trunk/src/common/xmpp/dispatcher_nb.py 2008-04-18 00:02:56 UTC (rev 9487) @@ -287,7 +287,7 @@
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()
Modified: trunk/src/common/xmpp/roster.py =================================================================== --- trunk/src/common/xmpp/roster.py 2008-04-17 19:26:09 UTC (rev 9486) +++ trunk/src/common/xmpp/roster.py 2008-04-18 00:02:56 UTC (rev 9487) @@ -65,7 +65,7 @@ """ 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'):
Modified: trunk/src/dialogs.py =================================================================== --- trunk/src/dialogs.py 2008-04-17 19:26:09 UTC (rev 9486) +++ trunk/src/dialogs.py 2008-04-18 00:02:56 UTC (rev 9487) @@ -653,7 +653,7 @@ 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():
Modified: trunk/src/gajim.py =================================================================== --- trunk/src/gajim.py 2008-04-17 19:26:09 UTC (rev 9486) +++ trunk/src/gajim.py 2008-04-18 00:02:56 UTC (rev 9487) @@ -2166,7 +2166,7 @@
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 @@ 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 @@ 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)
Modified: trunk/src/lastfm.py =================================================================== --- trunk/src/lastfm.py 2008-04-17 19:26:09 UTC (rev 9486) +++ trunk/src/lastfm.py 2008-04-18 00:02:56 UTC (rev 9487) @@ -147,7 +147,7 @@ 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 @@
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 @@ 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:
Modified: trunk/src/message_window.py =================================================================== --- trunk/src/message_window.py 2008-04-17 19:26:09 UTC (rev 9486) +++ trunk/src/message_window.py 2008-04-18 00:02:56 UTC (rev 9487) @@ -547,7 +547,7 @@ 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)
Modified: trunk/src/remote_control.py =================================================================== --- trunk/src/remote_control.py 2008-04-17 19:26:09 UTC (rev 9486) +++ trunk/src/remote_control.py 2008-04-18 00:02:56 UTC (rev 9487) @@ -610,7 +610,7 @@ 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)