Author: jim++ Date: 2008-04-18 02:26:07 +0200 (Fri, 18 Apr 2008) New Revision: 9488
Modified: trunk/src/chat_control.py trunk/src/common/GnuPGInterface.py trunk/src/common/connection_handlers.py trunk/src/common/helpers.py trunk/src/common/pep.py trunk/src/common/socks5.py trunk/src/common/xmpp/client.py trunk/src/common/xmpp/client_nb.py trunk/src/common/xmpp/commands.py trunk/src/common/xmpp/dispatcher.py trunk/src/common/xmpp/protocol.py trunk/src/conversation_textview.py trunk/src/gajim.py trunk/src/gtkgui_helpers.py trunk/src/lastfm.py trunk/src/message_window.py trunk/src/notify.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; second one... roster_win.py is NOT checked here (waiting for modelfilter)
Modified: trunk/src/chat_control.py =================================================================== --- trunk/src/chat_control.py 2008-04-18 00:02:56 UTC (rev 9487) +++ trunk/src/chat_control.py 2008-04-18 00:26:07 UTC (rev 9488) @@ -1700,7 +1700,7 @@ 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 @@ 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)
Modified: trunk/src/common/GnuPGInterface.py =================================================================== --- trunk/src/common/GnuPGInterface.py 2008-04-18 00:02:56 UTC (rev 9487) +++ trunk/src/common/GnuPGInterface.py 2008-04-18 00:26:07 UTC (rev 9488) @@ -350,7 +350,7 @@
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 @@ 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' )
Modified: trunk/src/common/connection_handlers.py =================================================================== --- trunk/src/common/connection_handlers.py 2008-04-18 00:02:56 UTC (rev 9487) +++ trunk/src/common/connection_handlers.py 2008-04-18 00:26:07 UTC (rev 9488) @@ -489,7 +489,7 @@ 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 @@ 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 @@ 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 @@ 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()
Modified: trunk/src/common/helpers.py =================================================================== --- trunk/src/common/helpers.py 2008-04-18 00:02:56 UTC (rev 9487) +++ trunk/src/common/helpers.py 2008-04-18 00:26:07 UTC (rev 9488) @@ -908,7 +908,7 @@
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':
Modified: trunk/src/common/pep.py =================================================================== --- trunk/src/common/pep.py 2008-04-18 00:02:56 UTC (rev 9487) +++ trunk/src/common/pep.py 2008-04-18 00:26:07 UTC (rev 9488) @@ -20,9 +20,9 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 = ''):
Modified: trunk/src/common/socks5.py =================================================================== --- trunk/src/common/socks5.py 2008-04-18 00:02:56 UTC (rev 9487) +++ trunk/src/common/socks5.py 2008-04-18 00:26:07 UTC (rev 9488) @@ -201,7 +201,7 @@ 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 @@ 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
Modified: trunk/src/common/xmpp/client.py =================================================================== --- trunk/src/common/xmpp/client.py 2008-04-18 00:02:56 UTC (rev 9487) +++ trunk/src/common/xmpp/client.py 2008-04-18 00:26:07 UTC (rev 9488) @@ -283,7 +283,7 @@ 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)
Modified: trunk/src/common/xmpp/client_nb.py =================================================================== --- trunk/src/common/xmpp/client_nb.py 2008-04-18 00:02:56 UTC (rev 9487) +++ trunk/src/common/xmpp/client_nb.py 2008-04-18 00:26:07 UTC (rev 9488) @@ -354,7 +354,7 @@ 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)
Modified: trunk/src/common/xmpp/commands.py =================================================================== --- trunk/src/common/xmpp/commands.py 2008-04-18 00:02:56 UTC (rev 9487) +++ trunk/src/common/xmpp/commands.py 2008-04-18 00:26:07 UTC (rev 9488) @@ -115,7 +115,7 @@ 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 @@ # 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
Modified: trunk/src/common/xmpp/dispatcher.py =================================================================== --- trunk/src/common/xmpp/dispatcher.py 2008-04-18 00:02:56 UTC (rev 9487) +++ trunk/src/common/xmpp/dispatcher.py 2008-04-18 00:26:07 UTC (rev 9488) @@ -246,7 +246,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/protocol.py =================================================================== --- trunk/src/common/xmpp/protocol.py 2008-04-18 00:02:56 UTC (rev 9487) +++ trunk/src/common/xmpp/protocol.py 2008-04-18 00:26:07 UTC (rev 9488) @@ -405,7 +405,7 @@ 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')
Modified: trunk/src/conversation_textview.py =================================================================== --- trunk/src/conversation_textview.py 2008-04-18 00:02:56 UTC (rev 9487) +++ trunk/src/conversation_textview.py 2008-04-18 00:26:07 UTC (rev 9488) @@ -973,7 +973,7 @@ 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()
Modified: trunk/src/gajim.py =================================================================== --- trunk/src/gajim.py 2008-04-18 00:02:56 UTC (rev 9487) +++ trunk/src/gajim.py 2008-04-18 00:26:07 UTC (rev 9488) @@ -1457,7 +1457,7 @@ 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)
Modified: trunk/src/gtkgui_helpers.py =================================================================== --- trunk/src/gtkgui_helpers.py 2008-04-18 00:02:56 UTC (rev 9487) +++ trunk/src/gtkgui_helpers.py 2008-04-18 00:26:07 UTC (rev 9488) @@ -660,7 +660,7 @@ 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)
Modified: trunk/src/lastfm.py =================================================================== --- trunk/src/lastfm.py 2008-04-18 00:02:56 UTC (rev 9487) +++ trunk/src/lastfm.py 2008-04-18 00:26:07 UTC (rev 9488) @@ -192,7 +192,7 @@ if songTuple is None: songTuple = self.getLastRecentSong()
- if songTuple != None: + if songTuple is not None: dict = { 'a': songTuple[0], 'n': songTuple[1],
Modified: trunk/src/message_window.py =================================================================== --- trunk/src/message_window.py 2008-04-18 00:02:56 UTC (rev 9487) +++ trunk/src/message_window.py 2008-04-18 00:26:07 UTC (rev 9488) @@ -784,11 +784,12 @@ 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
Modified: trunk/src/notify.py =================================================================== --- trunk/src/notify.py 2008-04-18 00:02:56 UTC (rev 9487) +++ trunk/src/notify.py 2008-04-18 00:26:07 UTC (rev 9488) @@ -59,7 +59,7 @@ 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_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':