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 |