\d#,ddlZddlZddlZddlmZejdZdZdZdZ dZ dZ Gd d ej Z Gd d ej ZGd dejZGdde ejZGdde ejZdZdS)N) ucd_3_2_0u [.。.。]sxn--zxn--c:g}|D]>}tj|r|tj|?d|}t jd|}|D]}tj|stj|stj |sxtj |sdtj |sPtj |sznameprep..)s# 7 7 7Aj$Q'' 7 7 7c3>K|]}tj|VdS)N)r in_table_d2r s r znameprep..1s-88Qz%a((888888rzViolation of BIDI requirement 2rzViolation of BIDI requirement 3)r in_table_b1append map_table_b2join unicodedata normalize in_table_c12 in_table_c22 in_table_c3 in_table_c4 in_table_c5 in_table_c6 in_table_c7 in_table_c8 in_table_c9 UnicodeErrorany)labelnewlabelcRandALs rnameprepr*sH 44  !! $ $   /223333 GGH  E  !&% 0 0E ; ;  "1 % % ;  "1 % % ;  !! $ $ ;  !! $ $ ;  !! $ $ ;  !! $ $ ;  !! $ $ ;  !! $ $ ;  !! $ $ ;59:: : ;8 7 7 7 7F 6{{B 88%888 8 8 B@AA A ay Br  B@AA A Lrc\ |d}dt|cxkrdkrnn|Std#t$rYnwxYwt|} |d}dt|cxkrdkrnn|Std#t$rYnwxYw|t rtd|d}t |z}dt|cxkrdkrnn|Std)Nasciir@label empty or too longzLabel starts with ACE prefixpunycode)encodelenr$r* startswith sace_prefix ace_prefix)r&s rToASCIIr5<s 6 W%% s5zz    B     L4555       UOOE6 W%% s5zz    B     L4555        $$;9::: LL $ $E  E 3u:: 0 1 11s#A AA%B(( B54B5ctt|trd}n+ |d}d}n#t$rd}YnwxYw|sCt |} |d}n#t$rtdwxYw|t st|dS|tt d}| d}t|}t|d t|dkrtd|||S)NTr,FzInvalid character in IDN labelr/zIDNA does not round-trip) isinstancebytesr0r$r*r2r4strr1decoder5lower)r& pure_asciilabel1resultlabel2s r ToUnicoder@gs^%  LL))EJJ   JJJ  A ALL))EE A A A?@@ @ A   J ' '#5'"""3z??## $F]]: & &FV__F 5'  ""c&'&:&:::5ufEEE Ms2 AAA,,BceZdZddZddZdS)Codecstrictc|dkrtd|z|sdS |d}|d}|ddD]-}dt|cxkrdksntd .t|ddkrtd |t|fS#t$rYnwxYwt }t |}|r|dsd}|d=nd }|D];}|r|d|t|labelsr& trailing_dots rr0z Codec.encodes X  r&s rr:z Codec.decodes/ X  sizer&s r_buffer_encodez!IncrementalEncoder._buffer_encodes X  d||z}|t|z }||fS) NrCrSrTr,rUrrrr]) r$r7r9rKrHrr@r1rr^s r_buffer_decodez!IncrementalDecoder._buffer_decodesB X  rzs000000rz.//  ,,,\)2)2)2V%%%RF9F9F9F9F9FLF9F9F9P!%!%!%!%!%:!%!%!%F%%%%%:%%%N     5,        5,       r