� ��^c@s�ddlmZddlZddlZddlZddlZddlmZdZdZ ej d�Z ej dd kr�e ZeZnd efd ��YZd efd ��YZdefd��YZdefd��YZd�Zd�Zd�Zd�Zd�Zd�Zed�Zd�Zd�Zd�Z d�Z!ed�Z"d�Z#d�Z$d �Z%e&ed!�Z'eeeed"�Z(eeed#�Z)dS($i(tidnadatai����N(tintranges_containi sxn--u [.。.。]iit IDNAErrorcBseZdZRS(s7 Base exception for all IDNA-encoding related problems (t__name__t __module__t__doc__(((s'/tmp/pip-build-1THPZW/idna/idna/core.pyRst IDNABidiErrorcBseZdZRS(s= Exception when bidirectional requirements are not satisfied (RRR(((s'/tmp/pip-build-1THPZW/idna/idna/core.pyRstInvalidCodepointcBseZdZRS(s> Exception when a disallowed or unallocated codepoint is used (RRR(((s'/tmp/pip-build-1THPZW/idna/idna/core.pyRstInvalidCodepointContextcBseZdZRS(sE Exception when the codepoint is not valid in the context it is used (RRR(((s'/tmp/pip-build-1THPZW/idna/idna/core.pyRscCsLtjt|��}|dkrHtjt|��sHtd��qHn|S(Nis Unknown character in unicodedata(t unicodedatat combiningtunichrtnamet ValueError(tcptv((s'/tmp/pip-build-1THPZW/idna/idna/core.pyt_combining_class$s  cCstt|�tj|�S(N(RtordRtscripts(Rtscript((s'/tmp/pip-build-1THPZW/idna/idna/core.pyt _is_script+scCs |jd�S(Ntpunycode(tencode(ts((s'/tmp/pip-build-1THPZW/idna/idna/core.pyt _punycode.scCs dj|�S(Ns U+{0:04X}(tformat(R((s'/tmp/pip-build-1THPZW/idna/idna/core.pyt_unot1scCst|�dkrtStS(Ni?(tlentFalsetTrue(tlabel((s'/tmp/pip-build-1THPZW/idna/idna/core.pytvalid_label_length5scCs&t|�|rdndkr"tStS(Ni�i�(RRR(Rt trailing_dot((s'/tmp/pip-build-1THPZW/idna/idna/core.pytvalid_string_length<sc Cst}xnt|d�D]]\}}tj|�}|dkr^tdjt|�|���n|dkrt}qqW| r�| r�tStj|d�}|dkr�t}n0|dkr�t}ntd jt|����t}t}x t|d�D]�\}}tj|�}|r�|dkrBtdj|���n|dkrWt}n|dkrlt}n|dkr�|s�|}q�||kr�td��q�q�q�|dkr�tdj|���n|dkr�t}q�|dkr�t}q�q�W|std��ntS(Nits3Unknown directionality in label {0} at position {1}tRtALtANitLs>First codepoint in label {0} must be directionality L, R or ALtENtEStCStETtONtBNtNSMsHInvalid direction for codepoint at position {0} in a right-to-left labels2Can not mix numeral types in a right-to-left labelsHInvalid direction for codepoint at position {0} in a left-to-right labels0Label ends with illegal codepoint directionality(R#R$R%(R#R$( R#R$R%R'R(R)R*R+R,R-(R#R$R'R%(R%R'(R&R'R(R)R*R+R,R-(R&R'(Rt enumerateR t bidirectionalRRtreprR( Rt check_ltrt bidi_labeltidxRt directiontrtlt valid_endingt number_type((s'/tmp/pip-build-1THPZW/idna/idna/core.pyt check_bidiCsP !                   cCs0tj|d�ddkr,td��ntS(NitMs0Label begins with an illegal combining character(R tcategoryRR(R((s'/tmp/pip-build-1THPZW/idna/idna/core.pytcheck_initial_combinerscCsU|dd!dkr"td��n|ddksB|ddkrQtd��ntS( Niis--s4Label has disallowed hyphens in 3rd and 4th positionit-i����s)Label must not start or end with a hyphen(RR(R((s'/tmp/pip-build-1THPZW/idna/idna/core.pytcheck_hyphen_ok�s  cCs+tjd|�|kr'td��ndS(NtNFCs%Label must be in Normalization Form C(R t normalizeR(R((s'/tmp/pip-build-1THPZW/idna/idna/core.pyt check_nfc�scCs�t||�}|dkrf|dkrOtt||d��tkrOtSnt}xzt|ddd�D]b}tjjt||��}|td�kr�qln|td�td�gkrlt}PqlqlW|s�tSt}x}t|dt |��D]b}tjjt||��}|td�kr6q�n|td�td�gkr�t}Pq�q�W|S|d kr�|dkr�tt||d��tkr�tSntStSdS( Ni iii����tTR&tDR#i ( RRt_virama_combining_classRRtrangeRt joining_typestgetR(Rtpostcp_valuetoktit joining_type((s'/tmp/pip-build-1THPZW/idna/idna/core.pytvalid_contextj�s<       cCs!t||�}|dkr�d|ko=t|�dknr}t||d�dkr}t||d�dkr}tSntS|dkr�|t|�dkr�t|�dkr�t||dd�StS|dks�|dkr |dkrt||dd �StS|d kroxQ|D]I}|d kr6qnt|d �sct|d �sct|d�rtSqWtSd|ko�dknr�x4|D],}dt|�ko�dknr�tSq�WtSd|ko�dknrx4|D],}dt|�ko dknr�tSq�WtSdS(Ni�iiiliutGreeki�i�tHebrewi�0u・tHiraganatKatakanatHani`iii�i�(RRRRR(RRGt exceptionRHR((s'/tmp/pip-build-1THPZW/idna/idna/core.pytvalid_contexto�s> &4 (    - " "cCs�t|ttf�r'|jd�}nt|�dkrHtd��nt|�t|�t|�x\t |�D]N\}}t |�}t |t j d�r�qsqst |t j d�r@yAt||�s�tdjt|�|dt|����nWq�tk r<tdjt|�|dt|����q�Xqst |t j d �r�t||�s�td jt|�|dt|����q�qstd jt|�|dt|����qsWt|�dS( Nsutf-8is Empty LabeltPVALIDtCONTEXTJs-Joiner {0} not allowed at position {1} in {2}is?Unknown codepoint adjacent to joiner {0} at position {1} in {2}tCONTEXTOs0Codepoint {0} not allowed at position {1} in {2}s0Codepoint {0} at position {1} of {2} not allowed(t isinstancetbytest bytearraytdecodeRRR@R=R;R.RRRtcodepoint_classesRLRRRR0R RSRR8(RRGRRH((s'/tmp/pip-build-1THPZW/idna/idna/core.pyt check_label�s0     )  )1/cCs�y<|jd�}t|�t|�s7td��n|SWntk rOnX|setd��nt|�}t|�t|�}t|}t|�s�td��n|S(NtasciisLabel too longsNo Input( RtulabelRRtUnicodeEncodeErrortunicodeR\Rt_alabel_prefix(R((s'/tmp/pip-build-1THPZW/idna/idna/core.pytalabel s"        cCs�t|ttf�sJy|jd�}WqJtk rFt|�|SXn|j�}|jt�r�|t t�}|j d�ddkr�t d��q�nt|�|j d�S|j d�}t|�|S(NR]i����R<s"A-label must not end with a hyphenR( RWRXRYRR_R\tlowert startswithRaRRZR(R((s'/tmp/pip-build-1THPZW/idna/idna/core.pyR^#s       c Cs�ddlm}d}yHx1t|�D]#\}}t|�}||dkrS|ntj||df�d}|d} t|�dkr�|dnd} | dks�| d kr�| s�| d kr�| r�| dkr�||7}q&| dk r1| d ks$| d kr| s$| d kr1|r1|| 7}q&| d kr&t��q&q&Wtj d |�SWn<tk r�t dj t |�|dt |����nXdS(sBRe-map the characters in the string according to UTS46 processing.i(t uts46datauitZiitVRBt3R9tIR>s0Codepoint {0} not allowed at position {1} in {2}N(ReR.Rtbisectt bisect_leftRtNonet IndexErrorR R?RRRR0( tdomaint std3_rulest transitionalRetoutputRGtchart code_pointtuts46rowtstatust replacement((s'/tmp/pip-build-1THPZW/idna/idna/core.pyt uts46_remap:s0  "     c Cs@t|ttf�r'|jd�}n|rBt|||�}nt}g}|rf|jd�}ntj|�}| s�|dgkr�td��n|ddkr�|d=t }nx<|D]4}t |�}|r�|j |�q�td��q�W|r|j d�ndj |�}t ||�s<td��n|S(NR]t.R"s Empty domaini����s Empty labelsDomain too long(RWRXRYRZRwRtsplitt_unicode_dots_reRRRbtappendtjoinR!( Rtstricttuts46RoRpR tresulttlabelsR((s'/tmp/pip-build-1THPZW/idna/idna/core.pyRVs2   cCst|ttf�r'|jd�}n|rBt||t�}nt}g}|sftj|�}n|jd�}| s�|dgkr�td��n|ds�|d=t }nx<|D]4}t |�}|r�|j |�q�td��q�W|r |j d�ndj |�S(NR]u.R"s Empty domaini����s Empty labelu( RWRXRYRZRwRRzRyRRR^R{R|(RR}R~RoR RR�R((s'/tmp/pip-build-1THPZW/idna/idna/core.pyRZus,    (*R"RRjR tretsyst intrangesRRCRatcompileRzt version_infotstrR`tchrR t UnicodeErrorRRRRRRRRRR!RR8R;R=R@RLRSR\RbR^RRwRRZ(((s'/tmp/pip-build-1THPZW/idna/idna/core.pytsB            <   , )