U ,a#@sddlZddlZddlZddlmZedZdZdZddZ dd Z d d Z Gd d d ej Z Gdddej ZGdddejZGddde ejZGddde ejZddZdS)N) ucd_3_2_0u [.。.。]sxn--zxn--cCsg}|D] }t|rq|t|qd|}td|}|D]j}t|st|st |st |st |st |st |st|st|rDtd|qDdd|D}|D]:}|rtdd|Drtd|d r|d std q|S) NZNFKCzInvalid character %rcSsg|]}t|qS) stringprepZ in_table_d1.0xrr3/opt/alt/python38/lib64/python3.8/encodings/idna.py )sznameprep..css|]}t|VqdS)N)rZ in_table_d2rrrr 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)labelZnewlabelcZRandALrrr nameprepsD      rcCsz|d}Wntk r"Yn*Xdt|krs,  rcCst|trd}n,z|d}d}Wntk r:d}YnX|stt|}z|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||sdSz|d}Wntk r>YndX|d}|ddD]&}dt|krrdksVntd qVt|ddkrtd |t|fSt}t|}|r|dsd}|d=nd }|D] }|r|d|t|qt ||t|fS) Nr'unsupported error handling rr.r rrrzlabel too longr*) rrUnicodeEncodeErrorsplitr bytearraydotsextendrr )selfinputerrorsr$labelsr trailing_dotrrr rs4       z Codec.encodecCs|dkrtd||sdSt|ts.t|}t|kr`z|dt|fWStk r^YnX|d}|rt|ddkrd}|d=nd }g}|D]}|t |qd ||t|fS) Nr'Unsupported error handling rrrr+r r.r) rrr rr"rUnicodeDecodeErrorr-r r%r)r1r2r3r4r5r$rrrr r"s(   z Codec.decodeN)r')r')__name__ __module__ __qualname__rr"rrrr r&s %r&c@seZdZddZdS)IncrementalEncoderc Cs|dkrtd||sdSt|}d}|rT|dsBd}|d=n|sT|d=|rTd}t}d}|D]4}|r||d|d7}|t||t|7}qb||7}|t|7}t||fS) Nr'r(r)r*r r+r)rr/r-r.r0rrr r1r2r3finalr4r5r$sizerrrr _buffer_encodes2    z!IncrementalEncoder._buffer_encodeN)r:r;r<rBrrrr r=sr=c@seZdZddZdS)IncrementalDecoderc Cs|dkrtd||sdSt|tr2t|}nt|d}|d}d}|rt|dsbd}|d=n|st|d=|rtd}g}d}|D]*}|t||r|d 7}|t|7}qd||}|t|7}||fS) Nr'r6r7rr8rr rr>) rrr!r/r-r r%rrr?rrr _buffer_decodes6      z!IncrementalDecoder._buffer_decodeN)r:r;r<rDrrrr rCsrCc@s eZdZdS) StreamWriterNr:r;r<rrrr rE$srEc@s eZdZdS) StreamReaderNrFrrrr rG'srGc Cs tjdtjtjttttdS)NZidna)namerr"incrementalencoderincrementaldecoder streamwriter streamreader) codecs CodecInfor&rr"r=rCrErGrrrr getregentry,srO)rrerMrrcompiler/rrrrr%r&BufferedIncrementalEncoderr=BufferedIncrementalDecoderrCrErGrOrrrr s  0+)H#'