nfc@sdZddlZddlTddlmZdZdZedZedZ ed Z ed Z ie e d fd 6e e d fd6e e dfd6e e dfd6e e dfd6e e dfd6e e dfd6e e dfd6Zi eefd6eefd6eefd6eeefgfd6eeefgfd6eeefgfd6eeefgfd 6eeefgfd!6eeefgfd"6eefd#6Zied$6ed%6ed&6e d'6e!d(6e"d)6e#d*6Z$d+fd,YZ%d-fd.YZ&d/fd0YZ'd1Z(d2Z)d3Z*d4Z+d5Z,d6d7Z-d8Z.ed9Z/ed:Z0ed;Z1ee2e3gZ4d<Z5d=e6d>Z7d?Z8d@Z9dS(AsInternal support module for sreiN(t*(t MAXREPEATs .\[{()*+?^$|s*+?{t 0123456789t01234567t0123456789abcdefABCDEFs ss\ass\bs s\fs s\ns s\rs s\ts s\vs\s\\s\As\Bs\ds\Ds\ss\Ss\ws\Ws\ZtitLtmtstxtttutPatterncBs/eZdZddZdZdZRS(cCs(d|_g|_d|_i|_dS(Nii(tflagstopentgroupst groupdict(tself((s!/usr/lib64/python2.7/sre_parse.pyt__init__Ds   cCs|j}|d|_|dk rr|jj|d}|dk rbtdt|||fn||j|tintt OCTDIGITStDIGITStordt ValueError(tsourcetescapeR8RW((s!/usr/lib64/python2.7/sre_parse.pyt _class_escapes6  $  $   cCsBtj|}|r|Stj|}|r2|Sy|dd!}|dkrx5|jtkrt|dkr||j}qQWt|dkrtntt|ddd@fS|dkrx5|jt krt|dkr||j}qWtt|ddd@fS|t kr|jt kr||j}|dt kr|dt kr|jt kr||j}tt|ddd@fSnt|d}||j kr|j |st d nt|fStnt|dkrtt|dfSWntk r*nXt d t|dS( NiiR iiiRciscannot refer to open groupsbogus escape: %s(RjRRiRTRkR2RpR>RlRmRnRRRtGROUPREFRoR(RqRrtstateR8RWtgroup((s!/usr/lib64/python2.7/sre_parse.pyt_escapesH  $  $      ic Csg}|j}|j}xX|t|||dr@qn|sJPn|j sc|ddrgPqtdqt|dkr|dSt|}|j}xwd}xj|D]=} | sPn|dkr| d}q| d|krPqqWx|D] } | d=qW||qPqxz|D]0} t| dksO| ddtkr#Pq#q#Wg} | j} x|D]} | | dqmW|t | f|S|jt d|ff|S(Nt|t)ispattern not properly closedi( RRZt_parseRTRR2R!RR>R=RC( RqRutnestedtitemst itemsappendt sourcematcht subpatterntsubpatternappendtprefixtitemtsett setappend((s!/usr/lib64/python2.7/sre_parse.pyt _parse_sub.sR             &  cCst||}|jdrKt||}|jdrQtdqQnd}|jry|jdd rytdnt|}|jt|||ff|S(NRxs/conditional backref with more than two branchesRyispattern not properly closed(RzRZRRRTR!RtGROUPREF_EXISTS(RqRut condgrouptitem_yestitem_noR((s!/usr/lib64/python2.7/sre_parse.pyt_parse_sub_condis  s|)s=! d }d}d}|d rZ d}|dr |drd}x>|}|dkrtdn|dkrPn||}qd }|std nt"|std!|qqW |d"rd}x>|}|dkrItdn|d#krYPn||}q(|s{td nt"|std$|n|j#j|}|dkrtd%n|t$|fqHqW |}|dkrtd&ntd'|qZ |d(r d }qZ |dryx,|j dksM|j d#krQPn|q/|d#sHtd)qHqHqZ |j |kr8 |}d }|dkr|j | krtd*nd}|}nt%||}|d#std)n|d"kr |t&||ffqH|t'||ffqHqZ |dr d}x>|}|dkrn tdn|d#kr~ Pn||}qM d }|s td nt"|r |j#j|}|dkr td%q qW yt|}WqW t(k r td+qW XqZ |j t)kr* td&nx-|j t)krV |j t)|B|_ q- Wn|r |d kru d}n|j*|}|r t+|||}nt%||}|d#s td)n|dk r |j,|n|t-||ffq x|}|dkr td&n|d#kr/ Pntd,q qH| dkr] |tt.fqH| d-kr |jtt/fqH| r | ddkr t0|| |}||qHtd.qH|S(1Nt#s it[t^t]s\s$unexpected end of regular expressiont-isbad character rangeit?Rt+t{t}tt,s"the repetition number is too largesbad repeat intervals not supportedisnothing to repeatsmultiple repeatt.t(tPtsmissing group namesbad character in group name %rt=Rys&bad character in backref group name %rsunknown group namesunexpected end of patternsunknown specifier: ?P%st:sunbalanced parenthesiss syntax errorsbad character in group namesunknown extensiont$s parser error(Ns (ii(1R!RRRZR2t_PATTERNENDERSt _ASSERTCHARSt_LOOKBEHINDASSERTCHARSt _REPEATCODESRTRR tSRE_FLAG_VERBOSEt WHITESPACEt SPECIAL_CHARSR>RotNEGATERsRR=R<R?t REPEAT_CHARSRR\RnR]Rlt OverflowErrortATRARBR;RhRRtRtASSERTt ASSERT_NOTRptFLAGSRRRRHt AT_BEGINNINGtAT_ENDRw( RqRuRRt sourcegetR~t_lent PATTERNENDERSt ASSERTCHARStLOOKBEHINDASSERTCHARSRMR[RRtstarttcode1tcode2RJRKRERFthereRRvRRRVRtdirtptcondnameR8((s!/usr/lib64/python2.7/sre_parse.pyRz|s                             &:                 -                                                               icCst|}|dkr$t}n||_||_t||d}|j}|dkrltdn|r~tdn|t@r|j n|t @ r|j jt @rt ||j jS|S(NiRysunbalanced parenthesiss-bogus characters at end of regular expression( RQRR R tstrRRRtSRE_FLAG_DEBUGR)RR"tparse(RR R"RqRttail((s!/usr/lib64/python2.7/sre_parse.pyRs            cCst|}|j}g}|j}||d}|d }t|tdkr^t}nt}x|} | dkrPn| r| ddkr| dd!} | dkrd} |jdrxA|} | dkrtd n| d krPn| | } qn| std ny(t | } | dkrAtd nWnWt k rt | sjtd ny|j | } Wqt k rtdqXnX|t| fq| dkr|jtkr| |} |jtkr| |} qn||t | ddd@q| tkrt}|jtkr| |} | tkr| dtkr|jtkr| |} t}||t | ddd@qn|s |tt | dfq qy|t| d} Wnt k rnX|| qg|| qgd}g}|j}dgt|}xG|D]?\} }| tkrv|||fn |||<|d}qKW||fS(NcSsM|r9|ddtkr9t|dd|f|d(tliteralRtpappend((s!/usr/lib64/python2.7/sre_parse.pyRsiRs\iitgRsunterminated group nameRsmissing group namesnegative group numbersbad character in group namesunknown group nameRcii(RQRRR(tchrtunichrRRZRRlRpRht groupindextKeyErrorRUtMARKRTRmRnRfRgRiR2(RqR"RtsgetRR0RtseptmakecharR[RWRRVR4tisoctalRRt groupsappendtliterals((s!/usr/lib64/python2.7/sre_parse.pytparse_templates                      $   '       c Cs|j}|jd }|\}}|}yGx@|D]8\}}||||<}|dkr3tdq3q3WWntk rtdnX|j|S(Nisunmatched groupsinvalid group reference(RvRRRRRUtjoin( ttemplateRZRRRRR4RvR((s!/usr/lib64/python2.7/sre_parse.pytexpand_templates      (:t__doc__tsyst sre_constantst_sreRRRRRnRmRkRR>RoRiRtAT_BEGINNING_STRINGt AT_BOUNDARYtAT_NON_BOUNDARYR=R@tCATEGORY_DIGITtCATEGORY_NOT_DIGITtCATEGORY_SPACEtCATEGORY_NOT_SPACEt CATEGORY_WORDtCATEGORY_NOT_WORDt AT_END_STRINGRjtSRE_FLAG_IGNORECASEtSRE_FLAG_LOCALEtSRE_FLAG_MULTILINEtSRE_FLAG_DOTALLRtSRE_FLAG_TEMPLATEtSRE_FLAG_UNICODERR R!RQRbReRhRsRwRRRRRRARBRRzRRRR(((s!/usr/lib64/python2.7/sre_parse.pyt sp          Y!   , ;     ) W