Code cleanup/optimization in VMM's idn2ascii() and ace2idna().
authorPascal Volk <neverseen@users.sourceforge.net>
Sat, 05 Sep 2009 18:01:04 +0000
changeset 143 16542519a5a8
parent 142 28f26f7f3d8f
child 144 4c6aa6c29dd7
Code cleanup/optimization in VMM's idn2ascii() and ace2idna().
VirtualMailManager/VirtualMailManager.py
--- a/VirtualMailManager/VirtualMailManager.py	Fri Sep 04 20:27:39 2009 +0000
+++ b/VirtualMailManager/VirtualMailManager.py	Sat Sep 05 18:01:04 2009 +0000
@@ -122,29 +122,20 @@
     def idn2ascii(domainname):
         """Converts an idn domainname in punycode.
 
-        Keyword arguments:
-        domainname -- the domainname to convert (str)
+        Arguments:
+        domainname -- the domainname to convert (unicode)
         """
-        tmp = []
-        for label in domainname.split('.'):
-            if len(label) == 0:
-                continue
-            tmp.append(ToASCII(label))
-        return '.'.join(tmp)
+        return '.'.join([ToASCII(lbl) for lbl in domainname.split('.') if lbl])
     idn2ascii = staticmethod(idn2ascii)
 
     def ace2idna(domainname):
         """Convertis a domainname from ACE according to IDNA
 
-        Keyword arguments:
+        Arguments:
         domainname -- the domainname to convert (str)
         """
-        tmp = []
-        for label in domainname.split('.'):
-            if len(label) == 0:
-                continue
-            tmp.append(ToUnicode(label))
-        return '.'.join(tmp)
+        return u'.'.join([ToUnicode(lbl) for lbl in domainname.split('.')\
+                if lbl])
     ace2idna = staticmethod(ace2idna)
 
     def chkDomainname(domainname):