B -_#@sddlZddlZddlZddlmZedZdZdZddZ dd Z d d Z Gd d d ej Z Gdddej ZGdddejZGddde ejZGddde ejZddZdS)N) ucd_3_2_0u [.。.。]sxn--zxn--cCsg}x(|D] }t|rq |t|q Wd|}td|}xr|D]j}t|st|st |st |st |st |st |st|st|rJtd|qJWdd|D}xD|D]<}|rtdd|Drtd|d r|d std qW|S) NZNFKCzInvalid character %rcSsg|]}t|qS) stringprepZ in_table_d1).0xrr$/usr/lib/python3.7/encodings/idna.py )sznameprep..css|]}t|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                rcCsy|d}Wntk r"Yn*Xdt|krs,  rcCst|trd}n,y|d}d}Wntk r:d}YnX|stt|}y|d}Wntk rrtdYnX|tst|dS|ttd}| d}t |}t|d t|dkrtd|||S)NTrFzInvalid character in IDN labelrzIDNA does not round-trip) isinstancebytesrrrrrstrrdecoderlower)rZ pure_asciiZlabel1resultZlabel2rrr ToUnicodeis*       r#c@s eZdZdddZdddZdS) CodecstrictcCs|dkrtd||sdSy|d}Wntk r>YnhX|d}x6|ddD]&}dt|krtdksXntd qXWt|ddkrtd |t|fSt}t|}|r|dsd}|d=nd }x(|D] }|r|d|t|qWt ||t|fS) Nr%zunsupported error handling )rr.r rrzlabel empty or too longzlabel too longr&) rrUnicodeEncodeErrorsplitr bytearraydotsextendrr)selfinputerrorsr"labelsr trailing_dotrrrrs4        z Codec.encodecCs|dkrtd||sdSt|ts.t|}t|kr^y|dt|fStk r\YnX|d}|rt|ddkrd}|d=nd }g}x|D]}|t |qWd ||t|fS) Nr%zUnsupported error handling )rrrr'r r.r) rrrrr rUnicodeDecodeErrorr)r r#r )r-r.r/r0r1r"rrrrr s(    z Codec.decodeN)r%)r%)__name__ __module__ __qualname__rr rrrrr$s %r$c@seZdZddZdS)IncrementalEncoderc Cs|dkrtd||sdSt|}d}|rT|dsBd}|d=n|sT|d=|rTd}t}d}x<|D]4}|r~|d|d7}|t||t|7}qdW||7}|t|7}t||fS) Nr%zunsupported error handling )r&rr&r r'r)rr+r)r*r,rrr) r-r.r/finalr0r1r"sizerrrr_buffer_encodes2     z!IncrementalEncoder._buffer_encodeN)r4r5r6r;rrrrr7sr7c@seZdZddZdS)IncrementalDecoderc Cs|dkrtd||sdSt|tr2t|}nt|d}|d}d}|rt|dsbd}|d=n|st|d=|rtd}g}d}x2|D]*}|t||r|d 7}|t|7}qWd||}|t|7}||fS) Nr%zUnsupported error handling )rrrr2rr rr8) rrrr+r)r r#rr ) r-r.r/r9r0r1r"r:rrrr_buffer_decodes6       z!IncrementalDecoder._buffer_decodeN)r4r5r6r=rrrrr<sr<c@s eZdZdS) StreamWriterN)r4r5r6rrrrr>$sr>c@s eZdZdS) StreamReaderN)r4r5r6rrrrr?'sr?c Cs tjdtjtjttttdS)NZidna)namerr incrementalencoderincrementaldecoder streamwriter streamreader) codecs CodecInfor$rr r7r<r>r?rrrr getregentry,srG)rrerErrcompiler+rrrrr#r$BufferedIncrementalEncoderr7BufferedIncrementalDecoderr<r>r?rGrrrrs  0+)H#'