ó „J¶Xc@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-/usr/lib/python2.7/site-packages/idna/core.pyRst IDNABidiErrorcBseZdZRS(s= Exception when bidirectional requirements are not satisfied (RRR(((s-/usr/lib/python2.7/site-packages/idna/core.pyRstInvalidCodepointcBseZdZRS(s> Exception when a disallowed or unallocated codepoint is used (RRR(((s-/usr/lib/python2.7/site-packages/idna/core.pyRstInvalidCodepointContextcBseZdZRS(sE Exception when the codepoint is not valid in the context it is used (RRR(((s-/usr/lib/python2.7/site-packages/idna/core.pyRscCstjt|ƒƒS(N(t unicodedatat combiningtunichr(tcp((s-/usr/lib/python2.7/site-packages/idna/core.pyt_combining_class$scCstt|ƒtj|ƒS(N(RtordRtscripts(R tscript((s-/usr/lib/python2.7/site-packages/idna/core.pyt _is_script'scCs |jdƒS(Ntpunycode(tencode(ts((s-/usr/lib/python2.7/site-packages/idna/core.pyt _punycode*scCs dj|ƒS(Ns U+{0:04X}(tformat(R((s-/usr/lib/python2.7/site-packages/idna/core.pyt_unot-scCst|ƒdkrtStS(Ni?(tlentFalsetTrue(tlabel((s-/usr/lib/python2.7/site-packages/idna/core.pytvalid_label_length1scCs&t|ƒ|rdndkr"tStS(Nižiż(RRR(Rt trailing_dot((s-/usr/lib/python2.7/site-packages/idna/core.pytvalid_string_length8sc Cst}xot|dƒD]^\}}tj|ƒ}|dkr^tdjt|ƒ|ƒƒ‚n|dkrt}PqqW| rŠ| rŠtStj|dƒ}|dkr²t}n0|dkrĒt}ntd jt|ƒƒƒ‚t}t}x t|dƒD]ł\}}tj|ƒ}|r©|dkrCtdj|ƒƒ‚n|dkrXt}n|dkrmt}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_labeltidxR t directiontrtlt valid_endingt number_type((s-/usr/lib/python2.7/site-packages/idna/core.pyt check_bidi?sR !                  cCs0tj|dƒddkr,tdƒ‚ntS(NitMs0Label begins with an illegal combining character(R tcategoryRR(R((s-/usr/lib/python2.7/site-packages/idna/core.pytcheck_initial_combiner|scCsU|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-/usr/lib/python2.7/site-packages/idna/core.pytcheck_hyphen_okƒs  cCs+tjd|ƒ|kr'tdƒ‚ndS(NtNFCs%Label must be in Normalization Form C(R t normalizeR(R((s-/usr/lib/python2.7/site-packages/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 ( RR t_virama_combining_classRRtrangeRt joining_typestgetR(Rtpostcp_valuetoktit joining_type((s-/usr/lib/python2.7/site-packages/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 krrxT|D]L}|d kr6qnt|d ƒ rt|d ƒ rt|dƒ rtSqWtSd|ko‰dknrÉx4|D],}dt|ƒkoødknr•tSq•WtSd|koądknr x4|D],}dt|ƒkodknrģtSqģWtSdS(Ni·iiiliutGreekióiōtHebrewiū0u惻tHiraganatKatakanatHani`iiišił(RRRRR(RRDt exceptionRER ((s-/usr/lib/python2.7/site-packages/idna/core.pytvalid_contexto¾s> &4 (    0 " "cCst|ttfƒr'|jdƒ}nt|ƒdkrHtdƒ‚nt|ƒt|ƒt|ƒxt |ƒD] \}}t |ƒ}t |t j dƒr§qsqst |t j dƒrżt||ƒs~tdjt|ƒ|dt|ƒƒƒ‚q~qst |t j dƒrSt||ƒs~td jt|ƒ|dt|ƒƒƒ‚q~qstd jt|ƒ|dt|ƒƒƒ‚qsWt|ƒdS( Nsutf-8is Empty LabeltPVALIDtCONTEXTJs-Joiner {0} not allowed at position {1} in {2}itCONTEXTOs0Codepoint {0} not allowed at position {1} in {2}s0Codepoint {0} at position {1} of {2} not allowed(t isinstancetbytest bytearraytdecodeRRR=R:R8R+RRRtcodepoint_classesRIRRRR-RPRR5(RRDR RE((s-/usr/lib/python2.7/site-packages/idna/core.pyt check_labelēs&    11/cCsŻyi|jdƒ}yt|ƒWn&tk rHtdj|ƒƒ‚nXt|ƒsdtdƒ‚n|SWntk r|nX|s’tdƒ‚nt|ƒ}t|ƒt|ƒ}t |}t|ƒsŁtdƒ‚n|S(Ntasciis$The label {0} is not a valid A-labelsLabel too longsNo Input( RtulabelRRRtUnicodeEncodeErrortunicodeRYRt_alabel_prefix(R((s-/usr/lib/python2.7/site-packages/idna/core.pytalabels(        cCs¬t|ttfƒsJy|jdƒ}WqJtk rFt|ƒ|SXn|jƒ}|jtƒrx|t tƒ}nt|ƒ|j dƒS|j dƒ}t|ƒ|S(NRZR( RTRURVRR\RYtlowert startswithR^RRW(R((s-/usr/lib/python2.7/site-packages/idna/core.pyR[s      c CsŸddlm}d}yFx/t|ƒD]!\}}t|ƒ}||dkrS|ntj||dfƒd}|d} t|ƒdkr–|dnd} | dksŁ| d kr»| sŁ| d krę|rę| dkrę||7}q&| dk r/| d ks"| d kr|s"| d kr/|r/|| 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 uts46datauitZiitVR?t3R6tIR;s0Codepoint {0} not allowed at position {1} in {2}N(RbR+Rtbisectt bisect_leftRtNonet IndexErrorR R<RRRR-( tdomaint std3_rulest transitionalRbtoutputRDtchart code_pointtuts46rowtstatust replacement((s-/usr/lib/python2.7/site-packages/idna/core.pyt uts46_remap3s0  "     c Cs4t|ttfƒr'|jdƒ}n|rBt|||ƒ}nt}g}|rf|jdƒ}ntj|ƒ}x|r“|d r“|d=qxW|s©tdƒ‚n|ddkrÉ|d=t }nx!|D]}|j t |ƒƒqŠW|r|j dƒndj |ƒ}t ||ƒs0tdƒ‚n|S(NRZt.is Empty domaini’’’’RsDomain too long(RTRURVRWRtRtsplitt_unicode_dots_reRRtappendR_tjoinR( Rtstricttuts46RlRmRtresulttlabelsR((s-/usr/lib/python2.7/site-packages/idna/core.pyROs0   cCs t|ttfƒr'|jdƒ}n|rBt||tƒ}nt}g}|sftj|ƒ}n|jdƒ}x|r“|d r“|d=qxW|s©tdƒ‚n|dsĆ|d=t }nx!|D]}|j t |ƒƒqŹW|rż|j dƒndj |ƒS(NRZu.is Empty domaini’’’’u( RTRURVRWRtRRwRvRRRxR[Ry(RRzR{RlRR|R}R((s-/usr/lib/python2.7/site-packages/idna/core.pyRWls*    (*RRRgR tretsyst intrangesRR@R^tcompileRwt version_infotstrR]tchrR t UnicodeErrorRRRRR RRRRRRR5R8R:R=RIRPRYR_R[RRtRRW(((s-/usr/lib/python2.7/site-packages/idna/core.pytsB            =   , )