da67f52
diff --git jabberpy-0.5-0/jabber/__init__.py jabberpy-0.5-0/jabber/__init__.py
da67f52
index ba26086..8d134bd 100644
da67f52
--- jabberpy-0.5-0/jabber/__init__.py
da67f52
+++ jabberpy-0.5-0/jabber/__init__.py
da67f52
@@ -1,6 +1,10 @@
da67f52
-__all__ = []
da67f52
+import sys
da67f52
+if sys.version_info[0] == 3:
da67f52
+    from . import jabber
da67f52
+else:
da67f52
+    import jabber
da67f52
 
da67f52
-import jabber
da67f52
+__all__ = []
da67f52
 
da67f52
 for __s in dir(jabber):
da67f52
     __val = getattr(jabber, __s)
d0c35a6
diff --git jabberpy-0.5-0/jabber/debug.py jabberpy-0.5-0/jabber/debug.py
da67f52
index 4615697..b9ee00d 100644
d0c35a6
--- jabberpy-0.5-0/jabber/debug.py
d0c35a6
+++ jabberpy-0.5-0/jabber/debug.py
da67f52
@@ -41,9 +41,13 @@ in this code
da67f52
 
da67f52
 import sys
d0c35a6
 import time
da67f52
-from string import join
d0c35a6
 
d0c35a6
-import types
d0c35a6
+if sys.version_info[0] == 3:
d0c35a6
+    StringType = (str, bytes)
d0c35a6
+    UnicodeType = str
d0c35a6
+else:
d0c35a6
+    StringType = basestring
d0c35a6
+    UnicodeType = unicode
d0c35a6
 
d0c35a6
 
d0c35a6
 debug_flags = []
da67f52
@@ -164,10 +168,10 @@ class Debug:
d0c35a6
                   ):
d0c35a6
 
d0c35a6
         if type(active_flags) not in [type([]), type(())]:
d0c35a6
-            print  '***' 
d0c35a6
-            print  '*** Invalid or oldformat debug param given: %s' % active_flags
d0c35a6
-            print  '*** please correct your param, should be of [] type!'
d0c35a6
-            print  '*** Due to this, full debuging is enabled'
d0c35a6
+            print('***')
d0c35a6
+            print('*** Invalid or oldformat debug param given: %s' % active_flags)
d0c35a6
+            print('*** please correct your param, should be of [] type!')
d0c35a6
+            print('*** Due to this, full debuging is enabled')
d0c35a6
             active_flags=[DBG_ALWAYS]
d0c35a6
 
d0c35a6
         if welcome == -1:
da67f52
@@ -182,7 +186,7 @@ class Debug:
d0c35a6
                 try:
d0c35a6
                     self._fh = open(log_file,'w')
d0c35a6
                 except:
d0c35a6
-                    print 'ERROR: can open %s for writing'
d0c35a6
+                    print('ERROR: can open %s for writing')
d0c35a6
                     sys.exit(0)
d0c35a6
             else: ## assume its a stream type object
d0c35a6
                 self._fh = log_file
da67f52
@@ -190,8 +194,7 @@ class Debug:
895cf7f
             self._fh = sys.stdout
895cf7f
          
895cf7f
         if time_stamp not in (0,1,2):
895cf7f
-            msg2 = '%s' % time_stamp
895cf7f
-            raise 'Invalid time_stamp param', msg2
895cf7f
+            raise Exception('Invalid time_stamp param: %s' % time_stamp)
895cf7f
         self.prefix = prefix
895cf7f
         self.sufix = sufix
895cf7f
         self.time_stamp = time_stamp
da67f52
@@ -214,8 +217,7 @@ class Debug:
895cf7f
         if type(flag_show) in (type(''), type(None)):
895cf7f
             self.flag_show = flag_show
895cf7f
         else:
895cf7f
-            msg2 = '%s' % type(flag_show )
895cf7f
-            raise 'Invalid type for flag_show!', msg2
895cf7f
+            raise Exception('Invalid type for flag_show: %s' % type(flag_show))
895cf7f
 
895cf7f
 
895cf7f
         
da67f52
@@ -271,7 +273,7 @@ class Debug:
d0c35a6
                 # dont print "None", just show the separator
d0c35a6
                 output = '%s %s' % ( output, self.flag_show )
d0c35a6
 
d0c35a6
-        if type(msg)==type(u'') and self.encoding:
d0c35a6
+        if isinstance(msg, UnicodeType) and self.encoding:
d0c35a6
             msg=msg.encode(self.encoding, 'replace')
d0c35a6
 
d0c35a6
         output = '%s%s%s' % ( output, msg, suf )
da67f52
@@ -321,11 +323,11 @@ class Debug:
d0c35a6
         if not active_flags:
d0c35a6
             #no debuging at all
d0c35a6
             self.active = []
d0c35a6
-        elif type( active_flags ) in ( types.TupleType, types.ListType ):
d0c35a6
+        elif isinstance(active_flags, (tuple, list)):
d0c35a6
             flags = self._as_one_list( active_flags )
d0c35a6
             for t in flags:
d0c35a6
                 if t not in debug_flags:
d0c35a6
-                    print 'Invalid debugflag given', t
d0c35a6
+                    print('Invalid debugflag given', t)
d0c35a6
                 else:
d0c35a6
                     ok_flags.append( t )
d0c35a6
                 
da67f52
@@ -360,7 +362,7 @@ class Debug:
d0c35a6
         
d0c35a6
         This code organises lst and remves dupes
d0c35a6
         """
d0c35a6
-        if type( items ) <> type( [] ) and type( items ) <> type( () ):
d0c35a6
+        if not isinstance(items, (tuple, list)):
d0c35a6
             return [ items ]
d0c35a6
         r = []
d0c35a6
         for l in items:
da67f52
@@ -377,9 +379,8 @@ class Debug:
d0c35a6
     
d0c35a6
     def _append_unique_str( self, lst, item ):
d0c35a6
         """filter out any dupes."""
d0c35a6
-        if type(item) <> type(''):
895cf7f
-            msg2 = '%s' % item
895cf7f
-            raise 'Invalid item type (should be string)',msg2
895cf7f
+        if not isinstance(item, StringType):
895cf7f
+            raise Exception('Invalid item type (should be string): %s' % type(item))
d0c35a6
         if item not in lst:
895cf7f
             lst.append( item )
895cf7f
         return lst
da67f52
@@ -389,9 +390,8 @@ class Debug:
895cf7f
         'verify that flag is defined.'
895cf7f
         if flags:
895cf7f
             for f in self._as_one_list( flags ):
895cf7f
-                if not f in debug_flags:
895cf7f
-                    msg2 = '%s' % f
895cf7f
-                    raise 'Invalid debugflag given', msg2
895cf7f
+                if f not in debug_flags:
895cf7f
+                    raise Exception('Invalid debugflag given: %s' % f)
895cf7f
 
895cf7f
     def _remove_dupe_flags( self ):
895cf7f
         """
d0c35a6
diff --git jabberpy-0.5-0/jabber/jabber.py jabberpy-0.5-0/jabber/jabber.py
da67f52
index ab9d9b3..c6c97c7 100644
d0c35a6
--- jabberpy-0.5-0/jabber/jabber.py
d0c35a6
+++ jabberpy-0.5-0/jabber/jabber.py
da67f52
@@ -64,17 +64,23 @@ An example of usage for a simple client would be ( only psuedo code !)
d0c35a6
 
d0c35a6
 # $Id: jabber.py,v 1.58 2004/01/18 05:27:10 snakeru Exp $
d0c35a6
 
d0c35a6
-import xmlstream
d0c35a6
 import time
d0c35a6
 import hashlib
d0c35a6
+import sys
d0c35a6
+
d0c35a6
+if sys.version_info[0] == 3:
da67f52
+    from . import xmlstream
d0c35a6
+    StringType = (str, bytes)
d0c35a6
+    UnicodeType = str
d0c35a6
+else:
da67f52
+    import xmlstream
d0c35a6
+    StringType = basestring
d0c35a6
+    UnicodeType = unicode
d0c35a6
 
d0c35a6
 debug=xmlstream.debug
d0c35a6
 
895cf7f
 VERSION = xmlstream.VERSION
895cf7f
 
895cf7f
-False = 0;
895cf7f
-True  = 1;
895cf7f
-
895cf7f
 timeout = 300
895cf7f
 
895cf7f
 DBG_INIT, DBG_ALWAYS = debug.DBG_INIT, debug.DBG_ALWAYS
da67f52
@@ -179,14 +185,14 @@ RS_EXT_PENDING  = 0
d0c35a6
 def ustr(what):
d0c35a6
     """If sending object is already a unicode str, just
d0c35a6
        return it, otherwise convert it using xmlstream.ENCODING"""
d0c35a6
-    if type(what) == type(u''):
d0c35a6
+    if isinstance(what, UnicodeType):
d0c35a6
         r = what
d0c35a6
     else:
d0c35a6
         try: r = what.__str__()
d0c35a6
         except AttributeError: r = str(what)
d0c35a6
         # make sure __str__() didnt return a unicode
d0c35a6
-        if type(r) <> type(u''):
d0c35a6
-            r = unicode(r,xmlstream.ENCODING,'replace')
d0c35a6
+        if not isinstance(r, UnicodeType):
d0c35a6
+            r = UnicodeType(r,xmlstream.ENCODING,'replace')
d0c35a6
     return r
d0c35a6
 xmlstream.ustr = ustr
d0c35a6
 
da67f52
@@ -218,17 +224,17 @@ class Connection(xmlstream.Client):
d0c35a6
 
d0c35a6
     def setMessageHandler(self, func, type='', chainOutput=False):
d0c35a6
         """Back compartibility method"""
d0c35a6
-        print "WARNING! setMessageHandler(...) method is obsolette, use registerHandler('message',...) instead."
d0c35a6
+        print("WARNING! setMessageHandler(...) method is obsolette, use registerHandler('message',...) instead.")
d0c35a6
         return self.registerHandler('message', func, type, chained=chainOutput)
d0c35a6
 
d0c35a6
     def setPresenceHandler(self, func, type='', chainOutput=False):
d0c35a6
         """Back compartibility method"""
d0c35a6
-        print "WARNING! setPresenceHandler(...) method is obsolette, use registerHandler('presence',...) instead."
d0c35a6
+        print("WARNING! setPresenceHandler(...) method is obsolette, use registerHandler('presence',...) instead.")
d0c35a6
         return self.registerHandler('presence', func, type, chained=chainOutput)
d0c35a6
 
d0c35a6
     def setIqHandler(self, func, type='', ns=''):
d0c35a6
         """Back compartibility method"""
d0c35a6
-        print "WARNING! setIqHandler(...) method is obsolette, use registerHandler('iq',...) instead."
d0c35a6
+        print("WARNING! setIqHandler(...) method is obsolette, use registerHandler('iq',...) instead.")
d0c35a6
         return self.registerHandler('iq', func, type, ns)
d0c35a6
 
d0c35a6
     def header(self):
da67f52
@@ -248,7 +254,7 @@ class Connection(xmlstream.Client):
d0c35a6
 
d0c35a6
     def _expectedIqHandler(self, conn, iq_obj):
d0c35a6
         if iq_obj.getAttr('id') and \
d0c35a6
-           self._expected.has_key(iq_obj.getAttr('id')):
d0c35a6
+           iq_obj.getAttr('id') in self._expected:
d0c35a6
             self._expected[iq_obj.getAttr('id')] = iq_obj
d0c35a6
             raise NodeProcessed('No need for further Iq processing.')
d0c35a6
 
da67f52
@@ -257,7 +263,7 @@ class Connection(xmlstream.Client):
d0c35a6
            Builds the relevant jabber.py object and dispatches it
d0c35a6
            to a relevant function or callback."""
d0c35a6
         name=stanza.getName()
d0c35a6
-        if not self.handlers.has_key(name):
d0c35a6
+        if name not in self.handlers:
d0c35a6
             self.DEBUG("whats a tag -> " + name,DBG_NODE_UNKNOWN)
d0c35a6
             name='unknown'
d0c35a6
         else:
da67f52
@@ -274,9 +280,9 @@ class Connection(xmlstream.Client):
d0c35a6
         self.DEBUG("dispatch called for: name->%s ns->%s"%(name,ns),DBG_DISPATCH)
d0c35a6
 
d0c35a6
         typns=typ+ns
d0c35a6
-        if not self.handlers[name].has_key(ns): ns=''
d0c35a6
-        if not self.handlers[name].has_key(typ): typ=''
d0c35a6
-        if not self.handlers[name].has_key(typns): typns=''
d0c35a6
+        if ns not in self.handlers[name]: ns=''
d0c35a6
+        if typ not in self.handlers[name]: typ=''
d0c35a6
+        if typns not in self.handlers[name]: typns=''
d0c35a6
 
d0c35a6
         chain=[]
d0c35a6
         for key in ['default',typ,ns,typns]: # we will use all handlers: from very common to very particular
da67f52
@@ -337,7 +343,7 @@ class Connection(xmlstream.Client):
d0c35a6
            have lower priority that common handlers.
d0c35a6
         """
d0c35a6
         if not type and not ns: type='default'
d0c35a6
-        if not self.handlers[name].has_key(type+ns): self.handlers[name][type+ns]=[]
d0c35a6
+        if type+ns not in self.handlers[name]: self.handlers[name][type+ns]=[]
d0c35a6
         if makefirst: self.handlers[name][type+ns].insert({'chain':chained,'func':handler,'system':system})
d0c35a6
         else: self.handlers[name][type+ns].append({'chain':chained,'func':handler,'system':system})
d0c35a6
 
da67f52
@@ -525,16 +531,23 @@ class Client(Connection):
da67f52
             token = auth_ret_query.getTag('token').getData()
d0c35a6
             seq = auth_ret_query.getTag('sequence').getData()
d0c35a6
             self.DEBUG("zero-k authentication supported",(DBG_INIT,DBG_NODE_IQ))
da67f52
-            hash = hashlib.new('sha1', hashlib.new('sha1', passwd).hexdigest()+token).hexdigest()
d0c35a6
-            for foo in xrange(int(seq)): hash = hashlib.new('sha1', hash).hexdigest()
da67f52
+            # Unicode-objects must be encoded before hashing
da67f52
+            if isinstance(passwd, UnicodeType):
da67f52
+                pass_enc = passwd.encode('utf-8')
da67f52
+            else:
da67f52
+                pass_enc = passwd
da67f52
+            hash = hashlib.new('sha1', hashlib.new('sha1', pass_enc).hexdigest()+token).hexdigest()
d0c35a6
+            for foo in range(int(seq)): hash = hashlib.new('sha1', hash).hexdigest()
d0c35a6
             q.insertTag('hash').insertData(hash)
d0c35a6
 
d0c35a6
         elif auth_ret_query.getTag('digest'):
da67f52
 
da67f52
             self.DEBUG("digest authentication supported",(DBG_INIT,DBG_NODE_IQ))
da67f52
             digest = q.insertTag('digest')
da67f52
-            digest.insertData(hashlib.new('sha1',
da67f52
-                self.getIncomingID() + passwd).hexdigest() )
da67f52
+            idp = self.getIncomingID() + passwd
da67f52
+            if isinstance(idp, UnicodeType):
da67f52
+                idp = idp.encode('uft-8')
da67f52
+            digest.insertData(hashlib.new('sha1', idp).hexdigest() )
da67f52
         else:
da67f52
             self.DEBUG("plain text authentication supported",(DBG_INIT,DBG_NODE_IQ))
da67f52
             q.insertTag('password').insertData(passwd)
da67f52
@@ -729,7 +742,7 @@ class Protocol(xmlstream.Node):
d0c35a6
 
d0c35a6
     def asNode(self):
d0c35a6
         """Back compartibility method"""
d0c35a6
-        print 'WARNING! "asNode()" method is obsolette, use Protocol object as Node object instead.'
d0c35a6
+        print('WARNING! "asNode()" method is obsolette, use Protocol object as Node object instead.')
d0c35a6
         return self
d0c35a6
 
d0c35a6
     def getError(self):
da67f52
@@ -822,7 +835,7 @@ class Protocol(xmlstream.Node):
d0c35a6
            XML document"""
d0c35a6
         x = self.setX(namespace)
d0c35a6
 
d0c35a6
-        if type(payload) == type('') or type(payload) == type(u''):
d0c35a6
+        if isinstance(payload, StringType):
d0c35a6
                 payload = xmlstream.NodeBuilder(payload).getDom()
d0c35a6
 
d0c35a6
         x.kids = [] # should be a method for this realy
da67f52
@@ -961,7 +974,7 @@ class Message(Protocol):
d0c35a6
         return m
d0c35a6
 
d0c35a6
     def build_reply(self, reply_txt=''):
d0c35a6
-        print "WARNING: build_reply method is obsolette. Use buildReply instead."
d0c35a6
+        print("WARNING: build_reply method is obsolette. Use buildReply instead.")
d0c35a6
         return self.buildReply(reply_txt)
d0c35a6
 
d0c35a6
 #############################################################################
da67f52
@@ -1059,7 +1072,7 @@ class Iq(Protocol):
d0c35a6
         if q is None:
d0c35a6
             q = self.insertTag('query')
d0c35a6
 
d0c35a6
-        if type(payload) == type('') or type(payload) == type(u''):
d0c35a6
+        if isinstance(payload, StringType):
d0c35a6
                 payload = xmlstream.NodeBuilder(payload).getDom()
d0c35a6
 
d0c35a6
         if not add: q.kids = []
da67f52
@@ -1138,7 +1151,7 @@ class Roster:
d0c35a6
     def getStatus(self, jid): ## extended
d0c35a6
         """Returns the 'status' value for a Roster item with the given jid."""
d0c35a6
         jid = ustr(jid)
d0c35a6
-        if self._data.has_key(jid):
d0c35a6
+        if jid in self._data:
d0c35a6
             return self._data[jid]['status']
d0c35a6
         return None
d0c35a6
 
da67f52
@@ -1146,7 +1159,7 @@ class Roster:
d0c35a6
     def getShow(self, jid):   ## extended
d0c35a6
         """Returns the 'show' value for a Roster item with the given jid."""
d0c35a6
         jid = ustr(jid)
d0c35a6
-        if self._data.has_key(jid):
d0c35a6
+        if jid in self._data:
d0c35a6
             return self._data[jid]['show']
d0c35a6
         return None
d0c35a6
 
da67f52
@@ -1155,7 +1168,7 @@ class Roster:
d0c35a6
         """Returns the 'online' status for a Roster item with the given jid.
d0c35a6
            """
d0c35a6
         jid = ustr(jid)
d0c35a6
-        if self._data.has_key(jid):
d0c35a6
+        if jid in self._data:
d0c35a6
             return self._data[jid]['online']
d0c35a6
         return None
d0c35a6
 
da67f52
@@ -1164,7 +1177,7 @@ class Roster:
d0c35a6
         """Returns the 'subscription' status for a Roster item with the given
d0c35a6
            jid."""
d0c35a6
         jid = ustr(jid)
d0c35a6
-        if self._data.has_key(jid):
d0c35a6
+        if jid in self._data:
d0c35a6
             return self._data[jid]['sub']
d0c35a6
         return None
d0c35a6
 
da67f52
@@ -1172,7 +1185,7 @@ class Roster:
d0c35a6
     def getName(self,jid):
d0c35a6
         """Returns the 'name' for a Roster item with the given jid."""
d0c35a6
         jid = ustr(jid)
d0c35a6
-        if self._data.has_key(jid):
d0c35a6
+        if jid in self._data:
d0c35a6
             return self._data[jid]['name']
d0c35a6
         return None
d0c35a6
 
da67f52
@@ -1181,7 +1194,7 @@ class Roster:
d0c35a6
         """ Returns the lsit of groups associated with the given roster item.
d0c35a6
         """
d0c35a6
         jid = ustr(jid)
d0c35a6
-        if self._data.has_key(jid):
d0c35a6
+        if jid in self._data:
d0c35a6
             return self._data[jid]['groups']
d0c35a6
         return None
d0c35a6
 
da67f52
@@ -1189,7 +1202,7 @@ class Roster:
d0c35a6
     def getAsk(self,jid):
d0c35a6
         """Returns the 'ask' status for a Roster item with the given jid."""
d0c35a6
         jid = ustr(jid)
d0c35a6
-        if self._data.has_key(jid):
d0c35a6
+        if jid in self._data:
d0c35a6
             return self._data[jid]['ask']
d0c35a6
         return None
d0c35a6
 
da67f52
@@ -1233,7 +1246,7 @@ class Roster:
d0c35a6
         jid = ustr(jid) # just in case
d0c35a6
         online = 'offline'
d0c35a6
         if ask: online = 'pending'
d0c35a6
-        if self._data.has_key(jid): # update it
d0c35a6
+        if jid in self._data: # update it
d0c35a6
             self._data[jid]['name'] = name
d0c35a6
             self._data[jid]['groups'] = groups
d0c35a6
             self._data[jid]['ask'] = ask
da67f52
@@ -1255,13 +1268,13 @@ class Roster:
d0c35a6
     def _setOnline(self,jid,val):
d0c35a6
         """Used internally - private"""
d0c35a6
         jid = ustr(jid)
d0c35a6
-        if self._data.has_key(jid):
d0c35a6
+        if jid in self._data:
d0c35a6
             self._data[jid]['online'] = val
d0c35a6
             if self._listener != None:
d0c35a6
                 self._listener("update", jid, {'online' : val})
d0c35a6
         else:                      ## fall back
d0c35a6
             jid_basic = JID(jid).getStripped()
d0c35a6
-            if self._data.has_key(jid_basic):
d0c35a6
+            if jid_basic in self._data:
d0c35a6
                 self._data[jid_basic]['online'] = val
d0c35a6
                 if self._listener != None:
d0c35a6
                     self._listener("update", jid_basic, {'online' : val})
da67f52
@@ -1270,13 +1283,13 @@ class Roster:
d0c35a6
     def _setShow(self,jid,val):
d0c35a6
         """Used internally - private"""
d0c35a6
         jid = ustr(jid)
d0c35a6
-        if self._data.has_key(jid):
d0c35a6
+        if jid in self._data:
d0c35a6
             self._data[jid]['show'] = val
d0c35a6
             if self._listener != None:
d0c35a6
                 self._listener("update", jid, {'show' : val})
d0c35a6
         else:                      ## fall back
d0c35a6
             jid_basic = JID(jid).getStripped()
d0c35a6
-            if self._data.has_key(jid_basic):
d0c35a6
+            if jid_basic in self._data:
d0c35a6
                 self._data[jid_basic]['show'] = val
d0c35a6
                 if self._listener != None:
d0c35a6
                     self._listener("update", jid_basic, {'show' : val})
da67f52
@@ -1285,13 +1298,13 @@ class Roster:
d0c35a6
     def _setStatus(self,jid,val):
d0c35a6
         """Used internally - private"""
d0c35a6
         jid = ustr(jid)
d0c35a6
-        if self._data.has_key(jid):
d0c35a6
+        if jid in self._data:
d0c35a6
             self._data[jid]['status'] = val
d0c35a6
             if self._listener != None:
d0c35a6
                 self._listener("update", jid, {'status' : val})
d0c35a6
         else:                      ## fall back
d0c35a6
             jid_basic = JID(jid).getStripped()
d0c35a6
-            if self._data.has_key(jid_basic):
d0c35a6
+            if jid_basic in self._data:
d0c35a6
                 self._data[jid_basic]['status'] = val
d0c35a6
                 if self._listener != None:
d0c35a6
                     self._listener("update", jid_basic, {'status' : val})
da67f52
@@ -1299,7 +1312,7 @@ class Roster:
d0c35a6
 
d0c35a6
     def _remove(self,jid):
d0c35a6
         """Used internally - private"""
d0c35a6
-        if self._data.has_key(jid):
d0c35a6
+        if jid in self._data:
d0c35a6
             del self._data[jid]
d0c35a6
             if self._listener != None:
d0c35a6
                 self._listener("remove", jid, {})
da67f52
@@ -1397,8 +1410,11 @@ class Component(Connection):
da67f52
 
da67f52
     def auth(self,secret):
da67f52
         """will disconnect on failure"""
da67f52
+        idp = self.getIncomingID() + secret
da67f52
+        if isinstance(idp, UnicodeType):
da67f52
+            idp = idp.encode('uft-8')
da67f52
         self.send( u"<handshake id='1'>%s</handshake>"
da67f52
-                   % hashlib.new('sha1', self.getIncomingID() + secret ).hexdigest()
da67f52
+                   % hashlib.new('sha1', idp).hexdigest()
da67f52
                   )
da67f52
         while not self._auth_OK:
da67f52
             self.DEBUG("waiting on handshake")
d0c35a6
diff --git jabberpy-0.5-0/jabber/xmlstream.py jabberpy-0.5-0/jabber/xmlstream.py
da67f52
index e8fdcab..7e72708 100644
d0c35a6
--- jabberpy-0.5-0/jabber/xmlstream.py
d0c35a6
+++ jabberpy-0.5-0/jabber/xmlstream.py
da67f52
@@ -34,14 +34,21 @@ import time, sys, re, socket
d0c35a6
 from select import select
d0c35a6
 from base64 import encodestring
d0c35a6
 import xml.parsers.expat
d0c35a6
-import debug
d0c35a6
+
d0c35a6
+if sys.version_info[0] == 3:
da67f52
+    from . import debug
da67f52
+    UnicodeType = str
da67f52
+    BytesType = bytes
da67f52
+else:
da67f52
+    BytesType = str
da67f52
+    UnicodeType = unicode
da67f52
+    import debug
da67f52
+
da67f52
+
d0c35a6
 _debug=debug
d0c35a6
 
d0c35a6
 VERSION = "0.5"
895cf7f
 
895cf7f
-False = 0
895cf7f
-True  = 1
895cf7f
-
895cf7f
 TCP     = 1
895cf7f
 STDIO   = 0
895cf7f
 TCP_SSL = 2
da67f52
@@ -83,7 +90,7 @@ class Node:
d0c35a6
     """A simple XML DOM like class"""
d0c35a6
     def __init__(self, tag=None, parent=None, attrs={}, payload=[], node=None):
d0c35a6
         if node:
d0c35a6
-            if type(node)<>type(self): node=NodeBuilder(node).getDom()
d0c35a6
+            if type(node) != type(self): node=NodeBuilder(node).getDom()
d0c35a6
             self.name,self.namespace,self.attrs,self.data,self.kids,self.parent = \
d0c35a6
                 node.name,node.namespace,node.attrs,node.data,node.kids,node.parent
d0c35a6
         else:
da67f52
@@ -244,7 +251,8 @@ class NodeBuilder:
da67f52
         self.__depth = 0
da67f52
         self._dispatch_depth = 1
da67f52
 
da67f52
-        if data: self._parser.Parse(data,1)
da67f52
+        if data:
da67f52
+            self._parser.Parse(data.__str__(), 1)
da67f52
 
da67f52
     def unknown_starttag(self, tag, attrs):
da67f52
         """XML Parser callback"""
da67f52
@@ -258,7 +266,7 @@ class NodeBuilder:
d0c35a6
             self._ptr.kids.append(Node(tag=tag,parent=self._ptr,attrs=attrs))
d0c35a6
             self._ptr = self._ptr.kids[-1]
d0c35a6
         else:                           ## it the stream tag:
d0c35a6
-            if attrs.has_key('id'):
d0c35a6
+            if 'id' in attrs:
d0c35a6
                 self._incomingID = attrs['id']
d0c35a6
         self.last_is_data = False
d0c35a6
 
da67f52
@@ -322,7 +330,7 @@ class Stream(NodeBuilder):
d0c35a6
                 try:
d0c35a6
                     self._logFH = open(log,'w')
d0c35a6
                 except:
d0c35a6
-                    print "ERROR: can open %s for writing" % log
d0c35a6
+                    print("ERROR: can open %s for writing" % log)
d0c35a6
                     sys.exit(0)
d0c35a6
             else: ## assume its a stream type object
d0c35a6
                 self._logFH = log
da67f52
@@ -361,9 +369,9 @@ class Stream(NodeBuilder):
da67f52
            If supplied data is not unicode string, ENCODING
da67f52
            is used for convertion. Avoid this!
da67f52
            Always send your data as a unicode string."""
da67f52
-        if type(raw_data) == type(''):
da67f52
+        if isinstance(raw_data, BytesType):
da67f52
             self.DEBUG('Non-utf-8 string "%s" passed to Stream.write! Treating it as %s encoded.'%(raw_data,ENCODING))
da67f52
-            raw_data = unicode(raw_data,ENCODING)
da67f52
+            raw_data = UnicodeType(raw_data,ENCODING)
da67f52
         data_out = raw_data.encode('utf-8')
da67f52
         try:
da67f52
             self._write(data_out)
da67f52
@@ -469,7 +477,7 @@ class Client(Stream):
d0c35a6
             af, socktype, proto, canonname, sa = r
d0c35a6
             try:
d0c35a6
                 self._sock = socket.socket(af, socktype, proto)
d0c35a6
-            except socket.error, msg:
d0c35a6
+            except socket.error:
d0c35a6
                 self._sock = None
d0c35a6
                 continue
d0c35a6
             try:
da67f52
@@ -477,7 +485,8 @@ class Client(Stream):
d0c35a6
                     self._sock.connect((self._proxy['host'], self._proxy['port']))
d0c35a6
                 else:
d0c35a6
                     self._sock.connect((self._hostIP, self._port))
d0c35a6
-            except socket.error, e:
d0c35a6
+            except socket.error:
d0c35a6
+                e = sys.exc_info()[1]
d0c35a6
                 self._sock.close()
d0c35a6
                 self._sock = None
d0c35a6
                 self.DEBUG("socket error: "+str(e),DBG_CONN_ERROR)
da67f52
@@ -501,7 +510,7 @@ class Client(Stream):
d0c35a6
 
d0c35a6
         if self._proxy:
d0c35a6
             self.DEBUG("Proxy connected",DBG_INIT)
d0c35a6
-            if self._proxy.has_key('type'): type = self._proxy['type'].upper()
d0c35a6
+            if 'type' in self._proxy: type = self._proxy['type'].upper()
d0c35a6
             else: type = 'CONNECT'
d0c35a6
             connector = []
d0c35a6
             if type == 'CONNECT':
da67f52
@@ -515,7 +524,7 @@ class Client(Stream):
d0c35a6
             connector.append('Pragma: no-cache')
d0c35a6
             connector.append('Host: %s:%s'%(self._hostIP,self._port))
d0c35a6
             connector.append('User-Agent: Jabberpy/'+VERSION)
d0c35a6
-            if self._proxy.has_key('user') and self._proxy.has_key('password'):
d0c35a6
+            if 'user' in self._proxy and 'password' in self._proxy:
d0c35a6
                 credentials = '%s:%s'%(self._proxy['user'],self._proxy['password'])
d0c35a6
                 credentials = encodestring(credentials).strip()
d0c35a6
                 connector.append('Proxy-Authorization: Basic '+credentials)
da67f52
@@ -526,7 +535,7 @@ class Client(Stream):
d0c35a6
             self._read , self._write = bak
d0c35a6
             try: proto,code,desc=reply.split('\n')[0].split(' ',2)
d0c35a6
             except: raise error('Invalid proxy reply')
d0c35a6
-            if code<>'200': raise error('Invalid proxy reply: %s %s %s'%(proto,code,desc))
d0c35a6
+            if code != '200': raise error('Invalid proxy reply: %s %s %s'%(proto,code,desc))
d0c35a6
             while reply.find('\n\n') == -1: reply += self.read().replace('\r','')
d0c35a6
 
d0c35a6
         self.DEBUG("Jabber server connected",DBG_INIT)
da67f52
@@ -574,16 +583,16 @@ class Server:
d0c35a6
 
d0c35a6
     def serve(self):
d0c35a6
 
d0c35a6
-        print 'select-server loop starting'
d0c35a6
+        print('select-server loop starting')
d0c35a6
 
d0c35a6
         while 1:
d0c35a6
-            print "LOOPING"
d0c35a6
+            print("LOOPING")
d0c35a6
             readables, writeables, exceptions = select(self.readsocks,
d0c35a6
                                                        self.writesocks, [])
d0c35a6
             for sockobj in readables:
d0c35a6
                 if sockobj in self. mainsocks:   # for ready input sockets
d0c35a6
                     newsock, address = sockobj.accept() # accept not block
d0c35a6
-                    print 'Connect:', address, id(newsock)
d0c35a6
+                    print('Connect:', address, id(newsock))
d0c35a6
                     self.readsocks.append(newsock)
d0c35a6
                     self._makeNewStream(newsock)
d0c35a6
                     # add to select list, wait
da67f52
@@ -591,7 +600,7 @@ class Server:
d0c35a6
                     # client socket: read next line
d0c35a6
                     data = sockobj.recv(1024)
d0c35a6
                     # recv should not block
d0c35a6
-                    print '\tgot', data, 'on', id(sockobj)
d0c35a6
+                    print('\tgot', data, 'on', id(sockobj))
d0c35a6
                     if not data:        # if closed by the clients
d0c35a6
                         sockobj.close() # close here and remv from
d0c35a6
                         self.readsocks.remove(sockobj)
bb2fd44
diff --git jabberpy-0.5-0/setup.py jabberpy-0.5-0/setup.py
bb2fd44
index 11f6f81..84c5369 100644
bb2fd44
--- jabberpy-0.5-0/setup.py
bb2fd44
+++ jabberpy-0.5-0/setup.py
bb2fd44
@@ -5,14 +5,14 @@ try:
bb2fd44
     from distutils.core import setup
bb2fd44
 except:
bb2fd44
     if sys.version[0] < 2:
bb2fd44
-        print "jabber.py requires at least python 2.0"
bb2fd44
-        print "Setup cannot continue."
bb2fd44
+        print("jabber.py requires at least python 2.0")
bb2fd44
+        print("Setup cannot continue.")
bb2fd44
         sys.exit(1)
bb2fd44
-    print "You appear not to have the Python distutils modules"
bb2fd44
-    print "installed. Setup cannot continue."
bb2fd44
-    print "You can manually install jabberpy by coping the jabber"
bb2fd44
-    print "directory to your /python-libdir/site-packages"    
bb2fd44
-    print "directory."
bb2fd44
+    print("You appear not to have the Python distutils modules")
bb2fd44
+    print("installed. Setup cannot continue.")
bb2fd44
+    print("You can manually install jabberpy by coping the jabber")
bb2fd44
+    print("directory to your /python-libdir/site-packages")
bb2fd44
+    print("directory.")
bb2fd44
     sys.exit(1)
bb2fd44
     
bb2fd44
 setup(name="jabber.py",