U .e-@s>ddlmZddlZddlZddlZddlZddlmZdZdZ e dZ ej ddkr`e ZeZGd d d eZGd d d eZGd ddeZGdddeZddZddZddZddZddZddZd7ddZd d!Zd"d#Zd$d%Zd&d'Z d8d(d)Z!d*d+Z"d,d-Z#d.d/Z$d9d1d2Z%d:d3d4Z&d;d5d6Z'dS)<)idnadataN)intranges_contain sxn--u [.。.。]c@seZdZdZdS) IDNAErrorz7 Base exception for all IDNA-encoding related problems N__name__ __module__ __qualname____doc__r r 9/usr/lib/python3.8/site-packages/pip/_vendor/idna/core.pyrsrc@seZdZdZdS) IDNABidiErrorz= Exception when bidirectional requirements are not satisfied Nrr r r rrsrc@seZdZdZdS)InvalidCodepointz> Exception when a disallowed or unallocated codepoint is used Nrr r r rrsrc@seZdZdZdS)InvalidCodepointContextzE Exception when the codepoint is not valid in the context it is used Nrr r r rrsrcCs0tt|}|dkr,tt|s,td|S)Nrz Unknown character in unicodedata) unicodedataZ combiningunichrname ValueError)cpvr r r_combining_class$s rcCstt|tj|S)N)rordrZscripts)rZscriptr r r _is_script+srcCs |dS)Npunycode)encodesr r r _punycode.srcCs d|S)Nz U+{0:04X})formatrr r r_unot1sr!cCst|dkrdSdS)N?FTlenlabelr r rvalid_label_length5s r'cCst||rdndkrdSdS)NFTr#)r& trailing_dotr r rvalid_string_length<sr+Fc Cs^d}t|dD]:\}}t|}|dkrd}q|dkrd}q|sZtddS)NFrz3Unknown directionality in label {0} at position {1})RALANTr)r-r.Lz>First codepoint in label {0} must be directionality L, R or AL) r-r.r/ENESCSETONBNNSMzHInvalid direction for codepoint at position {0} in a right-to-left label)r-r.r1r/r7)r/r1z2Can not mix numeral types in a right-to-left label)r0r1r2r3r4r5r6r7zHInvalid direction for codepoint at position {0} in a left-to-right label)r0r1z0Label ends with illegal codepoint directionality) enumeraterZ bidirectionalrr repr) r&Z check_ltrZ bidi_labelidxr directionZrtlZ valid_endingZ number_typer r r check_bidiCsP       r<cCs"t|dddkrtddS)NrMz0Label begins with an illegal combining characterT)rcategoryrr%r r rcheck_initial_combinersr?cCs<|dddkrtd|ddks0|ddkr8tdd S) Nz--z4Label has disallowed hyphens in 3rd and 4th positionr-z)Label must not start or end with a hyphenT)rr%r r rcheck_hyphen_oks rDcCstd||krtddS)NNFCz%Label must be in Normalization Form C)r normalizerr%r r r check_nfcsrGcCs4t||}|dkr|dkr8tt||dtkr8dSd}t|dddD]B}tjt||}|tdkrrqL|tdtd fkrLd}qqL|sdSd}t|dt|D]B}tjt||}|tdkrq|td td fkrd}qq|S|d kr,|dkr(tt||dtkr(dSdSdSdS) Ni rrTFrCTr0Dr-i )rr_virama_combining_classrangerZ joining_typesgetr$)r&poscp_valueokiZ joining_typer r rvalid_contextjs<     rQcCst||}|dkrdd|kr0t|dkr`nn,t||ddkr`t||ddkr`dSdS|dkr|t|dkrt|dkrt||ddSdS|d ks|d kr|dkrt||dd SdS|d kr|D]6}|d krqt|ds t|ds t|drdSqdSd|kr.dkrhnn6|D],}dt|krVdkr6nndSq6dSd|krdkrnn6|D],}dt|krdkrnndSqdSdS)NrrlTFiuZGreekiiZHebrewi0u・ZHiraganaZKatakanaZHani`iiii)rr$r)r&rMZ exceptionrNrr r rvalid_contextos>  ( "    rTc CsLt|ttfr|d}t|dkr,tdt|t|t|t |D]\}}t |}t |t j drpqLqLt |t j drz,t||stdt||dt|Wn2tk rtdt||dt|YnXqLt |t j d r t||s>td t||dt|qLtd t||dt|qLt|dS) Nzutf-8rz Empty LabelZPVALIDZCONTEXTJz-Joiner {0} not allowed at position {1} in {2}rz?Unknown codepoint adjacent to joiner {0} at position {1} in {2}ZCONTEXTO0Codepoint {0} not allowed at position {1} in {2}z0Codepoint {0} at position {1} of {2} not allowed) isinstancebytes bytearraydecoder$rrGrDr?r8rrrZcodepoint_classesrQrr r!r9rrTrr<)r&rMrrNr r r check_labels<       rZcCs~z(|d}t|t|s$td|WStk r<YnX|sJtdt|}t|t|}t|}t|sztd|S)NasciizLabel too longzNo Input) rulabelr'rUnicodeEncodeErrorunicoderZr_alabel_prefixr%r r ralabel s" r`cCst|ttfs>z|d}Wn tk r<t||YSX|}|trb|t td}nt|| dS| d}t||S)Nr[r) rVrWrXrr]rZlower startswithr_r$rYr%r r rr\#s    r\Tc Cs(ddlm}d}zt|D]\}}t|}||dkr8|nt||dfd}|d} t|dkrj|dnd} | d ks| d kr|r| d kr|s| dkr||7}q| dk r| d ks| d kr|r| d kr|r|| 7}q| d krtqtd|WStk r"t d t ||dt |YnXdS)zBRe-map the characters in the string according to UTS46 processing.r) uts46datar,Zrr@NVrI3r=IrErU) rcr8rbisectZ bisect_leftr$ IndexErrorrrFrr r!r9) Zdomain std3_rules transitionalrcoutputrMcharZ code_pointZuts46rowZstatusZ replacementr r r uts46_remap8sV   roc Cst|ttfr|d}|r(t|||}d}g}|r@|d}n t|}|rX|dgkr`td|ddkrv|d=d}|D]$}t|}|r| |qztdqz|r| d d |}t ||std |S) Nr[F.r, Empty domainrCT Empty label.zDomain too long) rVrWrXrYrosplit_unicode_dots_rerr`appendjoinr+) rstrictuts46rkrlr*resultlabelsr&r r rrTs2          rcCst|ttfr|d}|r(t||d}d}g}|s@t|}n |d}|rX|dgkr`td|dsr|d=d}|D]$}t|}|r| |qvtdqv|r| dd |S) Nr[Frpr,rqrCTrr) rVrWrXrYrorvrurr\rwrx)rryrzrkr*r{r|r&r r rrYss,       rY)F)F)TF)FFFF)FFF)(r,rrirresysZ intrangesrrJr_compilerv version_infostrr^chrr UnicodeErrorrrrrrrrr!r'r+r<r?rDrGrQrTrZr`r\rorrYr r r rsB    < , )