source: ralphm-patches/py3-xmppim.patch

Last change on this file was 78:361e2111a663, checked in by Ralph Meijer <ralphm@…>, 4 years ago

Start port to Python 3.

File size: 2.8 KB
  • wokkel/test/test_xmppim.py

    # HG changeset patch
    # Parent  9846c8af3f2c87ab42909cd04487eede17b26c41
    
    diff --git a/wokkel/test/test_xmppim.py b/wokkel/test/test_xmppim.py
    a b  
    77
    88from twisted.internet import defer
    99from twisted.trial import unittest
     10from twisted.python.compat import unicode
    1011from twisted.words.protocols.jabber import error
    1112from twisted.words.protocols.jabber.jid import JID
    1213from twisted.words.protocols.jabber.xmlstream import toResponse
     
    896897        request = xmppim.RosterRequest()
    897898        element = request.toElement()
    898899        children = element.elements()
    899         child = children.next()
     900        child = next(children)
    900901        self.assertEqual(NS_ROSTER, child.uri)
    901902        self.assertEqual('query', child.name)
    902903
     
    909910        request.item = xmppim.RosterItem(JID('user@example.org'))
    910911        element = request.toElement()
    911912        children = element.query.elements()
    912         child = children.next()
     913        child = next(children)
    913914        self.assertEqual(NS_ROSTER, child.uri)
    914915        self.assertEqual('item', child.name)
    915916
  • wokkel/xmppim.py

    diff --git a/wokkel/xmppim.py b/wokkel/xmppim.py
    a b  
    1313import warnings
    1414
    1515from twisted.internet import defer
     16from twisted.python.compat import iteritems, itervalues, unicode
    1617from twisted.words.protocols.jabber import error
    1718from twisted.words.protocols.jabber.jid import JID
    1819from twisted.words.xish import domish
     
    4546            self.addElement('show', content=show)
    4647
    4748        if statuses is not None:
    48             for lang, status in statuses.iteritems():
     49            for lang, status in iteritems(statuses):
    4950                s = self.addElement('status', content=status)
    5051                if lang:
    5152                    s[(NS_XML, "lang")] = lang
     
    5859        Presence.__init__(self, to, type='unavailable')
    5960
    6061        if statuses is not None:
    61             for lang, status in statuses.iteritems():
     62            for lang, status in iteritems(statuses):
    6263                s = self.addElement('status', content=status)
    6364                if lang:
    6465                    s[(NS_XML, "lang")] = lang
     
    306307        if None in self.statuses:
    307308            return self.statuses[None]
    308309        elif self.statuses:
    309             for status in self.status.itervalues():
     310            for status in itervalues(self.status):
    310311                return status
    311312        else:
    312313            return None
     
    352353            if self.priority != 0:
    353354                presence.addElement('priority', content=unicode(self.priority))
    354355
    355         for lang, text in self.statuses.iteritems():
     356        for lang, text in iteritems(self.statuses):
    356357            status = presence.addElement('status', content=text)
    357358            if lang:
    358359                status[(NS_XML, 'lang')] = lang
Note: See TracBrowser for help on using the repository browser.