^Rc@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/lib/python2.7/sre_parse.pyt__init__Ds   cCs|j}|d|_|dk rr|jj|d}|dk rbtdt|||fn||j|RMt OCTDIGITStDIGITStordt ValueError(tsourcetescapeR8R[((s/usr/lib/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 iiiRgiscannot refer to open groupsbogus escape: %s(RnRRmRXRoR2RsR>RMRpRqRRRtGROUPREFRrR(RtRutstateR8R[tgroup((s/usr/lib/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( RR^t_parseRXRR2R!RR>R=RC( RtRxtnestedtitemst itemsappendt sourcematcht subpatterntsubpatternappendtprefixtitemtsett setappend((s/usr/lib/python2.7/sre_parse.pyt _parse_sub.sR             &  cCst||}|jdrKt||}|jdrQtdqQnd}|jry|jdd rytdnt|}|jt|||ff|S(NR{s/conditional backref with more than two branchesR|ispattern not properly closed(R}R^RRRXR!RtGROUPREF_EXISTS(RtRxt condgrouptitem_yestitem_noR((s/usr/lib/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=R|s&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!RRR^R2t_PATTERNENDERSt _ASSERTCHARSt_LOOKBEHINDASSERTCHARSt _REPEATCODESRXRR tSRE_FLAG_VERBOSEt WHITESPACEt SPECIAL_CHARSR>RrtNEGATERvRR=R<R?t REPEAT_CHARSRR`RqRaRMt OverflowErrortATRARBR;RlRRwRtASSERTt ASSERT_NOTRstFLAGSRRRRJt AT_BEGINNINGtAT_ENDRz( RtRxRRt sourcegetRt_lent PATTERNENDERSt ASSERTCHARStLOOKBEHINDASSERTCHARSRQR_RRtstarttcode1tcode2RNRORGRHthereRRyRRRZRtdirtptcondnameR8((s/usr/lib/python2.7/sre_parse.pyR}|s                             &:                 -                                                               icCst|}|dkr$t}n||_||_t||d}|j}|dkrltdn|r~tdn|t@r|j n|t @ r|j jt @rt ||j jS|S(NiR|sunbalanced parenthesiss-bogus characters at end of regular expression( RURR R tstrRRRtSRE_FLAG_DEBUGR)RR"tparse(RR R"RtRttail((s/usr/lib/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/lib/python2.7/sre_parse.pyRsiRs\iitgRsunterminated group nameRsmissing group namesnegative group numbersbad character in group namesunknown group nameRgii(RURRR(tchrtunichrRR^RRMRsRlt groupindextKeyErrorRYtMARKRXRpRqRjRkRmR2(RtR"RtsgetRR0RtseptmakecharR_R[RRZR4tisoctalRRt groupsappendtliterals((s/usr/lib/python2.7/sre_parse.pytparse_templates                      $   '       c Cs|j}|jd }|\}}|}yGx@|D]8\}}||||<}|dkr3tdq3q3WWntk rtdnX|j|S(Nisunmatched groupsinvalid group reference(RyRVRRRYtjoin( ttemplateR^RRRRR4RyR((s/usr/lib/python2.7/sre_parse.pytexpand_templates      (:t__doc__RDt sre_constantst_sreRRRRRqRpRoRR>RrRmRtAT_BEGINNING_STRINGt AT_BOUNDARYtAT_NON_BOUNDARYR=R@tCATEGORY_DIGITtCATEGORY_NOT_DIGITtCATEGORY_SPACEtCATEGORY_NOT_SPACEt CATEGORY_WORDtCATEGORY_NOT_WORDt AT_END_STRINGRntSRE_FLAG_IGNORECASEtSRE_FLAG_LOCALEtSRE_FLAG_MULTILINEtSRE_FLAG_DOTALLRtSRE_FLAG_TEMPLATEtSRE_FLAG_UNICODERR R!RURfRiRlRvRzRRRRRRARBRR}RRRR(((s/usr/lib/python2.7/sre_parse.pyt sp          Y!   , ;     ) W