Changeset 184:a9ab7d3945e2 for wokkel


Ignore:
Timestamp:
May 6, 2013, 9:15:41 PM (7 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Deprecate prepareIDNName.

C{unicode.encode('idna')} does exactly the same as the recently
introduced L{generic.prepareIDNName}.

Location:
wokkel
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wokkel/client.py

    r178 r184  
    8888    def __init__(self, jid, password, host=None, port=5222):
    8989        self.jid = jid
    90         self.domain = generic.prepareIDNName(jid.host)
     90        self.domain = jid.host.encode('idna')
    9191        self.host = host
    9292        self.port = port
     
    183183
    184184def clientCreator(factory):
    185     domain = generic.prepareIDNName(factory.authenticator.jid.host)
     185    domain = factory.authenticator.jid.host.encode('idna')
    186186    c = XMPPClientConnector(reactor, domain, factory)
    187187    c.connect()
  • wokkel/generic.py

    r178 r184  
    88"""
    99
    10 from encodings import idna
    11 
    1210from zope.interface import implements
    1311
    1412from twisted.internet import defer, protocol
    1513from twisted.python import reflect
     14from twisted.python.deprecate import deprecated
     15from twisted.python.versions import Version
    1616from twisted.words.protocols.jabber import error, jid, xmlstream
    1717from twisted.words.protocols.jabber.xmlstream import toResponse
     
    333333
    334334
     335@deprecated(Version("Wokkel", 0, 8, 0), "unicode.encode('idna')")
    335336def prepareIDNName(name):
    336337    """
     
    342343    standard full stop.
    343344    """
    344     result = []
    345     labels = idna.dots.split(name)
    346 
    347     if labels and len(labels[-1]) == 0:
    348         trailing_dot = b'.'
    349         del labels[-1]
    350     else:
    351         trailing_dot = b''
    352 
    353     for label in labels:
    354         result.append(idna.ToASCII(label))
    355 
    356     return b'.'.join(result) + trailing_dot
     345    return name.encode('idna')
  • wokkel/server.py

    r178 r184  
    3030from twisted.words.xish import domish
    3131
    32 from wokkel.generic import DeferredXmlStreamFactory, XmlPipe, prepareIDNName
     32from wokkel.generic import DeferredXmlStreamFactory, XmlPipe
    3333
    3434NS_DIALBACK = 'jabber:server:dialback'
     
    469469
    470470def initiateS2S(factory):
    471     domain = prepareIDNName(factory.authenticator.otherHost)
     471    domain = factory.authenticator.otherHost.encode('idna')
    472472    c = XMPPServerConnector(reactor, domain, factory)
    473473    c.connect()
  • wokkel/test/test_generic.py

    r178 r184  
    66"""
    77
     8import re
     9
     10from twisted.python import deprecate
     11from twisted.python.versions import Version
    812from twisted.trial import unittest
     13from twisted.trial.util import suppress as SUPPRESS
    914from twisted.words.xish import domish
    1015from twisted.words.protocols.jabber.jid import JID
     
    277282    """
    278283
     284    suppress = [SUPPRESS(category=DeprecationWarning,
     285                         message=re.escape(
     286                             deprecate.getDeprecationWarningString(
     287                                 generic.prepareIDNName,
     288                                 Version("Wokkel", 0, 8, 0),
     289                                 replacement="unicode.encode('idna')")))]
     290
     291
     292    def test_deprecated(self):
     293        """
     294        prepareIDNName is deprecated.
     295        """
     296        self.callDeprecated((Version("Wokkel", 0, 8, 0),
     297                             "unicode.encode('idna')"),
     298                            generic.prepareIDNName, (b"example.com"))
     299    test_deprecated.suppress = []
     300
     301
    279302    def test_bytestring(self):
    280303        """
Note: See TracChangeset for help on using the changeset viewer.