Commit bda8f905 authored by Yann Leboulanger's avatar Yann Leboulanger

[NooN8] simplify arithmetic. See #38

parent 1accf16a
......@@ -101,7 +101,7 @@ class NonBlockingBOSH(NonBlockingTransport):
NonBlockingTransport.connect(self, conn_5tuple, on_connect, on_connect_failure)
global FAKE_DESCRIPTOR
FAKE_DESCRIPTOR = FAKE_DESCRIPTOR - 1
FAKE_DESCRIPTOR -= 1
self.fd = FAKE_DESCRIPTOR
self.stanza_buffer = []
......
......@@ -28,7 +28,7 @@ def c14n(node, is_buggy):
s = "<" + node.name
if node.namespace:
if not node.parent or node.parent.namespace != node.namespace:
s = s + ' xmlns="%s"' % node.namespace
s += ' xmlns="%s"' % node.namespace
sorted_attrs = sorted(node.attrs.keys())
for key in sorted_attrs:
......@@ -36,15 +36,15 @@ def c14n(node, is_buggy):
continue
val = ustr(node.attrs[key])
# like XMLescape() but with whitespace and without &gt;
s = s + ' %s="%s"' % ( key, normalise_attr(val) )
s = s + ">"
s += ' %s="%s"' % (key, normalise_attr(val))
s += ">"
cnt = 0
if node.kids:
for a in node.kids:
if (len(node.data)-1) >= cnt:
s = s + normalise_text(node.data[cnt])
s = s + c14n(a, is_buggy)
cnt=cnt+1
cnt += 1
if (len(node.data)-1) >= cnt: s = s + normalise_text(node.data[cnt])
if not node.kids and s.endswith('>'):
s=s[:-1]+' />'
......
......@@ -273,9 +273,9 @@ class NonBlockingClient:
"""
if err_message:
log.debug('While looping over DNS A records: %s' % err_message)
if self.ip_addresses == []:
if not self.ip_addresses:
msg = 'Run out of hosts for name %s:%s.' % (self.Server, self.Port)
msg = msg + ' Error for last IP: %s' % err_message
msg += ' Error for last IP: %s' % err_message
self.disconnect(msg)
else:
self.current_ip = self.ip_addresses.pop(0)
......
......@@ -458,7 +458,7 @@ class XMPPDispatcher(PlugIn):
stanza.getName() != 'a' and stanza.getName() != 'enabled' and
stanza.getName() != 'resumed'):
# increments the number of stanzas that has been handled
self.sm.in_h = self.sm.in_h + 1
self.sm.in_h += 1
list_ = ['default'] # we will use all handlers:
if typ in self.handlers[xmlns][name]:
list_.append(typ) # from very common...
......@@ -571,7 +571,7 @@ class XMPPDispatcher(PlugIn):
# If no ID then it is a whitespace
if self.sm and self.sm.enabled and ID:
self.sm.uqueue.append(stanza)
self.sm.out_h = self.sm.out_h + 1
self.sm.out_h += 1
if len(self.sm.uqueue) > self.sm.max_queue:
self.sm.request_ack()
......
......@@ -195,7 +195,8 @@ class SOCKS5Connector(ProxyConnector):
# # Resolve locally
# self.ipaddr = socket.inet_aton(socket.gethostbyname(self.xmpp_server[0]))
# req = req + "\x01" + ipaddr
req = req + struct.pack(">H", self.xmpp_server[1])
req += struct.pack(">H", self.xmpp_server[1])
self.onreceive(self._on_req_sent)
self.send(req)
......
......@@ -120,7 +120,8 @@ class SSLWrapper:
if self.exc_str:
if self.strerror:
s += "(%s)" % self.exc_str
else: s += "(%s)" % str(self.exc_args)
else:
s += "(%s)" % str(self.exc_args)
return s
def __init__(self, sslobj, sock=None):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment