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-09 21:41:52 +0400
committeralkorgun <alkorgun@gmail.com>2014-01-09 21:41:52 +0400
commit064b2195afabefe133f9dd202037011f9d0367e4 (patch)
tree285f8b1f7e658c63214cc148936c06ba97690468
parentbd8d688c92b84c417f5cb1a9d5430111c43cb27d (diff)
some code cleanup
-rw-r--r--xmpp/auth.py6
-rw-r--r--xmpp/commands.py32
-rw-r--r--xmpp/simplexml.py2
3 files changed, 20 insertions, 20 deletions
diff --git a/xmpp/auth.py b/xmpp/auth.py
index ca21835..56b5a89 100644
--- a/xmpp/auth.py
+++ b/xmpp/auth.py
@@ -235,7 +235,7 @@ class SASL(PlugIn):
resp["realm"] = self._owner.Server
resp["nonce"] = chal["nonce"]
cnonce = ""
- for i in range(7):
+ for i in xrange(7):
cnonce += hex(int(_random() * 65536 * 4096))[2:]
resp["cnonce"] = cnonce
resp["nc"] = ("00000001")
@@ -247,8 +247,8 @@ class SASL(PlugIn):
resp["response"] = response
resp["charset"] = "utf-8"
sasl_data = ""
- for key in ["charset", "username", "realm", "nonce", "nc", "cnonce", "digest-uri", "response", "qop"]:
- if key in ["nc", "qop", "response", "charset"]:
+ for key in ("charset", "username", "realm", "nonce", "nc", "cnonce", "digest-uri", "response", "qop"):
+ if key in ("nc", "qop", "response", "charset"):
sasl_data += "%s=%s," % (key, resp[key])
else:
sasl_data += "%s=\"%s\"," % (key, resp[key])
diff --git a/xmpp/commands.py b/xmpp/commands.py
index 9c75649..898351b 100644
--- a/xmpp/commands.py
+++ b/xmpp/commands.py
@@ -95,13 +95,13 @@ class Commands(PlugIn):
except Exception:
conn.send(Error(request, ERR_BAD_REQUEST))
raise NodeProcessed()
- if self._handlers.has_key(jid):
- if self._handlers[jid].has_key(node):
+ if jid in self._handlers:
+ if node in self._handlers[jid]:
self._handlers[jid][node]["execute"](conn, request)
else:
conn.send(Error(request, ERR_ITEM_NOT_FOUND))
raise NodeProcessed()
- elif self._handlers[""].has_key(node):
+ elif node in self._handlers[""]:
self._handlers[""][node]["execute"](conn, request)
else:
conn.send(Error(request, ERR_ITEM_NOT_FOUND))
@@ -124,7 +124,7 @@ class Commands(PlugIn):
items = []
jid = str(request.getTo())
# Get specific jid based results
- if self._handlers.has_key(jid):
+ if jid in self._handlers:
for each in self._handlers[jid].keys():
items.append((jid, each))
else:
@@ -160,10 +160,10 @@ class Commands(PlugIn):
# We must:
# Add item into disco
# Add item into command list
- if not self._handlers.has_key(jid):
+ if jid not in self._handlers:
self._handlers[jid] = {}
self._browser.setDiscoHandler(self._DiscoHandler, node=NS_COMMANDS, jid=jid)
- if self._handlers[jid].has_key(name):
+ if name in self._handlers[jid]:
raise NameError("Command Exists")
self._handlers[jid][name] = {"disco": cmddisco, "execute": cmdexecute}
# Need to add disco stuff here
@@ -177,9 +177,9 @@ class Commands(PlugIn):
# We must:
# Remove item from disco
# Remove item from command list
- if not self._handlers.has_key(jid):
+ if jid not in self._handlers:
raise NameError("Jid not found")
- if not self._handlers[jid].has_key(name):
+ if name not in self._handlers[jid]:
raise NameError("Command not found")
# Do disco removal here
command = self.getCommand(name, jid)["disco"]
@@ -193,9 +193,9 @@ class Commands(PlugIn):
# This gets the command object with name
# We must:
# Return item that matches this name
- if not self._handlers.has_key(jid):
+ if jid not in self._handlers:
raise NameError("Jid not found")
- if not self._handlers[jid].has_key(name):
+ if name not in self._handlers[jid]:
raise NameError("Command not found")
return self._handlers[jid][name]
@@ -277,10 +277,10 @@ class Command_Handler_Prototype(PlugIn):
if action == None:
action = "execute"
# Check session is in session list
- if self.sessions.has_key(session):
+ if session in self.sessions:
if self.sessions[session]["jid"] == request.getFrom():
# Check action is vaild
- if self.sessions[session]["actions"].has_key(action):
+ if action in self.sessions[session]["actions"]:
# Execute next action
self.sessions[session]["actions"][action](conn, request)
else:
@@ -299,15 +299,15 @@ class Command_Handler_Prototype(PlugIn):
# New session
self.initial[action](conn, request)
- def _DiscoHandler(self, conn, request, type):
+ def _DiscoHandler(self, conn, request, typ):
"""
The handler for discovery events.
"""
- if type == "list":
+ if typ == "list":
result = (request.getTo(), self.name, self.description)
- elif type == "items":
+ elif typ == "items":
result = []
- elif type == "info":
+ elif typ == "info":
result = self.discoinfo
return result
diff --git a/xmpp/simplexml.py b/xmpp/simplexml.py
index a416d24..b50059b 100644
--- a/xmpp/simplexml.py
+++ b/xmpp/simplexml.py
@@ -301,7 +301,7 @@ class Node(object):
["text1", <nodea instance>, <nodeb instance>, " text2"].
"""
pl = []
- for i in range(max(len(self.data), len(self.kids))):
+ for i in xrange(max(len(self.data), len(self.kids))):
if i < len(self.data) and self.data[i]:
pl.append(self.data[i])
if i < len(self.kids) and self.kids[i]: