Lines Matching refs:label
14 def nameprep(label):
17 for c in label:
22 label = "".join(newlabel)
25 label = unicodedata.normalize("NFKC", label)
28 for c in label:
41 RandAL = [stringprep.in_table_d1(x) for x in label]
49 if any(stringprep.in_table_d2(x) for x in label):
58 return label
60 def ToASCII(label):
63 label = label.encode("ascii")
69 if 0 < len(label) < 64:
70 return label
71 raise UnicodeError("label empty or too long")
74 label = nameprep(label)
79 label = label.encode("ascii")
84 if 0 < len(label) < 64:
85 return label
86 raise UnicodeError("label empty or too long")
89 if label.startswith(sace_prefix):
93 label = label.encode("punycode")
96 label = ace_prefix + label
99 if 0 < len(label) < 64:
100 return label
101 raise UnicodeError("label empty or too long")
103 def ToUnicode(label):
105 if isinstance(label, bytes):
109 label = label.encode("ascii")
115 label = nameprep(label)
118 label = label.encode("ascii")
120 raise UnicodeError("Invalid character in IDN label")
122 if not label.startswith(ace_prefix):
123 return str(label, "ascii")
126 label1 = label[len(ace_prefix):]
136 if str(label, "ascii").lower() != str(label2, "ascii"):
137 raise UnicodeError("IDNA does not round-trip", label, label2)
161 for label in labels[:-1]:
162 if not (0 < len(label) < 64):
163 raise UnicodeError("label empty or too long")
165 raise UnicodeError("label too long")
175 for label in labels:
179 result.extend(ToASCII(label))
211 for label in labels:
212 result.append(ToUnicode(label))
232 # Keep potentially unfinished label until the next call
239 for label in labels:
244 result.extend(ToASCII(label))
245 size += len(label)
273 # Keep potentially unfinished label until the next call
280 for label in labels:
281 result.append(ToUnicode(label))
284 size += len(label)