# HG changeset patch # User Pascal Volk # Date 1252173664 0 # Node ID 16542519a5a8fd9d08cc0e41b1d9c38ec0a6dd34 # Parent 28f26f7f3d8fc544e70863dcc184b246fef21ff7 Code cleanup/optimization in VMM's idn2ascii() and ace2idna(). diff -r 28f26f7f3d8f -r 16542519a5a8 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):