Yann Leboulanger pushed to branch master at gajim / python-nbxmpp
Commits: b3fdc536 by Yann Leboulanger at 2016-11-02T22:33:40+01:00 [NooN8] checks if something is not in a list/dict/.. should be done with 'var not in list'
- - - - - 5b3707eb by Yann Leboulanger at 2016-11-02T22:34:38+01:00 [NooN8] Checks with None should be made with is or is not
- - - - - b81a3ea7 by Yann Leboulanger at 2016-11-02T22:41:09+01:00 [NooN8] make all classes inherit from object
- - - - -
13 changed files:
- nbxmpp/auth_nb.py - nbxmpp/bosh.py - nbxmpp/client_nb.py - nbxmpp/dispatcher_nb.py - nbxmpp/idlequeue.py - nbxmpp/plugin.py - nbxmpp/protocol.py - nbxmpp/proxy_connectors.py - nbxmpp/roster_nb.py - nbxmpp/simplexml.py - nbxmpp/smacks.py - nbxmpp/stringprepare.py - nbxmpp/tls_nb.py
Changes:
===================================== nbxmpp/auth_nb.py ===================================== --- a/nbxmpp/auth_nb.py +++ b/nbxmpp/auth_nb.py @@ -193,7 +193,7 @@ class SASL(PlugIn): # If the server supports a mechanism disable all weaker mechanisms. password_auth_mechs_strength = ['SCRAM-SHA-1-PLUS', 'SCRAM-SHA-1', 'DIGEST-MD5', 'PLAIN', 'X-MESSENGER-OAUTH2'] - if self.channel_binding == None: + if self.channel_binding is None: password_auth_mechs_strength.remove('SCRAM-SHA-1-PLUS') for i in range(0, len(password_auth_mechs_strength)): if password_auth_mechs_strength[i] in self.mecs: @@ -243,7 +243,7 @@ class SASL(PlugIn): raise NodeProcessed except kerberos.GSSError as e: log.info('GSSAPI authentication failed: %s' % str(e)) - if 'SCRAM-SHA-1-PLUS' in self.mecs and self.channel_binding != None: + if 'SCRAM-SHA-1-PLUS' in self.mecs and self.channel_binding is not None: self.mecs.remove('SCRAM-SHA-1-PLUS') self.mechanism = 'SCRAM-SHA-1-PLUS' self._owner._caller.get_password(self.set_password, self.mechanism) @@ -501,7 +501,7 @@ class SASL(PlugIn): self.client_nonce = '%x' % rndg.getrandbits(196) self.scram_soup = 'n=' + self.username + ',r=' + self.client_nonce if self.mechanism == 'SCRAM-SHA-1': - if self.channel_binding == None: + if self.channel_binding is None: # Client doesn't support Channel Binding self.scram_gs2 = 'n,,' # No CB yet. else:
===================================== nbxmpp/bosh.py ===================================== --- a/nbxmpp/bosh.py +++ b/nbxmpp/bosh.py @@ -493,8 +493,7 @@ def get_rand_number(): return rndg.getrandbits(50)
- -class AckChecker(): +class AckChecker(object): """ Class for generating rids and generating and checking acknowledgements in BOSH messages @@ -537,10 +536,7 @@ class AckChecker(): return self.rid
- - - -class KeyStack(): +class KeyStack(object): """ Class implementing key sequences for BOSH messages """
===================================== nbxmpp/client_nb.py ===================================== --- a/nbxmpp/client_nb.py +++ b/nbxmpp/client_nb.py @@ -29,7 +29,7 @@ import logging log = logging.getLogger('nbxmpp.client_nb')
-class NonBlockingClient: +class NonBlockingClient(object): """ Client class is XMPP connection mountpoint. Objects for authentication, network communication, roster, xml parsing ... are plugged to client object. @@ -499,10 +499,10 @@ class NonBlockingClient: if self.protocol_type != 'BOSH': self._channel_binding = self.Connection.NonBlockingTLS.get_channel_binding() # TLS handshake is finished so channel binding data muss exist - assert (self._channel_binding != None) + assert (self._channel_binding is not None) except NotImplementedError: pass - if auth_mechs == None: + if auth_mechs is None: self._auth_mechs = SASL_AUTHENTICATION_MECHANISMS | set(['XEP-0078']) else: self._auth_mechs = auth_mechs @@ -557,7 +557,7 @@ class NonBlockingClient: """ if data: self.Dispatcher.ProcessNonBlocking(data) - if not 'SASL' in self.__dict__: + if 'SASL' not in self.__dict__: # SASL is pluged out, possible disconnect return if self.SASL.startsasl == 'in-process':
===================================== nbxmpp/dispatcher_nb.py ===================================== --- a/nbxmpp/dispatcher_nb.py +++ b/nbxmpp/dispatcher_nb.py @@ -43,7 +43,7 @@ DEFAULT_TIMEOUT_SECONDS = 25 XML_DECLARATION = '<?xml version=\'1.0\'?>'
# FIXME: ugly -class Dispatcher(): +class Dispatcher(object): """ Why is this here - I needed to redefine Dispatcher for BOSH and easiest way was to inherit original Dispatcher (now renamed to XMPPDispatcher). Trouble
===================================== nbxmpp/idlequeue.py ===================================== --- a/nbxmpp/idlequeue.py +++ b/nbxmpp/idlequeue.py @@ -76,7 +76,7 @@ def get_idlequeue(): return SelectIdleQueue()
-class IdleObject: +class IdleObject(object): """ Idle listener interface. Listed methods are called by IdleQueue. """ @@ -216,7 +216,7 @@ class IdleCommand(IdleObject): self._return_result()
-class IdleQueue: +class IdleQueue(object): """ IdleQueue provide three distinct time based features. Uses select.poll()
@@ -269,7 +269,7 @@ class IdleQueue: Remove alarm callback alarm_cb scheduled on alarm_time. Returns True if it was removed sucessfully, otherwise False """ - if not alarm_time in self.alarms: + if alarm_time not in self.alarms: return False i = -1 for i in range(len(self.alarms[alarm_time])): @@ -278,7 +278,7 @@ class IdleQueue: break if i != -1: del self.alarms[alarm_time][i] - if self.alarms[alarm_time] == []: + if not self.alarms[alarm_time]: del self.alarms[alarm_time] return True else:
===================================== nbxmpp/plugin.py ===================================== --- a/nbxmpp/plugin.py +++ b/nbxmpp/plugin.py @@ -21,7 +21,8 @@ Provides PlugIn class functionality to develop extentions for xmpppy import logging log = logging.getLogger('nbxmpp.plugin')
-class PlugIn: + +class PlugIn(object): """ Abstract xmpppy plugin infrastructure code, providing plugging in/out and debugging functionality
===================================== nbxmpp/protocol.py ===================================== --- a/nbxmpp/protocol.py +++ b/nbxmpp/protocol.py @@ -605,7 +605,8 @@ stream_exceptions = {'bad-format': BadFormat, 'unsupported-version': UnsupportedVersion, 'xml-not-well-formed': XMLNotWellFormed}
-class JID: + +class JID(object): """ JID can be built from string, modified, compared, serialised into string """
===================================== nbxmpp/proxy_connectors.py ===================================== --- a/nbxmpp/proxy_connectors.py +++ b/nbxmpp/proxy_connectors.py @@ -27,7 +27,8 @@ from base64 import b64encode import logging log = logging.getLogger('nbxmpp.proxy_connectors')
-class ProxyConnector: + +class ProxyConnector(object): """ Interface for proxy-connecting object - when tunnneling XMPP over proxies, some connecting process usually has to be done before opening stream. Proxy
===================================== nbxmpp/roster_nb.py ===================================== --- a/nbxmpp/roster_nb.py +++ b/nbxmpp/roster_nb.py @@ -74,7 +74,7 @@ class NonBlockingRoster(PlugIn): roster representation """ sender = stanza.getAttr('from') - if not sender is None and not sender.bareMatch( + if sender is not None and not sender.bareMatch( self._owner.User + '@' + self._owner.Server): return query = stanza.getTag('query')
===================================== nbxmpp/simplexml.py ===================================== --- a/nbxmpp/simplexml.py +++ b/nbxmpp/simplexml.py @@ -485,7 +485,8 @@ class Node(object): return self.NT raise AttributeError
-class T: + +class T(object): """ Auxiliary class used to quick access to node's child nodes """ @@ -519,7 +520,8 @@ class NT(T): else: return self.node.addChild(attr, payload=[val])
-class NodeBuilder: + +class NodeBuilder(object): """ Builds a Node class minidom from data parsed to it. This class used for two purposes:
===================================== nbxmpp/smacks.py ===================================== --- a/nbxmpp/smacks.py +++ b/nbxmpp/smacks.py @@ -3,14 +3,15 @@ from .protocol import NS_STREAM_MGMT import logging log = logging.getLogger('nbxmpp.smacks')
-class Smacks(): - ''' + +class Smacks(object): + """ This is Smacks is the Stream Management class. It takes care of requesting and sending acks. Also, it keeps track of the unhandled outgoing stanzas.
The dispatcher has to be able to access this class to increment the number of handled stanzas - ''' + """
def __init__(self, con): self.con = con # Connection object
===================================== nbxmpp/stringprepare.py ===================================== --- a/nbxmpp/stringprepare.py +++ b/nbxmpp/stringprepare.py @@ -25,7 +25,8 @@ import stringprep import unicodedata from encodings import idna
-class ILookupTable: + +class ILookupTable(object): """ Interface for character lookup classes """ @@ -36,7 +37,8 @@ class ILookupTable: """ pass
-class IMappingTable: + +class IMappingTable(object): """ Interface for character mapping classes """ @@ -47,15 +49,15 @@ class IMappingTable: """ pass
-class LookupTableFromFunction:
+class LookupTableFromFunction(object): __implements__ = ILookupTable
def __init__(self, in_table_function): self.lookup = in_table_function
-class LookupTable:
+class LookupTable(object): __implements__ = ILookupTable
def __init__(self, table): @@ -64,15 +66,15 @@ class LookupTable: def lookup(self, c): return c in self._table
-class MappingTableFromFunction:
+class MappingTableFromFunction(object): __implements__ = IMappingTable
def __init__(self, map_table_function): self.map = map_table_function
-class EmptyMappingTable:
+class EmptyMappingTable(object): __implements__ = IMappingTable
def __init__(self, in_table_function): @@ -149,7 +151,7 @@ class Profile: raise UnicodeError("Violation of BIDI Requirement 3")
-class NamePrep: +class NamePrep(object): """ Implements preparation of internationalized domain names
===================================== nbxmpp/tls_nb.py ===================================== --- a/nbxmpp/tls_nb.py +++ b/nbxmpp/tls_nb.py @@ -56,7 +56,7 @@ def gattr(obj, attr, default=None): return default
-class SSLWrapper: +class SSLWrapper(object): """ Abstract SSLWrapper base class """
View it on GitLab: http://dev.gajim.org/gajim/python-nbxmpp/compare/eb88300ee0d1767ddc0e6ace4f1...