mò %U²Ic@sÿdZdkZeiddeeddƒdkZdkTddgZhd d <d d <d d <dd<dd<dd<dd<dd<dd<dd<dd<dd<dd \b (not quite the same, but alla...) \` \A \' \Z Not translated... . ^ $ * + (unless RE_BK_PLUS_QM set, then to \+) ? (unless RE_BK_PLUS_QM set, then to \?) \ \b \B \w \W \1 ... \9 Special cases... Non-printable characters are always replaced by their 3-digit escape code (except \t, \n, \r, which use mnemonic escapes) Newline is turned into | when RE_NEWLINE_OR is set XXX To be done... [...] (different treatment of backslashed items?) [^...] (different treatment of backslashed items?) ^ $ * + ? (in some error contexts these are probably treated differently) \vDD \DD (in the regex docs but only works when RE_ANSI_HEX set) Ntignores .* regex .*tappendi(t*tconverttquotes\s\`s\As\'s\Zs\(t(s\)t)s\|t|s s\ts s\ns s\rcCsmtiƒ}|djotiƒ}n|t@o |d=|d=|d=|d=n|t@o|d=|d=n|t @o,d|d||}|d}d|}|i||ƒ}||}qÜ|i||ƒ}||}qÜW|S(sNConvert a regex regular expression to re syntax. The first argument is the regular expression, as a string object, just like it would be passed to regex.compile(). (I.e., pass the actual string object -- string quotes must already have been removed and the standard escape processing has already been done, e.g. by eval().) The optional second argument is the regex syntax variant to be used. This is an integer mask as passed to regex.set_syntax(); the flag bits are defined in regex_syntax. When not specified, or when None is given, the current regex syntax mask (as retrieved by regex.get_syntax()) is used -- which is 0 by default. The return value is a regular expression, as a string object that could be passed to re.compile(). (I.e., no string quotes have been added -- use quote() below, or repr().) The conversion is not always guaranteed to be correct. More syntactical analysis should be performed to detect borderline cases and decide what to do with them. For example, 'x*?' is not translated correctly. s\(s\)RRs\|Rs\+t+s\?t?s tiis\N(t mastertabletcopyttabletsyntaxtNonetregext get_syntaxtRE_NO_BK_PARENSt RE_NO_BK_VBARt RE_BK_PLUS_QMt RE_NEWLINE_ORtrestitlentstendtctkeytget(RRRRRRRR ((t&/data/zmath/lib/python2.4/reconvert.pyRZsB                  cCsÚ|djo4d}d}||jo||jo |}qGn|}|}xa|D]Y}||jod|}n/|djp |djodt|ƒ}n||}qTW||}d|jod|}n|S(sConvert a string object to a quoted string literal. This is similar to repr() but will return a "raw" string (r'...' or r"...") when the string contains backslashes, instead of doubling all backslashes. The resulting string does *not* always evaluate to the same string as the original; however it will do just the right thing when passed into re.compile(). The optional second argument forces the string quote; it must be a single character which is a valid Python string quote. t's\t t~s\%03otrN(RRtqtaltqRRRtord(RRRR#RR$((RR–s(     cCsbdk}t|iiƒƒ}|iitt|ƒƒƒ|ii ƒo|iidƒndS(s,Main program -- called when run as a script.Ns ( tsystevaltstdintreadRtstdouttwriteRRtisatty(R&R((Rtmain¶s  t__main__( t__doc__twarningstfilterwarningstDeprecationWarningt__name__Rt regex_syntaxt__all__R RRRR-(RRR5R0RR R-((RR <s    { <