Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mrDoctorWho/xmpppy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralkorgun <alkorgun@gmail.com>2014-01-10 00:01:43 +0400
committeralkorgun <alkorgun@gmail.com>2014-01-10 00:01:43 +0400
commited02f5d02d0e2da7cccc1bb505d3c9385cd1af3d (patch)
tree6b2a57e042cc50ea6f20bd52c6a191a7e1f0352b
parent801b977271d72372b69e002a4d949c9f869d8e91 (diff)
more and more code cleanup
-rw-r--r--xmpp/auth.py19
-rw-r--r--xmpp/browser.py2
-rw-r--r--xmpp/commands.py2
-rw-r--r--xmpp/debug.py4
-rw-r--r--xmpp/simplexml.py6
5 files changed, 16 insertions, 17 deletions
diff --git a/xmpp/auth.py b/xmpp/auth.py
index 56b5a89..7042d42 100644
--- a/xmpp/auth.py
+++ b/xmpp/auth.py
@@ -20,20 +20,19 @@ Can be used both for client and transport authentication.
"""
import dispatcher
-import sha
+import hashlib
from base64 import encodestring, decodestring
-from hashlib import md5 as __md5
from plugin import PlugIn
from protocol import *
from random import random as _random
from re import findall as re_findall
def HH(some):
- return __md5(some).hexdigest()
+ return hashlib.md5(some).hexdigest()
def H(some):
- return __md5(some).digest()
+ return hashlib.md5(some).digest()
def C(some):
return ":".join(some)
@@ -70,7 +69,8 @@ class NonSASL(PlugIn):
query.setTagData("resource", self.resource)
if query.getTag("digest"):
self.DEBUG("Performing digest authentication", "ok")
- query.setTagData("digest", sha.new(owner.Dispatcher.Stream._document_attrs["id"] + self.password).hexdigest())
+ hash = hashlib.sha1(owner.Dispatcher.Stream._document_attrs["id"] + self.password).hexdigest()
+ query.setTagData("digest", hash)
if query.getTag("password"):
query.delChild("password")
method = "digest"
@@ -78,9 +78,9 @@ class NonSASL(PlugIn):
token = query.getTagData("token")
seq = query.getTagData("sequence")
self.DEBUG("Performing zero-k authentication", "ok")
- hash = sha.new(sha.new(self.password).hexdigest() + token).hexdigest()
- for foo in xrange(int(seq)):
- hash = sha.new(hash).hexdigest()
+ hash = hashlib.sha1(hashlib.sha1(self.password).hexdigest() + token).hexdigest()
+ for i in xrange(int(seq)):
+ hash = hashlib.sha1(hash).hexdigest()
query.setTagData("hash", hash)
method = "0k"
else:
@@ -101,7 +101,8 @@ class NonSASL(PlugIn):
Authenticate component. Send handshake stanza and wait for result. Returns "ok" on success.
"""
self.handshake = 0
- owner.send(Node(NS_COMPONENT_ACCEPT + " handshake", payload=[sha.new(owner.Dispatcher.Stream._document_attrs["id"] + self.password).hexdigest()]))
+ hash = hashlib.sha1(owner.Dispatcher.Stream._document_attrs["id"] + self.password).hexdigest()
+ owner.send(Node(NS_COMPONENT_ACCEPT + " handshake", payload=[hash]))
owner.RegisterHandler("handshake", self.handshakeHandler, xmlns=NS_COMPONENT_ACCEPT)
while not self.handshake:
self.DEBUG("waiting on handshake", "notify")
diff --git a/xmpp/browser.py b/xmpp/browser.py
index d2ffdf0..db74131 100644
--- a/xmpp/browser.py
+++ b/xmpp/browser.py
@@ -122,7 +122,7 @@ class Browser(PlugIn):
get returns "" or None as the key or None as the dict.
Used internally.
"""
- if self._handlers.has_key(jid):
+ if jid in self._handlers:
cur = self._handlers[jid]
elif set:
self._handlers[jid] = {}
diff --git a/xmpp/commands.py b/xmpp/commands.py
index 898351b..3d4f75c 100644
--- a/xmpp/commands.py
+++ b/xmpp/commands.py
@@ -258,7 +258,7 @@ class Command_Handler_Prototype(PlugIn):
"""
Returns an id for the command session.
"""
- self.count = self.count + 1
+ self.count += 1
return "cmd-%s-%d" % (self.name, self.count)
def Execute(self, conn, request):
diff --git a/xmpp/debug.py b/xmpp/debug.py
index e84b4c1..ccccd02 100644
--- a/xmpp/debug.py
+++ b/xmpp/debug.py
@@ -162,13 +162,13 @@ class Debug:
self._fh.write(output)
except Exception:
# unicode strikes again ;)
- s = u""
+ s = unicode()
for i in xrange(len(output)):
if ord(output[i]) < 128:
c = output[i]
else:
c = "?"
- s = s + c
+ s += c
self._fh.write("%s%s%s" % (pre, s, suf))
self._fh.flush()
diff --git a/xmpp/simplexml.py b/xmpp/simplexml.py
index b50059b..a1ad7ac 100644
--- a/xmpp/simplexml.py
+++ b/xmpp/simplexml.py
@@ -25,8 +25,6 @@ import xml.parsers.expat
XML_ls = (
("&", "&amp;"),
- ("\x0C", ""),
- ("\x1B", ""),
("<", "&lt;"),
(">", "&gt;"),
('"', "&quot;"),
@@ -108,7 +106,7 @@ class Node(object):
self.nsp_cache[k] = v
for attr, val in attrs.items():
if attr == "xmlns":
- self.nsd[u""] = val
+ self.nsd[""] = val
elif attr.startswith("xmlns:"):
self.nsd[attr[6:]] = val
self.attrs[attr] = attrs[attr]
@@ -216,7 +214,7 @@ class Node(object):
if namespace:
newnode.setNamespace(namespace)
self.kids.append(newnode)
- self.data.append(u"")
+ self.data.append("")
return newnode
def addData(self, data):