U AT^#c@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_d1Z.0Zxrr&/usr/lib64/python3.8/encodings/idna.pyZ )sznameprep..css|]}t|VqdS)N)rZ in_table_d2rrrrZ 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 UnicodeErrorZany)labelZnewlabelZcZRandALrrrnameprepsD      r cCsz|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) isinstancebytesrr r rrstrrdecoderZlower)r Z pure_asciiZlabel1resultZlabel2rrr ToUnicodeis*       rc@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) Nrunsupported error handling rr.rrrrzlabel too longr") r rZUnicodeEncodeErrorsplitr bytearraydotsextendrr)selfinputerrorsrlabelsr trailing_dotrrrrs4       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) NrUnsupported error handling rrrr#rr.r) r rrrrrZUnicodeDecodeErrorr$rrr )r(r)r*r+r,rr rrrrs(   z Codec.decodeNrr0)__name__ __module__ __qualname__rrrrrrrs %rc@eZdZddZdS)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) Nrr r!r"rr#r)r r&r$r%r'rrr r(r)r*Zfinalr+r,rZsizer rrr_buffer_encodes2    z!IncrementalEncoder._buffer_encodeN)r1r2r3r8rrrrr5r5c@r4)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) Nrr-r.rr/rrrr6) r rrr&r$rrrr r7rrr_buffer_decodes6      z!IncrementalDecoder._buffer_decodeN)r1r2r3r;rrrrr:r9r:c@ eZdZdS) StreamWriterNr1r2r3rrrrr=$r9r=c@r<) StreamReaderNr>rrrrr?'r9r?c Cs tjdtjtjttttdS)NZidna)ZnamerrZincrementalencoderZincrementaldecoderZ streamwriterZ streamreader) codecsZ CodecInforrrr5r:r=r?rrrr getregentry,srA)rZrer@r rZcompiler&rrr rrrZBufferedIncrementalEncoderr5ZBufferedIncrementalDecoderr:r=r?rArrrrZs  0+)H#'