�`^c@sdZddlZd�Zd�Zd�Zd�Zd�ZdZd �Zd
�Z d�Z
d�Zd
�Zd�Z
d�Zdejfd��YZdejfd��YZdejfd��YZdeejfd��YZdeejfd��YZd�ZdS(sX Codec for the Punicode encoding, as specified in RFC 3492
Written by Martin v. L�.
i�NcCs{g}i}x:|D]2}t|�dkr;|j|�qd||<qW|j�}|j�dj|�jd�|fS(s 3.1 Basic code point segregationi�ittascii(tordtappendtkeystsorttjointencode(tstrtbasetextendedtc((s(/sys/lib/python2.7/encodings/punycode.pyt segregates
cCs:d}x-|D]%}t|�|kr
|d7}q
q
W|S(s@Return the length of str, considering only characters below max.ii(R(RtmaxtresR((s(/sys/lib/python2.7/encodings/punycode.pyt
selective_lens
cCsmt|�}xZ|d7}||kr)dS||}||krM|d|fS||kr|d7}qqdS(sReturn a pair (index, pos), indicating the next occurrence of
char in str. index is the position of the character considering
only ordinals up to and including char, and pos is the position in
the full string. index/pos is the starting position in the full
string.ii�N(i�i�(tlen(RtchartindextpostlR((s(/sys/lib/python2.7/encodings/punycode.pytselective_find s
cCs�d}g}d}x�|D]�}d}}t|�}t||�} | d||}
xYt||||�\}}|dkr�Pn|
||7}
|j|
d�|}d}
qY|}qW|S(s3.2 Insertion unsort codingi�i�ii(RRRR(RR
toldchartresulttoldindexRRRRtcurlentdelta((s(/sys/lib/python2.7/encodings/punycode.pytinsertion_unsort2s$
cCs6d|d|}|dkr"dS|dkr2dS|S(Ni$ii((tjtbiasR((s(/sys/lib/python2.7/encodings/punycode.pytTHst$abcdefghijklmnopqrstuvwxyz0123456789cCs�g}d}xpt||�}||kr?|jt|�|S|jt|||d|�||d|}|d7}qdS(s(3.3 Generalized variable-length integersii$iN(RRtdigits(tNRRRtt((s(/sys/lib/python2.7/encodings/punycode.pytgenerate_generalized_integerPs!cCsr|r|d}n
|d}|||7}d}x$|dkrW|d}|d7}q4W|d||d}|S(Ni�iii�i#i$i&((Rtfirsttnumcharst divisionsR((s(/sys/lib/python2.7/encodings/punycode.pytadapt]s
cCsrg}d}xVt|�D]H\}}t||�}|j|�t||dk||d�}qWdj|�S(s3.4 Bias adaptationiHiiR(t enumerateR#textendR'R(tbaselentdeltasRRtpointsRts((s(/sys/lib/python2.7/encodings/punycode.pytgenerate_integersls
$cCs[t|�\}}|jd�}t||�}tt|�|�}|rW|d|S|S(NRt-(RRRR.R(ttextR R
R+((s(/sys/lib/python2.7/encodings/punycode.pytpunycode_encodewsc
Cs;d}d}d}x"yt||�}Wn4tk
r_|dkrQtd�n|ddfSX|d7}d|ko�dknr�|d}nVd|ko�dknr�|d }n-|dkr�td
||��n
|dfSt||�} |||7}|| kr||fS|d| }|d7}qdS(
s(3.3 Generalized variable-length integersiitstrictsincomplete punicode stringiAiZi0i9is Invalid extended code point '%s'i$N(Rt
IndexErrortUnicodeErrortNoneR(
R
textposRterrorsRtwRRtdigitR"((s(/sys/lib/python2.7/encodings/punycode.pytdecode_generalized_number�s2
c Csd}d}d}d}x�t|�krt||||�\}}|d
krX|S||d7}||t|�d7}|dkr�|dkr�td|�ntd �}n|t|�d}|| t|�||}t||dkt|��}|}qW|S(s3.2 Insertion unsort codingi�i�iHiii�R2sInvalid character U+%xt?N(RR:R5R4RtunichrR'( R R
R7RRRR6tnewposR((s(/sys/lib/python2.7/encodings/punycode.pytinsertion_sort�s(
cCsp|jd�}|dkr*d}|}n|| }||d}t|d|�}|j�}t|||�S(NR/i�RiR(trfindtunicodetupperR>(R0R7RR R
((s(/sys/lib/python2.7/encodings/punycode.pytpunycode_decode�s
tCodeccBs eZdd�Zdd�ZRS(R2cCst|�}|t|�fS(N(R1R(tselftinputR7R((s(/sys/lib/python2.7/encodings/punycode.pyR�scCs;|dkrtd|�nt||�}|t|�fS(NR2treplacetignoresUnsupported error handling (sstrictsreplacesignore(R4RBR(RDRER7R((s(/sys/lib/python2.7/encodings/punycode.pytdecode�s(t__name__t
__module__RRH(((s(/sys/lib/python2.7/encodings/punycode.pyRC�stIncrementalEncodercBseZed�ZRS(cCs
t|�S(N(R1(RDREtfinal((s(/sys/lib/python2.7/encodings/punycode.pyR�s(RIRJtFalseR(((s(/sys/lib/python2.7/encodings/punycode.pyRK�stIncrementalDecodercBseZed�ZRS(cCs2|jdkr"td|j�nt||j�S(NR2RFRGsUnsupported error handling (sstrictsreplacesignore(R7R4RB(RDRERL((s(/sys/lib/python2.7/encodings/punycode.pyRH�s(RIRJRMRH(((s(/sys/lib/python2.7/encodings/punycode.pyRN�stStreamWritercBseZRS((RIRJ(((s(/sys/lib/python2.7/encodings/punycode.pyRO�stStreamReadercBseZRS((RIRJ(((s(/sys/lib/python2.7/encodings/punycode.pyRP�scCs@tjdddt�jdt�jdtdtdtdt�S( NtnametpunycodeRRHtincrementalencodertincrementaldecodertstreamwritertstreamreader( tcodecst CodecInfoRCRRHRKRNRORP(((s(/sys/lib/python2.7/encodings/punycode.pytgetregentry�s (t__doc__RWRRRRRR R#R'R.R1R:R>RBRCRKRNRORPRY(((s(/sys/lib/python2.7/encodings/punycode.pyt<module>s(
|