[v@sdZddlTddlmZdZdZedZedZedZ ed Z ie e d fd 6e e d fd 6e e dfd6e e dfd6e e dfd6e e dfd6e e dfd6e e dfd6Z i eefd6eefd 6eefd6eeefgfd6eeefgfd6eeefgfd6eeefgfd6eeefgfd 6eeefgfd!6eefd"6Zied#6ed$6ed%6ed&6e d'6e!d(6e"d)6e#d*6Z$Gd+d,d,Z%Gd-d.d.Z&Gd/d0d0Z'd1d2Z(d3d4Z)d5d6Z*d7d8Z+d9d:Z,d;d<d=Z-d>d?Z.ed@Z/edAZ0edBZ1ee2e3gZ4dCdDZ5dEdFZ6ddGdHdIZ7dJdKZ8dLdMZ9dGS)NzInternal support module for sre)*) MAXREPEATz .\[{()*+?^$|z*+?{ 0123456789Z01234567Z0123456789abcdefABCDEFz z\az\b z\f z\n z\r z\t z\v\z\\z\Az\Bz\dz\Dz\sz\Sz\wz\Wz\ZiLmsxatuc@sCeZdZddZdddZddZdd ZdS) PatterncCs(d|_g|_d|_i|_dS)Nr)flagsopengroups groupdict)selfr/usr/lib/python3.4/sre_parse.py__init__Cs   zPattern.__init__NcCs|j}|d|_|dk ru|jj|d}|dk retdt|||fn||j|slicer-r.r/)rrJrrr __getitem__szSubPattern.__getitem__cCs||j|stristextstringrJ_Tokenizer__next)rrirrrrs  zTokenizer.__init__c Cs|jt|jkr%d|_dS|j|j|jd}|re|j ret|d}n|dkry|j|jd}Wntk rtdYnX|jst|}n||}n|jt||_||_dS)Nrrr zbogus escape (end of line))rJrHrinextrhchr IndexErrorr )rcharcrrr__nexts      zTokenizer.__nextrcCs*||jkr&|r"|jndSdS)Nrr)rkrj)rrnskiprrrmatchs  zTokenizer.matchcCs|j}|j|S)N)rkrj)rthisrrrrs  z Tokenizer.getcCsNd}xAt|D]3}|j}||kr2Pn||7}|jqW|S)Nr2)rangerkrj)rncharsetresult_rorrrgetwhiles   zTokenizer.getwhilecCs|j|jfS)N)rJrk)rrrrtellszTokenizer.tellcCs|\|_|_dS)N)rJrk)rrJrrrseekszTokenizer.seekN) r*r+r,rrjrrrryrzr{rrrrrfs     rfcCsdddl}|jdtddd|ko9dknpcd|koUdknpc|d kS) Nrz*sre_parse.isident() will be removed in 3.5 stacklevelrQrzAZrx)warningswarnDeprecationWarning)rnrrrrisidents   rcCs:ddl}|jdtddd|ko7dkSS)Nrz*sre_parse.isdigit() will be removed in 3.5r|rQ09)rrr)rnrrrrisdigits   rcCssddl}|jdtddt|ds6dSx6|ddD]$}t| rGt| rGdSqGWdS)Nrz)sre_parse.isname() will be removed in 3.5r|rQFrT)rrrrr)r#rrnrrrisnames   rc Cs7tj|}|r|Stj|}|rB|dtkrB|Sy|dd}|dkr||jdt7}t|dkrtntt |dddd@fS|dkr|j r||jdt7}t|d krtntt |dddfS|d kr|j r||jd t7}t|d kr\tnt |ddd}t |t|fS|t kr||jdt 7}tt |ddd d@fS|t krtnt|dkrtt|dfSWntk rYnXtd t|dS)NrrrQrrU zbogus escape: %s)ESCAPESr CATEGORIESr9ry HEXDIGITSrH ValueErrorrTintrhrl OCTDIGITSDIGITSordr r!)sourceescaperNrorrr _class_escape sF  !     !   rc Cstj|}|r|Stj|}|r2|Sy|dd}|dkr||jdt7}t|dkrtntt|dddd@fS|dkr|j r||jdt7}t|dkrtntt|dddfS|d kry|j ry||jd t7}t|d krLtnt|ddd}t |t|fS|d kr||jdt 7}tt|ddd d@fS|t kr|j t krJ||j}|dt krJ|dt krJ|j t krJ||j}tt|ddd d@fSnt|dd}||jkr|j|std nt|fStnt|dkrtt|dfSWntk rYnXtdt|dS)NrrQrrrrrrrrrrzcannot refer to open groupzbogus escape: %s)rrrryrrHrrTrrhrlrrrkrr)r GROUPREFrr!)rrstaterNrogrouprrr_escape3s\  !     !  $   rrc Csg}|j}|j}x\|t|||dr@qn|sJPn|j sc|ddrgPqtdqWt|dkr|dSt|}|j}xxd}xj|D]=} | sPn|dkr| d}q| d|krPqqWx|D] } | d=qW||qPqWxz|D]0} t| dksT| ddtkr(Pq(q(Wg} | j} x|D]} | | dqrW|t| f|S|jt d|ff|S)N|)rzpattern not properly closedr) r"rr_parserkr rHr-rTr9r:) rrnesteditems itemsappend sourcematch subpatternsubpatternappendprefixitemset setappendrrr _parse_subksR            &  rcCst||}|jdrNt||}|jdrTtdqTnd}|jr|jdd rtdnt|}|jt|||ff|S)Nrz/conditional backref with more than two branchesrrzpattern not properly closed)rrrr rkr-r"r=)rrrDrErFrrrr_parse_sub_conds rz|)z=!td%ntd&|q |d'rfd }q |drx-|j dks|j d"krPn|quW|d"sHtd(qHqHq |j |kr |}d }|dkr |j | kr td)nd3}|}nt%||}|d"sG td(n|d!krl |t&||ffqH|t'||ffqHq |dry d}xB|}|dkr tdn|d"kr Pn||}q Wd }|s tdn|j!rE |j"j|}|dkrv d$j#|}t|qv q yt|}Wq t(k ru td*Yq Xq |j t)kr td%nx-|j t)kr |j t)|B|_ q Wn|rk |d kr d}n|j*|}|r t+|||}nt%||}|d"s6 td(n|dk rR |j,|n|t-||ffq7 x|}|dkr td%n|d"kr Pntd+qn WqH| dkr |tt.fqH| d,kr |jtt/fqH| r+ | ddkr+ t0|| |} || qHtd-qHW|S)4N#rr[^]r z$unexpected end of regular expression-rzbad character rangerQ?r+{}r2,z"the repetition number is too largezbad repeat intervalz not supportedznothing to repeatzmultiple repeat.(Pzmissing group namezbad character in group name %r=rz&bad character in backref group name %rzunknown group name: {0!r}zunexpected end of patternzunknown specifier: ?P%s:zunbalanced parenthesisz syntax errorzbad character in group namezunknown extension$z parser error)Nr)rrrrr)1r-r"rrrrH_PATTERNENDERS _ASSERTCHARS_LOOKBEHINDASSERTCHARS _REPEATCODESrkrSRE_FLAG_VERBOSE WHITESPACE SPECIAL_CHARSrTrNEGATErr r9rSrU REPEAT_CHARSrrzrr{r OverflowErrorATrWrXrR isidentifierrformatrrASSERT ASSERT_NOTrFLAGSr&rr(r] AT_BEGINNINGAT_ENDr)!rrrr sourcegetr_len PATTERNENDERS ASSERTCHARSLOOKBEHINDASSERTCHARSrbrsrrstartcode1code2r_r`rZr[hererrr#rDrnr$msgdirpcondnamerNrrrrs                         &:                -                                              rcCs_t|trB|t@s&|tO}q[|t@r[tdq[n|t@r[tdn|S)Nz(ASCII and UNICODE flags are incompatiblez+can't use UNICODE flag with a bytes pattern)r>rgSRE_FLAG_ASCIISRE_FLAG_UNICODEr)srcrrrr fix_flagss    rNcCst|}|dkr$t}n||_||_t||d}t||jj|j_|j}|dkrtdn|rtdn|t @r|j n|t @ r|jjt @rt ||jjS|S)Nrrzunbalanced parenthesisz-bogus characters at end of regular expression) rfrrrgrrr.rr SRE_FLAG_DEBUGr<rparse)rgrr.rrtailrrrrs"         rc snt|}|j}gggj}fdd}x|}|dkrdPn|ddkr|d}|dkrd}|jdrxE|} | dkrtd n| d krPn|| 7}qWn|std ny+t|} | dkr&td nWnntk r|jsRtd ny|j|} Wn-t k rdj |} t | YnXYnX|| q|dkr|j t kr||7}|j t kr||7}qn|tt|dddd@q|tkrd} |j tkr||7}|t kr|dt kr|j t kr||7}d} |tt|dddd@qn| s|t|ddqqytt|d}Wnt k rYnX||qK||qKWr?jdjnt|tsdddDnfS)NcsVr,jdjdd=njt|fjddS)Nr2)r"joinrH)rJ)rliteralliteralsrraddgroups z parse_template..addgrouprr rgr2rzunterminated group namerzmissing group nameznegative group numberzbad character in group namezunknown group name: {0!r}rrrFrQTcSs1g|]'}|dkrdn |jdqS)Nzlatin-1)encode).0rrrr Xs z"parse_template..)rfrr"rrr rrr groupindexKeyErrorrrmrkrrlrrrr>rg) rr.rsgetlappendrrsror#rnrJrisoctalr)rrrrparse_template s                  *   -   rc Cs|j}|jdd}|\}}|dd}yJxC|D];\}}||||<}|dkrBtdqBqBWWntk rtdYnX|j|S)Nrzunmatched groupzinvalid group reference)rrir rmr) templaterrrseprrrJrrrrrexpand_template[s    r):__doc__ sre_constants_srerrrrrrrrrTrrrAT_BEGINNING_STRING AT_BOUNDARYAT_NON_BOUNDARYr9rVCATEGORY_DIGITCATEGORY_NOT_DIGITCATEGORY_SPACECATEGORY_NOT_SPACE CATEGORY_WORDCATEGORY_NOT_WORD AT_END_STRINGrSRE_FLAG_IGNORECASESRE_FLAG_LOCALESRE_FLAG_MULTILINESRE_FLAG_DOTALLrrSRE_FLAG_TEMPLATErrrr-rfrrrrrrrrrrrWrXrrrrrrrrrr sr         e4   * 8;     *  P