Your IP : 3.143.23.153


Current Path : /lib64/python2.7/encodings/
Upload File :
Current File : //lib64/python2.7/encodings/punycode.pyo

�
�mec@sdZddlZd�Zd�Zd�Zd�Zd�ZdZd	�Zd
�Z	d�Z
d�Zd
�Zd�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�wis.
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*/usr/lib64/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*/usr/lib64/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*/usr/lib64/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*/usr/lib64/python2.7/encodings/punycode.pytinsertion_unsort2s$

	
cCs6d|d|}|dkr"dS|dkr2dS|S(Ni$ii((tjtbiasR((s*/usr/lib64/python2.7/encodings/punycode.pytTHst$abcdefghijklmnopqrstuvwxyz0123456789cCs�g}d}xpt||�}||kr?|jt|�|S|jt|||d|�||d|}|d7}qdS(s(3.3 Generalized variable-length integersii$iN(RRtdigits(tNRRRtt((s*/usr/lib64/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*/usr/lib64/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*/usr/lib64/python2.7/encodings/punycode.pytgenerate_integersls
$cCs[t|�\}}|jd�}t||�}tt|�|�}|rW|d|S|S(NRt-(RRRR.R(ttextR	R
R+((s*/usr/lib64/python2.7/encodings/punycode.pytpunycode_encodewsc
Cs;d}d}d}x"yt||�}Wn4tk
r_|dkrQtd�n|ddfSX|d7}d|ko�dknr�|d}nVd|ko�dknr�|d	}n-|dkr�td
||��n
|dfSt||�}	|||7}||	kr||fS|d|	}|d7}qdS(
s(3.3 Generalized variable-length integersiitstrictsincomplete punicode stringiAiZi0i9is Invalid extended code point '%s'i$N(Rt
IndexErrortUnicodeErrortNoneR(
R
textposRterrorsRtwRRtdigitR"((s*/usr/lib64/python2.7/encodings/punycode.pytdecode_generalized_number�s2





c	Csd}d}d}d}x�|t|�krt||||�\}}|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*/usr/lib64/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*/usr/lib64/python2.7/encodings/punycode.pytpunycode_decode�s	
tCodeccBs eZdd�Zdd�ZRS(R2cCst|�}|t|�fS(N(R1R(tselftinputR7R((s*/usr/lib64/python2.7/encodings/punycode.pyR�scCs;|dkrtd|�nt||�}|t|�fS(NR2treplacetignoresUnsupported error handling (sstrictsreplacesignore(R4RBR(RDRER7R((s*/usr/lib64/python2.7/encodings/punycode.pytdecode�s(t__name__t
__module__RRH(((s*/usr/lib64/python2.7/encodings/punycode.pyRC�stIncrementalEncodercBseZed�ZRS(cCs
t|�S(N(R1(RDREtfinal((s*/usr/lib64/python2.7/encodings/punycode.pyR�s(RIRJtFalseR(((s*/usr/lib64/python2.7/encodings/punycode.pyRK�stIncrementalDecodercBseZed�ZRS(cCs2|jdkr"td|j�nt||j�S(NR2RFRGsUnsupported error handling (sstrictsreplacesignore(R7R4RB(RDRERL((s*/usr/lib64/python2.7/encodings/punycode.pyRH�s(RIRJRMRH(((s*/usr/lib64/python2.7/encodings/punycode.pyRN�stStreamWritercBseZRS((RIRJ(((s*/usr/lib64/python2.7/encodings/punycode.pyRO�stStreamReadercBseZRS((RIRJ(((s*/usr/lib64/python2.7/encodings/punycode.pyRP�scCs@tjdddt�jdt�jdtdtdtdt�S(	NtnametpunycodeRRHtincrementalencodertincrementaldecodertstreamwritertstreamreader(	tcodecst	CodecInfoRCRRHRKRNRORP(((s*/usr/lib64/python2.7/encodings/punycode.pytgetregentry�s	(t__doc__RWRRRRRR R#R'R.R1R:R>RBRCRKRNRORPRY(((s*/usr/lib64/python2.7/encodings/punycode.pyt<module>s(