Ñò ha-Kc @sÔddklZddkZddklZddkZddkZddklZeidƒd„Zd„Z d„Z d „Z d dd „ƒYZ d dd „ƒYZ ddd„ƒYZddd„ƒYZdS(iÿÿÿÿ(tglobN(tlistdir(tmktemps ([\$\^\*\+\.\?\{\}\[\]\(\)\|\\])cCs|id|ƒS(Ns\\\1(tsub(ttxttescapeRE((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyt_escapeRegexChars scOst||ŽiƒS(sºRecursively find all the files matching a glob pattern. This function is a wrapper around the FileFinder class. See its docstring for details about the accepted arguments, etc.(t FileFindertfiles(targstkw((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyt findFiles scCs"t|ƒ}t|||ƒiƒS(s/Replace all instances of 'theStr' with 'repl' for each file in the 'files' list. Returns a dictionary with data about the matches found. This is like string.replace() on a multi-file basis. This function is a wrapper around the FindAndReplace class. See its docstring for more details.(RtFindAndReplacetresults(RttheStrtrepltpattern((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pytreplaceStrInFiless cCst|||ƒiƒS(s,Replace all instances of regex 'pattern' with 'repl' for each file in the 'files' list. Returns a dictionary with data about the matches found. This is like re.sub on a multi-file basis. This function is a wrapper around the FindAndReplace class. See its docstring for more details.(R R (RRR((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pytreplaceRegexInFiles"s RcBsbeZdZd d d d„Zdeieiieiid„Z d„Z e d„Z d „Z RS( sgTraverses a directory tree and finds all files in it that match one of the specified glob patterns.t*tCVSs.svncCs>||_||_||_||_g|_|i|ƒdS(N(t _rootPatht _globPatternst_ignoreBasenamest _ignoreDirst_filest walkDirTree(tselftrootPatht globPatternstignoreBasenamest ignoreDirs((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyt__init__7s      t.c Cs¨|i}|i}|g}|i}|i} xt|ol| ƒ}||ƒxR||ƒD]D} ||| ƒ} || ƒo"|| | ƒo|| ƒq›qWqWWq0WdS(sBRecursively walk through a directory tree and find matching files.N(t processDirt filterDirtappendtpop( RtdirRtisdirtjoinR"R#t pendingDirstaddDirtgetDirtbaseNametfullPath((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyREs         cCs||ijp ||ij S(s'A hook for filtering out certain dirs. (RR(RR,R-((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyR#`scCsC|ii}x0|iD]%}||tii||ƒƒƒqWdS(N(RtextendRtostpathR((RR&RR.R((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyR"gs  cCs|iS(N(R(R((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyRls(R(Rs.svn((t__name__t __module__t__doc__R R/RR0R'R(RR#RR"R(((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyR2s    t_GenSubberFunccBsÝeZdZeidƒZeidƒZd„Zd„Zd„Z d„Z d„Z dd „Z dd „Zd „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(s³Converts a 'sub' string in the form that one feeds to re.sub (backrefs, groups, etc.) into a function that can be used to do the substitutions in the FindAndReplace class.s\\([1-9][0-9]*)s\\g<([a-zA-Z_][a-zA-Z_]*)>cCs)||_d|_g|_|iƒdS(Ni(t_srct_post _codeChunkstparse(Rt replaceStr((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyR xs   cCs|iS(N(R5(R((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pytsrc~scCs|iS(N(R6(R((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pytposscCs ||_dS(N(R6(RR;((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pytsetPos„scCs|it|iƒjS(N(R6tlenR5(R((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pytatEnd‡sicCs|i|7_dS(N(R6(Rtoffset((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pytadvanceŠscCsN|djo |i}n||_|iƒo |i|S|i||!SdS(N(tNoneR6R>R5(Rttotstart((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pytreadTos      cCs|ii|iƒ|iƒƒS(N(t backrefREtmatchR:R;(R((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyt matchBackref˜scCs,|iƒ}|i|iƒƒ|idƒS(Ni(RGR<tendtgroup(Rtm((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyt getBackref›s cCs|ii|iƒ|iƒƒS(N(tgroupRERFR:R;(R((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyt matchGroup scCs,|iƒ}|i|iƒƒ|idƒS(Ni(RMR<RHRI(RRJ((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pytgetGroup£s cCsYxR|iƒpD|iƒo|iƒq|iƒo|iƒq|iƒqWdS(N(R>RGt eatBackrefRMteatGroupt eatStrConst(R((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyR8ªs   cCs||iƒ}x;|iƒp-|iƒp |iƒoPq|iƒqW|i|iƒd|ƒ}|it|ƒƒdS(NRC(R;R>RGRMR@RDtaddChunktrepr(RtstartPoststrConst((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyRQ³s  cCs|id|iƒdƒdS(Nsm.group(t)(RRRK(R((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyRO½scCs|id|iƒdƒdS(Ns m.group("s")(RRRN(R((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyRPÀscCs|ii|ƒdS(N(R7R$(Rtchunk((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyRRÃscCsdi|iƒS(Ns, (R(R7(R((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pytcodeBodyÈscCsd|iƒS(Ns%def subber(m): return ''.join([%s]) (RX(R((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pytcodeËscBs|iƒdUeS(N(RYtsubber(R((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyt subberFuncÎsN(R1R2R3tretcompileRERLR R:R;R<R>R@RARDRGRKRMRNR8RQRORPRRRXRYR[(((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyR4os,               R cBs5eZdZed„Zd„Zd„Zd„ZRS(s`Find and replace all instances of 'patternOrRE' with 'replacement' for each file in the 'files' list. This is a multi-file version of re.sub(). 'patternOrRE' can be a raw regex pattern or a regex object as generated by the re module. 'replacement' can be any string that would work with patternOrRE.sub(replacement, fileContents). cCs,t|tƒoti|ƒ|_n ||_t|tƒot|ƒiƒ|_n ||_|ii|_ }||_ h|_ ||_ t |_tidƒdiƒidƒoctƒ}t|dƒidƒtid|d|ƒdiƒp t|_nti|ƒn|iƒdS(NtpgrepisUsage:twt#spgrep "s" (t isinstancet basestringR\R]t_regexR4R[t_subberRt_patternRt_resultst_recordResultstFalset _usePgrepR/tpopen3treadt startswithRtopentwritetTruetremovet_run(RRt patternOrREt replacementt recordResultsRttmpFile((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyR Ýs$      # & cCs|iS(N(Rf(R((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyR üsc Cs;|i}|i}|i}|i}x|iD]}tii|ƒpq.n||_t }dt ƒjo~n|io0ti d|d|ƒi ƒo t }qÚn-t|ƒi ƒ}|i|ƒo t }n|oRdt ƒjot|ƒi ƒ}n|i||ƒ}t|dƒi|ƒq.q.WdS(Ntorigspgrep "s" R_(Rct_subDispatcherRiReRR/R0tisfilet _currFileRhtlocalstpopenRkRoRmtsearchRRn( RtregexRZtusePgrepRtfiletfoundRvtnew((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyRqÿs.       " cCs²|io›|i|ijo,h}|i|i}||d7}||d7}||d7}||d7}q+Wh|d6|d6|d6|d6}|S(Nit codeLinest blankLinest commentLinest totalLines(RŠtvalues(RR‹RŒRRŽt fileStatsR‰((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pytsummary9s  cCsdS(N((R((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyt printStatsKsc CsÑd}d}d}tidƒ}tidƒ}t|ƒiƒiƒ}t|ƒ}xT|D]L} |i| ƒo|d7}q[|i| ƒo|d7}q[|d7}q[Wh|d6|d6|d6|d6} | S( Nis\s#.*$s\s$iR‹RŒRRŽ(R\R]RmRkt splitlinesR=RF( RtfileNameR‹RŒRt commentLineRet blankLineRetlinesRŽtlineR‰((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyRˆNs&   N( R1R2R3RAR‡R RŠR‘R’Rˆ(((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyR†*s    (((((RR/Rtos.pathR\ttempfileRR]RR RRRR4R R†(((s7/usr/lib64/python2.6/site-packages/Cheetah/FileUtils.pyts     =dW