+e#@sddlZddlZddlZddlmZejdZdZdZddZ dd Z d d Z Gd d d ej Z Gdddej ZGdddejZGddde ejZGddde ejZddZdS)N) ucd_3_2_0u [.。.。]sxn--zxn--cCsg}x9|D]1}tj|r(q n|jtj|q Wdj|}tjd|}x|D]}tj|stj|stj |stj |stj |stj |stj |stj|stj|rjtd|qjqjWdd|D}xd|D]\}|r(tdd|Dr\tdn|d  sr|d  rtd qq(q(W|S) NZNFKCzInvalid character %rcSsg|]}tj|qS) stringprepZ in_table_d1).0xrr3/opt/alt/python34/lib64/python3.4/encodings/idna.py )s znameprep..css|]}tj|VqdS)N)rZ in_table_d2)rrrrr 2sznameprep..zViolation of BIDI requirement 2rzViolation of BIDI requirement 3)rZ in_table_b1appendZ map_table_b2join unicodedataZ normalizeZ in_table_c12Z in_table_c22Z in_table_c3Z in_table_c4Z in_table_c5Z in_table_c6Z in_table_c7Z in_table_c8Z in_table_c9 UnicodeErrorany)labelZnewlabelcZRandALrrrnamepreps4   rcCs-y|jd}Wntk r'Yn3Xdt|koEdknrN|Stdt|}y|jd}Wntk rYn3Xdt|kodknr|Std|jtrtdn|jd}t|}dt|kodknr|StddS)Nasciir@zlabel empty or too longzLabel starts with ACE prefixpunycode)encoderlenr startswith sace_prefix ace_prefix)rrrrToASCII>s, "   "  "rcCst|trd}n4y|jd}d}Wntk rKd}YnX|st|}y|jd}Wqtk rtdYqXn|jtst|dS|ttd}|j d}t |}t|dj t|dkrtd||n|S)NTrFzInvalid character in IDN labelrzIDNA does not round-trip) isinstancebytesrrrrrstrrdecoderlower)rZ pure_asciiZlabel1resultZlabel2rrr ToUnicodeis*        $r$c@s.eZdZdddZdddZdS)Codecstrictc Cst|dkrtd|n|s)d Sy|jd}Wntk rPYnX|jd}xI|dd D]7}dt|kodknsqtd qqqqWt|d dkrtd n|t|fSt}tj|}|r|d rd}|d=nd}x7|D]/}|rC|jdn|jt|q'Wt ||t|fS)Nr&zunsupported error handling rr.r rzlabel empty or too longzlabel too long)r'rr r r r ) rrUnicodeEncodeErrorsplitr bytearraydotsextendrr)selfinputerrorsr#labelsr trailing_dotrrrrs4  "   z Codec.encodec Cs|dkrtd|n|s)d St|tsGt|}nt|kry|jdt|fSWqtk rYqXn|jd}|rt|d dkrd}|d =nd}g}x!|D]}|jt |qWdj ||t|fS) Nr&zUnsupported error handling rrrr(r .)rrr r ) rrrrr!rUnicodeDecodeErrorr*r r$r)r.r/r0r1r2r#rrrrr!s(     z Codec.decodeN)__name__ __module__ __qualname__rr!rrrrr%s %r%c@seZdZddZdS)IncrementalEncoderc Cs |dkrtd|n|s)dStj|}d}|r|ds^d}|d =q|s|d =|r}d}q}qnt}d}xQ|D]I}|r|jd|d7}n|jt||t|7}qW||7}|t|7}t||fS) Nr&zunsupported error handling r'rr r()r'rr r r )rr,r*r+r-rrr) r.r/r0finalr1r2r#sizerrrr_buffer_encodes2        z!IncrementalEncoder._buffer_encodeN)r5r6r7r;rrrrr8s r8c@seZdZddZdS)IncrementalDecoderc Cs0|dkrtd|n|s)dSt|trJtj|}nt|d}|jd}d}|r|d sd}|d =q|s|d =|rd}qqng}d}xD|D]<}|jt||r|d7}n|t|7}qWdj||}|t|7}||fS) Nr&zUnsupported error handling rrrr3r )rrr r r ) rrr r,r*r r$rr) r.r/r0r9r1r2r#r:rrrr_buffer_decodes6     z!IncrementalDecoder._buffer_decodeN)r5r6r7r=rrrrr<s r<c@seZdZdS) StreamWriterN)r5r6r7rrrrr>$s r>c@seZdZdS) StreamReaderN)r5r6r7rrrrr?'s r?cCs@tjdddtjdtjdtdtdtdtS) NnameZidnarr!incrementalencoderincrementaldecoder streamwriter streamreader) codecs CodecInfor%rr!r8r<r>r?rrrr getregentry,s   rG)rrerErrcompiler,rrrrr$r%BufferedIncrementalEncoderr8BufferedIncrementalDecoderr<r>r?rGrrrrs$ 0 + )H#'