[thorstenp] use != instead of <>
This commit is contained in:
parent
196dd7e30a
commit
992e90208e
15 changed files with 31 additions and 31 deletions
|
@ -124,7 +124,7 @@ class OldEntry(xmpp.Node, object):
|
|||
''' Get the uri the entry points to (entry's first link element with rel='alternate'
|
||||
or without rel attribute). '''
|
||||
for element in self.getTags('link'):
|
||||
if 'rel' in element.attrs and element.attrs['rel']<>'alternate': continue
|
||||
if 'rel' in element.attrs and element.attrs['rel']!='alternate': continue
|
||||
try:
|
||||
return element.attrs['href']
|
||||
except AttributeError:
|
||||
|
|
|
@ -152,7 +152,7 @@ class SASL(PlugIn):
|
|||
|
||||
def SASLHandler(self,conn,challenge):
|
||||
""" Perform next SASL auth step. Used internally. """
|
||||
if challenge.getNamespace()<>NS_SASL: return
|
||||
if challenge.getNamespace()!=NS_SASL: return
|
||||
if challenge.getName()=='failure':
|
||||
self.startsasl='failure'
|
||||
try: reason=challenge.getChildren()[0]
|
||||
|
|
|
@ -168,7 +168,7 @@ class SASL(PlugIn):
|
|||
|
||||
def SASLHandler(self, conn, challenge):
|
||||
''' Perform next SASL auth step. Used internally. '''
|
||||
if challenge.getNamespace() <> NS_SASL:
|
||||
if challenge.getNamespace() != NS_SASL:
|
||||
return
|
||||
if challenge.getName() == 'failure':
|
||||
self.startsasl = 'failure'
|
||||
|
|
|
@ -112,8 +112,8 @@ class Browser(PlugIn):
|
|||
if node is None: node=[None]
|
||||
else: node=node.replace('/',' /').split('/')
|
||||
for i in node:
|
||||
if i<>'' and i in cur: cur=cur[i]
|
||||
elif set and i<>'': cur[i]={dict:cur,str:i}; cur=cur[i]
|
||||
if i!='' and i in cur: cur=cur[i]
|
||||
elif set and i!='': cur[i]={dict:cur,str:i}; cur=cur[i]
|
||||
elif set or '' in cur: return cur,''
|
||||
else: return None,None
|
||||
if 1 in cur or set: return cur,1
|
||||
|
|
|
@ -104,7 +104,7 @@ class CommonClient:
|
|||
# Who initiated this client
|
||||
# Used to register the EventDispatcher
|
||||
self._caller=caller
|
||||
if debug and type(debug)<>list: debug=['always', 'nodebuilder']
|
||||
if debug and type(debug)!=list: debug=['always', 'nodebuilder']
|
||||
self._DEBUG=Debug.Debug(debug)
|
||||
self.DEBUG=self._DEBUG.Show
|
||||
self.debug_flags=self._DEBUG.debug_flags
|
||||
|
@ -203,7 +203,7 @@ class Client(CommonClient):
|
|||
If you want to disable tls/ssl support completely, set it to 0.
|
||||
Example: connect(('192.168.5.5',5222),{'host':'proxy.my.net','port':8080,'user':'me','password':'secret'})
|
||||
Returns '' or 'tcp' or 'tls', depending on the result."""
|
||||
if not CommonClient.connect(self,server,proxy,secure,use_srv) or secure<>None and not secure: return self.connected
|
||||
if not CommonClient.connect(self,server,proxy,secure,use_srv) or secure!=None and not secure: return self.connected
|
||||
transports.TLS().PlugIn(self)
|
||||
if 'version' not in self.Dispatcher.Stream._document_attrs or not self.Dispatcher.Stream._document_attrs['version']=='1.0': return self.connected
|
||||
while not self.Dispatcher.Stream.features and self.Process(): pass # If we get version 1.0 stream the features tag MUST BE presented
|
||||
|
|
|
@ -329,7 +329,7 @@ class Debug:
|
|||
|
||||
This code organises lst and remves dupes
|
||||
"""
|
||||
if type( items ) <> type( [] ) and type( items ) <> type( () ):
|
||||
if type( items ) != type( [] ) and type( items ) != type( () ):
|
||||
return [ items ]
|
||||
r = []
|
||||
for l in items:
|
||||
|
@ -346,7 +346,7 @@ class Debug:
|
|||
|
||||
def _append_unique_str( self, lst, item ):
|
||||
"""filter out any dupes."""
|
||||
if type(item) <> type(''):
|
||||
if type(item) != type(''):
|
||||
msg2 = '%s' % item
|
||||
raise 'Invalid item type (should be string)',msg2
|
||||
if item not in lst:
|
||||
|
|
|
@ -107,7 +107,7 @@ class Dispatcher(PlugIn):
|
|||
self._owner.send("<?xml version='1.0'?>%s>"%str(self._metastream)[:-2])
|
||||
|
||||
def _check_stream_start(self,ns,tag,attrs):
|
||||
if ns<>NS_STREAMS or tag<>'stream':
|
||||
if ns!=NS_STREAMS or tag!='stream':
|
||||
raise ValueError('Incorrect stream start: (%s,%s). Terminating.'%(tag,ns))
|
||||
|
||||
def Process(self, timeout=0):
|
||||
|
@ -300,7 +300,7 @@ class Dispatcher(PlugIn):
|
|||
session.DEBUG("Expected stanza arrived. Callback %s(%s) found!"%(cb,args),'ok')
|
||||
try: cb(session,stanza,**args)
|
||||
except Exception, typ:
|
||||
if typ.__class__.__name__<>'NodeProcessed': raise
|
||||
if typ.__class__.__name__!='NodeProcessed': raise
|
||||
else:
|
||||
session.DEBUG("Expected stanza arrived!",'ok')
|
||||
session._expected[ID]=stanza
|
||||
|
@ -310,7 +310,7 @@ class Dispatcher(PlugIn):
|
|||
try:
|
||||
handler['func'](session,stanza)
|
||||
except Exception, typ:
|
||||
if typ.__class__.__name__<>'NodeProcessed':
|
||||
if typ.__class__.__name__!='NodeProcessed':
|
||||
self._pendingExceptions.insert(0, sys.exc_info())
|
||||
return
|
||||
user=0
|
||||
|
|
|
@ -117,7 +117,7 @@ class Dispatcher(PlugIn):
|
|||
self._owner.send("<?xml version='1.0'?>%s>" % str(self._metastream)[:-2])
|
||||
|
||||
def _check_stream_start(self, ns, tag, attrs):
|
||||
if ns<>NS_STREAMS or tag<>'stream':
|
||||
if ns!=NS_STREAMS or tag!='stream':
|
||||
raise ValueError('Incorrect stream start: (%s,%s). Terminating.' % (tag, ns))
|
||||
|
||||
def ProcessNonBlocking(self, data=None):
|
||||
|
@ -343,7 +343,7 @@ class Dispatcher(PlugIn):
|
|||
try:
|
||||
cb(session,stanza,**args)
|
||||
except Exception, typ:
|
||||
if typ.__class__.__name__ <>'NodeProcessed': raise
|
||||
if typ.__class__.__name__ !='NodeProcessed': raise
|
||||
else:
|
||||
session.DEBUG("Expected stanza arrived!",'ok')
|
||||
session._expected[ID]=stanza
|
||||
|
@ -354,7 +354,7 @@ class Dispatcher(PlugIn):
|
|||
try:
|
||||
handler['func'](session,stanza)
|
||||
except Exception, typ:
|
||||
if typ.__class__.__name__ <> 'NodeProcessed':
|
||||
if typ.__class__.__name__ != 'NodeProcessed':
|
||||
self._pendingExceptions.insert(0, sys.exc_info())
|
||||
return
|
||||
user=0
|
||||
|
|
|
@ -101,7 +101,7 @@ def _ReceivedRegInfo(con, resp, agent):
|
|||
return
|
||||
df=DataForm(typ='form')
|
||||
for i in resp.getQueryPayload():
|
||||
if type(i)<>type(iq): pass
|
||||
if type(i)!=type(iq): pass
|
||||
elif i.getName()=='instructions': df.addInstructions(i.getData())
|
||||
else: df.setField(i.getName()).setValue(i.getData())
|
||||
con.Event(NS_REGISTER,REGISTER_DATA_RECEIVED,(agent,df,False))
|
||||
|
@ -114,7 +114,7 @@ def register(disp,host,info):
|
|||
attributes lastErrNode, lastErr and lastErrCode.
|
||||
"""
|
||||
iq=Iq('set',NS_REGISTER,to=host)
|
||||
if type(info)<>type({}): info=info.asDict()
|
||||
if type(info)!=type({}): info=info.asDict()
|
||||
for i in info.keys(): iq.setTag('query').setTagData(i,info[i])
|
||||
resp=disp.SendAndWaitForResponse(iq)
|
||||
if isResultNode(resp): return 1
|
||||
|
|
|
@ -147,7 +147,7 @@ class IBB(PlugIn):
|
|||
else:
|
||||
stream=self._streams[sid]
|
||||
if not data: err=ERR_BAD_REQUEST
|
||||
elif seq<>stream['seq']: err=ERR_UNEXPECTED_REQUEST
|
||||
elif seq!=stream['seq']: err=ERR_UNEXPECTED_REQUEST
|
||||
else:
|
||||
self.DEBUG('Successfull receive sid->%s %s+%s bytes'%(sid,stream['fp'].tell(),len(data)),'ok')
|
||||
stream['seq']+=1
|
||||
|
|
|
@ -372,7 +372,7 @@ class Protocol(Node):
|
|||
errtag=self.getTag('error')
|
||||
if errtag:
|
||||
for tag in errtag.getChildren():
|
||||
if tag.getName()<>'text': return tag.getName()
|
||||
if tag.getName()!='text': return tag.getName()
|
||||
return errtag.getData()
|
||||
def getErrorMsg(self):
|
||||
""" Return the textual description of the error (if present) or the error condition """
|
||||
|
|
|
@ -238,9 +238,9 @@ class Session:
|
|||
self.sendnow(text+'>')
|
||||
self.set_stream_state(STREAM__OPENED)
|
||||
if self.TYP=='client': return
|
||||
if tag<>'stream': return self.terminate_stream(STREAM_INVALID_XML)
|
||||
if ns<>NS_STREAMS: return self.terminate_stream(STREAM_INVALID_NAMESPACE)
|
||||
if self.Stream.xmlns<>self.xmlns: return self.terminate_stream(STREAM_BAD_NAMESPACE_PREFIX)
|
||||
if tag!='stream': return self.terminate_stream(STREAM_INVALID_XML)
|
||||
if ns!=NS_STREAMS: return self.terminate_stream(STREAM_INVALID_NAMESPACE)
|
||||
if self.Stream.xmlns!=self.xmlns: return self.terminate_stream(STREAM_BAD_NAMESPACE_PREFIX)
|
||||
if 'to' not in attrs: return self.terminate_stream(STREAM_IMPROPER_ADDRESSING)
|
||||
if attrs['to'] not in self._owner.servernames: return self.terminate_stream(STREAM_HOST_UNKNOWN)
|
||||
self.ourname=attrs['to'].lower()
|
||||
|
@ -320,7 +320,7 @@ class Session:
|
|||
|
||||
def stop_feature(self,f):
|
||||
""" Declare some feature as "negotiated" to allow other features start negotiating. """
|
||||
if self.feature_in_process<>f: raise "Stopping feature %s instead of %s !"%(f,self.feature_in_process)
|
||||
if self.feature_in_process!=f: raise "Stopping feature %s instead of %s !"%(f,self.feature_in_process)
|
||||
self.feature_in_process=None
|
||||
|
||||
def set_socket_state(self,newstate):
|
||||
|
|
|
@ -30,7 +30,7 @@ def ustr(what):
|
|||
if isinstance(what, unicode): return what
|
||||
try: r=what.__str__()
|
||||
except AttributeError: r=str(what)
|
||||
if type(r)<>type(u''): return unicode(r,ENCODING)
|
||||
if type(r)!=type(u''): return unicode(r,ENCODING)
|
||||
return r
|
||||
|
||||
class Node(object):
|
||||
|
@ -214,10 +214,10 @@ class Node(object):
|
|||
Returns the list of nodes found. """
|
||||
nodes=[]
|
||||
for node in self.kids:
|
||||
if namespace and namespace<>node.getNamespace(): continue
|
||||
if namespace and namespace!=node.getNamespace(): continue
|
||||
if node.getName() == name:
|
||||
for key in attrs.keys():
|
||||
if key not in node.attrs or node.attrs[key]<>attrs[key]: break
|
||||
if key not in node.attrs or node.attrs[key]!=attrs[key]: break
|
||||
else: nodes.append(node)
|
||||
if one and nodes: return nodes[0]
|
||||
if not one: return nodes
|
||||
|
|
|
@ -139,7 +139,7 @@ class TCPsocket(PlugIn):
|
|||
""" Writes raw outgoing data. Blocks until done.
|
||||
If supplied data is unicode string, encodes it to utf-8 before send."""
|
||||
if isinstance(raw_data, unicode): raw_data = raw_data.encode('utf-8')
|
||||
elif type(raw_data)<>type(str): raw_data = ustr(raw_data).encode('utf-8')
|
||||
elif type(raw_data)!=type(str): raw_data = ustr(raw_data).encode('utf-8')
|
||||
try:
|
||||
self._send(raw_data)
|
||||
# Avoid printing messages that are empty keepalive packets.
|
||||
|
@ -207,7 +207,7 @@ class HTTPPROXYsocket(TCPsocket):
|
|||
return
|
||||
try: proto,code,desc=reply.split('\n')[0].split(' ',2)
|
||||
except: raise error('Invalid proxy reply')
|
||||
if code<>'200':
|
||||
if code!='200':
|
||||
self.DEBUG('Invalid proxy reply: %s %s %s'%(proto,code,desc),'error')
|
||||
self._owner.disconnected()
|
||||
return
|
||||
|
@ -278,7 +278,7 @@ class TLS(PlugIn):
|
|||
def StartTLSHandler(self, conn, starttls):
|
||||
""" Handle server reply if TLS is allowed to process. Behaves accordingly.
|
||||
Used internally."""
|
||||
if starttls.getNamespace()<>NS_TLS: return
|
||||
if starttls.getNamespace()!=NS_TLS: return
|
||||
self.starttls=starttls.getName()
|
||||
if self.starttls=='failure':
|
||||
self.DEBUG("Got starttls response: "+self.starttls,'error')
|
||||
|
|
|
@ -850,7 +850,7 @@ class NonBlockingTLS(PlugIn):
|
|||
def StartTLSHandler(self, conn, starttls):
|
||||
''' Handle server reply if TLS is allowed to process. Behaves accordingly.
|
||||
Used internally.'''
|
||||
if starttls.getNamespace() <> NS_TLS:
|
||||
if starttls.getNamespace() != NS_TLS:
|
||||
return
|
||||
self.starttls = starttls.getName()
|
||||
if self.starttls == 'failure':
|
||||
|
@ -925,7 +925,7 @@ class NBHTTPPROXYsocket(NonBlockingTcp):
|
|||
#traceback.print_exc()
|
||||
self.on_proxy_failure('Invalid proxy reply')
|
||||
return
|
||||
if code <> '200':
|
||||
if code != '200':
|
||||
self.DEBUG('Invalid proxy reply: %s %s %s' % (proto, code, desc),'error')
|
||||
self._owner.disconnected()
|
||||
self.on_proxy_failure('Invalid proxy reply')
|
||||
|
|
Loading…
Add table
Reference in a new issue