3 \@sddlZddZddZddZdd Zd d Zd Zd dZddZddZ ddZ ddZ ddZ ddZ GdddejZGdddejZGdd d ejZGd!d"d"eejZGd#d$d$eejZd%d&ZdS)'NcCsTt}t}x2|D]*}t|dkr2|jt|q|j|qWt|}t||fS)N) bytearraysetordappendaddsortedbytes)strbaseextendedcr*/usr/lib64/python3.6/encodings/punycode.py segregate s  rcCs*d}x |D]}t||kr |d7}q W|S)Nr)r)r maxresr rrr selective_lens    rcCsRt|}xD|d7}||krdS||}||kr:|d|fS||kr |d7}q WdS)Nrr)rr)len)r charindexposlr rrrselective_finds rc Csd}g}d}x~|D]v}d}}t|}t||} | d||} xBt||||\}}|dkr^P| ||7} |j| d|}d} qBW|}qW|S)Nrrrrrr)rrrr) r r ZoldcharresultZoldindexr rrrZcurlendeltarrrinsertion_unsort0s$   rcCs,d|d|}|dkrdS|dkr(dS|S)N$rr)jbiasrrrrTFs r#s$abcdefghijklmnopqrstuvwxyz0123456789cCsrt}d}xbt||}||kr4|jt|t|S|jt|||d|||d|}|d7}q WdS)Nrrr)rr#rdigitsr )Nr"rr!trrrgenerate_generalized_integerNs r'cCs\|r|d}n|d}|||7}d}x|dkrB|d}|d7}q(W|d||d}|S)Niri#r&r)rfirstnumcharsZ divisionsr"rrradapt[s    r-cCsTt}d}x@t|D]4\}}t||}|j|t||dk||d}qWt|S)NHrr)r enumerater'extendr-r )Zbaselendeltasrr"Zpointsrsrrrgenerate_integersjs  r3cCs8t|\}}t||}tt||}|r4|d|S|S)N-)rrr3r)textr r r1rrrpunycode_encodeus    r6c Csd}d}d}xyt||}Wn,tk rJ|dkr>td|ddfSX|d7}d|kofdknrv|d}nDd|kodknr|d }n"|dkrtd ||n|dfSt||} |||7}|| kr||fS|d | }|d7}qWdS) Nrrstrictzincomplete punicode stringAZ09z Invalid extended code point '%s'r)r IndexError UnicodeErrorr#) r extposr"errorsrwr!rZdigitr&rrrdecode_generalized_numbers2     rBc Csd}d }d}d}x|t|krt||||\}}|dkr<|S||d7}||t|d7}|dkr|dkrxtd|td}|t|d}|d|t|||d}t||dkt|}|}qW|S) Nrrr.rir7zInvalid character U+%x?r)rrBr>rchrr-) r r r@rrr"r?Znewposrrrrinsertion_sorts(    rEcCst|tr|jd}t|tr&t|}|jd}|dkrLd}t|dj}n.t|d|d|}t||dddj}t|||S)Nasciir4rr) isinstancer encode memoryviewr rfindupperrE)r5r@rr r rrrpunycode_decodes    rMc@s eZdZdddZdddZdS) Codecr7cCst|}|t|fS)N)r6r)selfinputr@rrrrrIsz Codec.encodecCs*|dkrtd|t||}|t|fS)Nr7replaceignorezUnsupported error handling )r7rQrR)r>rMr)rOrPr@rrrrdecodes  z Codec.decodeN)r7)r7)__name__ __module__ __qualname__rIrSrrrrrNs rNc@seZdZdddZdS)IncrementalEncoderFcCst|S)N)r6)rOrPfinalrrrrIszIncrementalEncoder.encodeN)F)rTrUrVrIrrrrrWsrWc@seZdZdddZdS)IncrementalDecoderFcCs$|jdkrtd|jt||jS)Nr7rQrRzUnsupported error handling )r7rQrR)r@r>rM)rOrPrXrrrrSs zIncrementalDecoder.decodeN)F)rTrUrVrSrrrrrYsrYc@s eZdZdS) StreamWriterN)rTrUrVrrrrrZsrZc@s eZdZdS) StreamReaderN)rTrUrVrrrrr[sr[c Cs tjdtjtjttttdS)NZpunycode)namerIrSincrementalencoderincrementaldecoder streamwriter streamreader) codecs CodecInforNrIrSrWrYrZr[rrrr getregentrysrc)rarrrrr#r$r'r-r3r6rBrErMrNrWrYrZr[rcrrrrs&