VirtualMailManager/VirtualMailManager.py
changeset 143 16542519a5a8
parent 140 ffac064bd728
child 155 eb866ebb9f2e
equal deleted inserted replaced
142:28f26f7f3d8f 143:16542519a5a8
   120                 raise VMMException(str(e), ERR.DATABASE_ERROR)
   120                 raise VMMException(str(e), ERR.DATABASE_ERROR)
   121 
   121 
   122     def idn2ascii(domainname):
   122     def idn2ascii(domainname):
   123         """Converts an idn domainname in punycode.
   123         """Converts an idn domainname in punycode.
   124 
   124 
   125         Keyword arguments:
   125         Arguments:
   126         domainname -- the domainname to convert (str)
   126         domainname -- the domainname to convert (unicode)
   127         """
   127         """
   128         tmp = []
   128         return '.'.join([ToASCII(lbl) for lbl in domainname.split('.') if lbl])
   129         for label in domainname.split('.'):
       
   130             if len(label) == 0:
       
   131                 continue
       
   132             tmp.append(ToASCII(label))
       
   133         return '.'.join(tmp)
       
   134     idn2ascii = staticmethod(idn2ascii)
   129     idn2ascii = staticmethod(idn2ascii)
   135 
   130 
   136     def ace2idna(domainname):
   131     def ace2idna(domainname):
   137         """Convertis a domainname from ACE according to IDNA
   132         """Convertis a domainname from ACE according to IDNA
   138 
   133 
   139         Keyword arguments:
   134         Arguments:
   140         domainname -- the domainname to convert (str)
   135         domainname -- the domainname to convert (str)
   141         """
   136         """
   142         tmp = []
   137         return u'.'.join([ToUnicode(lbl) for lbl in domainname.split('.')\
   143         for label in domainname.split('.'):
   138                 if lbl])
   144             if len(label) == 0:
       
   145                 continue
       
   146             tmp.append(ToUnicode(label))
       
   147         return '.'.join(tmp)
       
   148     ace2idna = staticmethod(ace2idna)
   139     ace2idna = staticmethod(ace2idna)
   149 
   140 
   150     def chkDomainname(domainname):
   141     def chkDomainname(domainname):
   151         """Validates the domain name of an e-mail address.
   142         """Validates the domain name of an e-mail address.
   152 
   143