3 \ @sdZddlTdZdZedZedZedZedZed Z ee e hZ ee eeeeehZeed feed feed feed feedfeedfeedfeedfdZeefeefeefeeefgfeeefgfeeefgfeeefgfeeefgfeeefgfee fd Z!e"e#e$e%e&e'e(e)dZ*e'e#Be)Be+Be(BZ,Gddde-Z.GdddZ/GdddZ0GdddZ1ddZ2dd Z3d!d"Z4d#d$Z5d3d&d'Z6d(d)Z7d*d+Z8d4d-d.Z9d/d0Z:d1d2Z;d,S)5zInternal support module for sre)*z .\[{()*+?^$|z*+?{ 0123456789Z01234567Z0123456789abcdefABCDEFZ4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZz      \)z\az\bz\fz\nz\rz\tz\vz\\) z\Az\bz\Bz\dz\Dz\sz\Sz\wz\Wz\Z)iLmsxatuc@s eZdZdS)VerboseN)__name__ __module__ __qualname__rr!/usr/lib64/python3.6/sre_parse.pyrGsrc@sBeZdZddZeddZdddZdd Zd d Zd d Z dS)PatterncCsd|_i|_dg|_d|_dS)Nr)flags groupdict groupwidthslookbehindgroups)selfrrr__init__LszPattern.__init__cCs t|jS)N)lenr)rrrrgroupsQszPattern.groupsNcCsb|j}|jjd|jtkr$td|dk r^|jj|d}|dk rTtd|||f||j|<|S)Nztoo many groupsz7redefinition of group name %r as group %d; was group %d)r"rappend MAXGROUPSerrorrget)rnamegidogidrrr opengroupTs   zPattern.opengroupcCs|j|j|<dS)N)getwidthr)rr(prrr closegroup`szPattern.closegroupcCs||jko|j|dk S)N)r"r)rr(rrr checkgroupbszPattern.checkgroupcCs6|jdk r2|j|s|jd||jkr2|jddS)Nzcannot refer to an open groupz?cannot refer to group defined in the same lookbehind subpattern)rr.r%)rr(sourcerrrchecklookbehindgroupes     zPattern.checklookbehindgroup)N) rrrr propertyr"r*r-r.r0rrrrrJs   rc@s`eZdZdddZdddZddZd d Zd d Zd dZddZ ddZ ddZ ddZ dS) SubPatternNcCs"||_|dkrg}||_d|_dS)N)patterndatawidth)rr3r4rrrr os zSubPattern.__init__rc Csd}ttf}x|jD]\}}t|dt|dd|tkrttx*|D]"\}}t|ddt||qLWq|tkrtx:t|dD]*\}}|rt|dd|j|dqWq|t kr|\}} } td|| j|d| rt|dd| j|dqt ||rd}x\|D]T}t |t rX|sDt|j|dd}n"|sjtd ddt|ddd}q(W|stqtd|qWdS) NTz )endORELSEF ) tuplelistr4printstrINBRANCH enumeratedumpGROUPREF_EXISTS isinstancer2) rlevelnlseqtypesopavrr condgroupitem_yesitem_norrrrCusH          zSubPattern.dumpcCs t|jS)N)reprr4)rrrr__repr__szSubPattern.__repr__cCs t|jS)N)r!r4)rrrr__len__szSubPattern.__len__cCs |j|=dS)N)r4)rindexrrr __delitem__szSubPattern.__delitem__cCs&t|trt|j|j|S|j|S)N)rEslicer2r3r4)rrQrrr __getitem__s zSubPattern.__getitem__cCs||j|<dS)N)r4)rrQcoderrr __setitem__szSubPattern.__setitem__cCs|jj||dS)N)r4insert)rrQrUrrrrWszSubPattern.insertcCs|jj|dS)N)r4r#)rrUrrrr#szSubPattern.appendc Cs|jdk r|jSd}}x|jD]\}}|tkrtd}d}x0|dD]$}|j\}}t||}t||}qJW||}||}q"|tkr|j\}}||}||}q"|tkr|dj\}}||}||}q"|t kr|dj\}}|||d}|||d}q"|t kr,|d}|d}q"|t krX|j j |\}}||}||}q"|tkr|dj\}}|ddk r|dj\}}t||}t||}nd}||}||}q"|tkr"Pq"Wt|tdt|tf|_|jS)Nrr8)r5r4rA MAXREPEATr+minmaxCALL SUBPATTERN _REPEATCODES _UNITCODESGROUPREFr3rrDSUCCESS) rlohirIrJr jlhrrrr+sZ                zSubPattern.getwidth)N)r) rrrr rCrOrPrRrTrVrWr#r+rrrrr2ms  (r2c@sbeZdZddZddZddZddZd d Zd d Ze d dZ ddZ ddZ dddZ dS) TokenizercCs@t|t|_||_|js"t|d}||_d|_d|_|jdS)Nlatin1r)rEr?istextstringdecoded_stringrQnext_Tokenizer__next)rrkrrrr s  zTokenizer.__init__cCs|j}y|j|}Wntk r.d|_dSX|dkr|d7}y||j|7}Wn.tk rtd|jt|jddYnX|d|_||_dS)Nr r8zbad escape (end of pattern))rQrl IndexErrorrmr%rkr!)rrQcharrrr__nexts zTokenizer.__nextcCs||jkr|jdSdS)NTF)rmrn)rrprrrmatchs zTokenizer.matchcCs|j}|j|S)N)rmrn)rthisrrrr&sz Tokenizer.getcCs:d}x0t|D]$}|j}||kr"P||7}|jqW|S)Nr6)rangermrn)rncharsetresult_crrrgetwhiles zTokenizer.getwhilecCshd}x^|j}|j|dkr>|s*|jd|jd|t|||krX|sV|jddP||7}qW|S)Nr6zmissing group namezmissing %s, unterminated namer8)rmrnr%r!)r terminatorrwryrrrgetuntil s     zTokenizer.getuntilcCs|jt|jpdS)Nr6)rQr!rm)rrrrpossz Tokenizer.poscCs|jt|jpdS)Nr6)rQr!rm)rrrrtellszTokenizer.tellcCs||_|jdS)N)rQrn)rrQrrrseekszTokenizer.seekrcCst||j|j|S)N)r%rkr~)rmsgoffsetrrrr%#szTokenizer.errorN)r)rrrr rnrrr&rzr|r1r}r~rr%rrrrrhs   rhc Cstj|}|r|Stj|}|r0|dtkr0|Sy|dd}|dkr||jdt7}t|dkrx|jd|t|tt |dddfS|dkr|j r||jdt7}t|d kr|jd|t|tt |dddfS|d ko|j rF||jd t7}t|d kr$|jd|t|t |ddd}t |t|fS|t kr||jdt 7}t |ddd }|d kr|jd|t|t|fS|t krtt|dkr|tkr|jd|t|tt|dfSWntk rYnX|jd|t|dS)Nrr8rXrzincomplete escape %srU z.octal escape value %s outside of range 0-0o377z bad escape %s)ESCAPESr& CATEGORIESr@rz HEXDIGITSr!r%LITERALintrjchr OCTDIGITSDIGITS ValueError ASCIILETTERSord)r/escaperUryrrr _class_escape&sR         rc Cstj|}|r|Stj|}|r$|Syt|dd}|dkr||jdt7}t|dkrl|jd|t|tt|dddfS|dkr|j r||jdt7}t|dkr|jd|t|tt|dddfS|d ko|j r:||jd t7}t|d kr|jd|t|t|ddd}t |t|fS|d krj||jdt 7}tt|ddd fS|t kr\|j t kr||j7}|dt kr|dt kr|j t kr||j7}t|ddd }|d kr|jd|t|t|fSt|dd}||jkrD|j|s0|jdt||j||t|fS|jd|t|dt|dkr|tkr|jd|t|tt|dfSWntk rYnX|jd|t|dS)Nr8rXrrzincomplete escape %srrrrrr0rz.octal escape value %s outside of range 0-0o377zcannot refer to an open groupzinvalid group reference %dz bad escape %s)rr&rrzrr!r%rrrjrrrrmr"r.r0rarrr)r/rstaterUrygrouprrr_escapeVsn                  rc Cs$g}|j}|j}|j}x.|t||||d| o4| |dsPqWt|dkr\|dSt|}|j} x\d} xP|D]*} | sP| dkr| d} qv| d| krvPqvWx|D] } | d=qW| | qlPqlWxD|D]"} t| dks| ddtk rPqW| tdd|Df|S|jtd|ff|S)Nr8|rcSsg|] }|dqS)rr).0itemrrr sz_parse_sub..) r#rrr~_parser!r2rr@rA) r/rverbosenesteditems itemsappend sourcematchstart subpatternsubpatternappendprefixrrrr _parse_subsD       rcCsht||||d}|jdrDt||||d}|jdkrH|jdnd}t|}|jt|||ff|S)Nr8rz/conditional backref with more than two branches)rrrrmr%r2r#rD)r/rrKrrrLrMrrrr_parse_sub_conds   rFc)Cs t|}|j}|j}|j}t} t} x|j} | dkr6P| dkr@P||r|| tkrTq&| dkr|x|} | dkst| dkr^Pq^Wq&| ddkrt|| |} || q&| t kr|t | | fq&| dkr4|j d} g}|j}|dr|t df|dd}x|} | dkr |j d |j | | d kr8||kr8Pn&| ddkrRt|| }n t | | f}|d r|}|dkr|j d |j | |d kr|dtkr|dd}|||t | d fP|ddkrt||}n t | |f}|dt ks |dt kr4d | |f}|j |t| dt||d}|d}||krvd | |f}|j |t| dt||t||ffn"|dtkr|dd}||qW| |dkr|ddt kr||dnT| |d kr&|ddt kr&|ddt kr&|t|ddfn |t|fq&| tkrb|j } | dkr\d7\}}nJ| dkrtdt}}n2| dkrdt}}n| dkr|jdkr|t | | fq&dt}}d}}x|jtkr||7}qW|drx"|jtkr ||7}qWn|}|ds8|t | | f|j| q&|rXt|}|tkrXtd|rt|}|tkrxtd||kr|j d|j | ntd|f|r|d8d}nd}| s| |dkr|ddtkr|j d|j | t| |ddtkr0|j d|j | t| |drNt|||ff|d9<nt|||ff|d:<q&| dkrz|tdfq&| dk r|j d}d}d}d}d}d}|d r|}|dkr|j d|dkr|dr|jd }|jsd!|}|j |t|dn|d"r|jd#}|jsHd!|}|j |t|d|j j|} | dkrzd$|}|j |t|d|j!| s|j d%t|d|j"| ||t#| fq&n2|}|dkr|j d|j d&|t|d n|d'krd}n|dkrDx4|jdkr*|j d(|j ||d#kr Pq Wq&n|d)kr0d}!|dkr|}|dkrv|j d|d*kr|j d+|t|d d;}!|j$}"|"dkr|j%|_$t&||||d}#|!dkr|"dkrd|_$|d#s|j d,|j ||d"kr|t'|!|#ffq&|t(|!|#ffq&n|dk r$|jd#}$d}|$jr|j j|$}|dk rd$|$}|j |t|$dnyt|$}|dkrt)Wn4t)k rd!|$}|j |t|$ddYnX|s|j d-t|$d|t*k rd.|}|j |t|$d|j"||n|t+k s8|d k rt,|||}%|%dk r| s\| rddl-}&|&j.d/|j/dd0t|j/d0k rd1ndft0|d2d3|j1t2@r&| r&t3q&|%\}}d}n|j d4|t|d|dk r0y|j4|}Wn<t k r.}'z|j |'j5t|ddWYdd}'~'XnX| rLt6|||||d}#n,| s\|t2@ od|t2@ }(t&|||(|d}#|jd# s|j d,|j ||dk r|j7||#|t8||||#ffq&| dk r|tt9fq&| d5k r|jtt:fq&td6|fq&W|S)zbad character in group name %r=)zunknown group name %rzcannot refer to an open groupzunknown extension ?P:zmissing ), unterminated commentz=!|t@rtd|t@s,|tO}qf|t@rftdn(|t@rNtd|t@rf|t@rftd|S)Nz)cannot use LOCALE flag with a str patternz(ASCII and UNICODE flags are incompatiblez,cannot use UNICODE flag with a bytes patternz'ASCII and LOCALE flags are incompatible)rEr?SRE_FLAG_LOCALErSRE_FLAG_ASCIISRE_FLAG_UNICODE)srcrrrr fix_flags<s   rNc Cst|}|dkrt}||_||_yt|||t@d}WnBtk rzt}|tB|_||_|jdt||dd}YnXt||j j|j _|j dk r|j d|t @r|j |S)NrTzunbalanced parenthesis)rhrrr?rrrrrr3rmr%SRE_FLAG_DEBUGrC)r?rr3r/r,rrrparseLs&    rc st|j}gggj}fdd}j}x|}|dkrNP|ddkr|d}|dkrJd}jdsjd jd }|jry ||} Wn tk rt d |YnXnlyt |} | dkrt Wn0t k rjd |t |ddYnX| t kr4jd | t |d|| t |dq|dkrjtkr||7}jtkr||7}|tt |dddd@q|tkrZd} jtkr4||7}|tkr4|dtkr4jtkr4||7}d} t |ddd}|dkr(jd|t ||t|| s|t |ddt |dnZytt|d}Wn<tk r|tkrddl} | jd|tddYnX||q>||q>Wr؈jdjt|tsddDfS)NcsX|jkrjd||r8jdjdd=jt|fjddS)Nzinvalid group reference %dr6)r"r%r#joinr!)rQr})r"literalliteralsr3rrraddgroupus  z parse_template..addgrouprr r8gr6rz missing .)rhr&r# groupindexrrr%r|rKeyErrorrorrr!r$rmrrrrrrrrrrEr?) r/r3sgetlappendrrrsryr'rQisoctalrr)r"rrr3rrparse_templatels             "             rc Csz|j}|jdd}|\}}|dd}y&x |D]\}}||pB|||<q0WWn tk rntd|YnX|j|S)Nrzinvalid group reference %d)rrkror%r)templaterrremptyr"rrQrrrrexpand_templates r)F)rN)<__doc__ sre_constantsrr frozensetrrrrrrrr_rrr@rrCATEGORYr`rrrZAT_BEGINNING_STRINGZ AT_BOUNDARYZAT_NON_BOUNDARYZCATEGORY_DIGITZCATEGORY_NOT_DIGITZCATEGORY_SPACEZCATEGORY_NOT_SPACEZ CATEGORY_WORDZCATEGORY_NOT_WORDZ AT_END_STRINGrSRE_FLAG_IGNORECASErSRE_FLAG_MULTILINESRE_FLAG_DOTALLrrSRE_FLAG_TEMPLATErrrr Exceptionrrr2rhrrrrrrrrrrrrrr sj               #qH0A3 <, W