U e5d& @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|)#rrr [r<z"Possible nested set at position %dr) stacklevel^zunterminated character set]z-&~|zPossible set %s at position %d- difference& intersection~zsymmetric differenceunionz&Possible set difference at position %dr`zbad character range %s-%s?)rr<r+rrr:,z"the repetition number is too largez"min repeat greater than max repeatzunsupported quantifier %rr_znothing to repeatzmultiple repeat.(Tzunexpected end of patternP<> group namebad character in group name %r=)unknown group name %rr2zunknown 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)rIrCSRE_FLAG_LOCALErSRE_FLAG_ASCIISRE_FLAG_UNICODE)srcrrrr fix_flagss   rNcCst|}|dkrt}||_||_zt|||t@d}WnBtk rzt}|tB|_||_|dt||dd}YnXt||j j|j _|j dk r|j dkst | d|t @r||S)NrTrzunbalanced parenthesis)rorrrCrrrrrr7rtrr(SRE_FLAG_DEBUGrG)rCrr7r3r/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)Nrr:)r%r(r&joinr$)rWrr%literalliteralsrr7rraddgroups  z parse_template..addgrouprr r<gr:rz missing sz"parse_template..)ror)r& groupindexrzr(rrrrvrrr$r'rtrrrrrrrIrC) r3r7sgetlappendrrr{rr*rWisoctalrrrparse_templates               "           rcCsv|j}|jdd}|\}}|dd}z"|D]\}}||p@|||<q.Wn tk rjtd|YnX||S)Nrr)rrrrvr(r)templaterzremptyr%rrWrrrrexpand_templates  r")F)rN)=__doc__ sre_constantsrr frozensetrrrrrrrrfrrrDrrCATEGORYrgrrrZAT_BEGINNING_STRINGZ AT_BOUNDARYZAT_NON_BOUNDARYZCATEGORY_DIGITZCATEGORY_NOT_DIGITZCATEGORY_SPACEZCATEGORY_NOT_SPACEZ CATEGORY_WORDZCATEGORY_NOT_WORDZ AT_END_STRINGrSRE_FLAG_IGNORECASEr SRE_FLAG_MULTILINESRE_FLAG_DOTALLrr SRE_FLAG_TEMPLATEr rrrr  Exceptionrrr6rorrrrrrrrrr"rrrr sr                 #rH<M: r< U