U AT^&c @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)BZ+e,e(BZ-Gddde.Z/GdddZ0GdddZ1GdddZ2ddZ3dd Z4d!d"Z5d#d$Z6d3d&d'Z7d(d)Z8d*d+Z9d4d-d.Z:d/d0Z;d1d2Z|dkrddl }|j d| dt|d d t | |f}|dt ks|dt krd| |f}||t| dt||d}|d}||kr*d| |f}||t| dt||t||ffn"|dtkrV|dd}||q t|}| |dkr|ddt kr|r|t|ddfn ||dn"|r|dtdf|t|fq"| tkr.| } | dkrd\}}nB| dkrdt}}n*| dkr0dt}}n| dkr4|jdkrX|t | | fq"dt}}d }}|jtkr||7}qj|d!r|jtkr||7}qn|}|ds|t | | f|| q"|rt|}|tkrtd"|rBt|}|tkrtd"||krB|d#| | ntd$|f|rV|d%d}nd}|rr|ddtkr|d&| | t| |ddtkr|d'| | t| |ddt kr|dd\}}}}|dkr|s|s|}|drt!|||ff|d%<nt"|||ff|d%<q"| d(krF|t#dfq"| d)k r| d} d*}d}!d}d}|d r|}|dkr|d+|d,kr|d-r|$d.d/}!|!%sd0|!}||t|!dn|d1r|$d2d/}!|!%sd0|!}||t|!d|j&|!}"|"dkrFd3|!}||t|!d|'|"sf|d4t|!d|(|"||t)|"fq"n2|}|dkr|d+|d5|t|dnd|d6krd}nR|dkr |jdkr|d7| | |d2krq"qq"n|d8krd}#|d-kr||}|dkr>|d+|d9kr`|d:|t|dd%}#|j*}$|$dkr||j+|_*t,||||d}|#dkr|$dkrd|_*|d2s|d;| | |d1kr|t-|#|ffq"|t.|#|ffq"n$|d)k rj|$d2d/}%|%% rL|j&|%}&|&dk rd3|%}||t|%dnzt|%}&|&dk rdt/Wn4t/k rd0|%}||t|%ddYnX|& s|d r0t1||||d}(|jd>k r4|d?nd}(|d2 sT|d;| | |t2|&|'|(ffq"n|t3k s~|dk rt4|||})|)dk r| r| rddl }|j d@|j5ddAt|j5dAk rdBnd ft6|d d |j7t8@r"|s"t9q"|)\}}d}n|dC|t|d|dk rrz|:|!}Wn<tk rp}*z||*j;t|!ddW5d}*~*XYnX| s|t8@ o|t8@ }+t,|||+|d}|d2 s|d;| | |dk r|<|||t ||||ffq"| d k r|tt=fq"| dDk r|tt>fq"tdE|fq"t?t|ddd%D]N},||,\}-}.|-t k r@|.\}}}}|dk r@| s@| s@|||,|,d< q@|S)FNz|)z#rrrz[r3z"Possible nested set at position %drq)Z stacklevelz^zunterminated character setz]z-&~|zPossible set %s at position %d-Z differencez&Z intersectionz~zsymmetric differenceZunionz&Possible set difference at position %drLzbad character range %s-%sz?)rr3rz+rvrxr2z,z"the repetition number is too largez"min repeat greater than max repeatzunsupported quantifier %rrKznothing to repeatzmultiple repeatZ.z(Tzunexpected end of patternZP<> group namebad character in group name %rz=)unknown group name %rr*zunknown extension ?P:zmissing ), unterminated commentz=!r?rZerrZ sub_verboserr;r<rrrrs|                                                                                                           *         rcCs|j}d}d}|dkrt|}|jr<|dkrRd}||n|dkrRd}||||O}|t@r||t@|kr|d}|||}|dkr|d|d krq|tkr|rd nd}||t|q|d kr|j|O_dS|t@r|d d |dkr|}|dkr|d|tkrF|r2d nd}||t|t|}|t@rfd}||||O}|}|dkr|d|dkrq|tkrF|rd nd}||t|qF|t@r|dd ||@r|dd ||fS)Nrrrz8bad inline flags: cannot use 'L' flag with a str patternr z:bad inline flags: cannot use 'u' flag with a bytes patternz9bad inline flags: flags 'a', 'u' and 'L' are incompatiblezmissing -, : or )z)-:z unknown flagrz,bad inline flags: cannot turn on global flagr3z missing flagz8bad inline flags: cannot turn off flags 'a', 'u' and 'L'z missing :rz-bad inline flags: cannot turn off global flagz(bad inline flags: flag turned on and off) r!rrXr TYPE_FLAGSZisalpharr GLOBAL_FLAGS)r+r/r^rrrZflagrmrrrr]sl                   rcCsjt|tr>|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)r:r5SRE_FLAG_LOCALErSRE_FLAG_ASCIISRE_FLAG_UNICODE)Zsrcrrrr fix_flagss   rNcCst|}|dkrt}||_||_zt|||t@d}WnBtk rzt}|tB|_||_|dt||dd}YnXt||j j|j _|j dk r| d|t @r| |S)NrTzunbalanced parenthesis)rWrrr5rrr rlrr/r[r SRE_FLAG_DEBUGr8)r5rr/r+r&rrrparses&    rc st|j}gggj}fdd}j}|}|dkrLq|ddkr|d}|dkrJd}dsd d d }|rz ||} Wn tk rt d |YnXnlzt |} | dkrt Wn0t k rd |t |ddYnX| t kr4d| t |d|| t |dq|dkrjtkr||7}jtkr||7}|tt |dddd@q|tkrZd} jtkr4||7}|tkr4|dtkr4jtkr4||7}d} t |ddd}|dkr(d|t ||t|| s|t |ddt |dnRztt|d}Wn4tk r|tkrd|t |YnX||q:||q:rΈdt|tsddDfS)NcsX|jkrd||r8ddd=t|fddS)Nrr2)rr rjoinr)rDrjrZliteralliteralsrr/rraddgroups  z parse_template..addgrouprrr3gr2rz missing sz"parse_template..)rWr!r groupindexr`r rgrrr]rrrrr[rrrrrrr:r5) r+r/ZsgetZlappendrrrarer"rDZisoctalrrrparse_templates               "           rcCsv|j}|jdd}|\}}|dd}z"|D]\}}||p@|||<q.Wn tk rjtd|YnX||S)Nrr)rrYr]r r)Ztemplater`rZemptyrrrDrrrrexpand_templates  r)F)rN)=Z__doc__Z sre_constantsrrZ frozensetrrrrrrrrQrrr6rrZCATEGORYrRrrrZAT_BEGINNING_STRINGZ AT_BOUNDARYZAT_NON_BOUNDARYZCATEGORY_DIGITZCATEGORY_NOT_DIGITZCATEGORY_SPACEZCATEGORY_NOT_SPACEZ CATEGORY_WORDZCATEGORY_NOT_WORDZ AT_END_STRINGrZSRE_FLAG_IGNORECASErZSRE_FLAG_MULTILINEZSRE_FLAG_DOTALLrrZSRE_FLAG_TEMPLATErrrrrZ Exceptionr rr.rWrrrrrrrrrrrrrrZ sr                 #rH<M: r< U