ha-Kc@s~dZdZddd!ZddkZddkZddkZddkZddkZddkZddk Z ddk Z ddk l Z ddklZdd klZlZdd klZeid Zeid Zd ZdefdYZdfdYZde idZdeZdZ de!fdYZ"dZ#dZ$e%djoe"i&ndS(sCheetah command-line interface. 2002-09-03 MSO: Total rewrite. 2002-09-04 MSO: Bugfix, compile command was using wrong output ext. 2002-11-08 MSO: Another rewrite. Meta-Data ================================================================================ Author: Tavis Rudd and Mike Orr > Version: $Revision: 1.26 $ Start Date: 2001/03/30 Last Revision Date: $Date: 2007/10/02 01:22:04 $ sETavis Rudd and Mike Orr s$Revision: 1.26 $i iiN(t OptionParser(tVersion(tTemplatetDEFAULT_COMPILER_SETTINGS(tmkdirsWithPyInitFiless^-{1,2}s^[a-zA-Z_][a-zA-Z_0-9]*$cGsU|ddjo|d }n |d7}|o||}n|}|i|dS(Nit^s (twrite(tstreamtformattargstmessage((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pytfprintfMessages tErrorcBseZRS((t__name__t __module__(((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyR (stBundlecBs eZdZdZdZRS(sxWrap the source, destination and backup paths in one neat little class. Used by CheetahWrapper.getBundles(). cKs|ii|dS(N(t__dict__tupdate(tselftkw((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyt__init__0scCs d|iS(Ns (R(R((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyt__repr__3s(R Rt__doc__RR(((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyR,s tcCs`|it|i|d}|o(|id|id|d}nti|dS(sGWrite help text, an optional error message, and abort the program. is s*** USAGE ERROR ***: %s iN(Rt WRAPPER_TOPtsystexit(t usageMessaget errorMessagetoutt exitStatus((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pytusage:s    s7 __ ____________ __ \ \/ \/ / \/ * * \/ CHEETAH %(Version)s Command-Line Tool \ | / \ ==----== / by Tavis Rudd \__________/ and Mike Orr sUSAGE: ------ cheetah compile [options] [FILES ...] : Compile template definitions cheetah fill [options] [FILES ...] : Fill template definitions cheetah help : Print this help message cheetah options : Print options help message cheetah test [options] : Run Cheetah's regression tests : (same as for unittest) cheetah version : Print Cheetah version number You may abbreviate the command to the first letter; e.g., 'h' == 'help'. If FILES is a single "-", read standard input and write standard output. Run "cheetah options" for the list of valid options. tCheetahWrappercBseZeZdZdZdZdZddZ dZ dZ dZ dZ dZdZd Zd Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZRS(s.bakcCsCd|_d|_d|_d|_g|_g|_d|_dS(N(tNonetprogNametcommandtoptstpathArgst sourceFilest searchListtparser(R((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyRks      c CsC|djo ti}nymtii|d|_}tid|d|_ }|djo|d|_ n|i |dWn t j ot tdnX|i|i|i|i|i|if}xW|D]O}|i}|d}|||fjo#tidcd|7<|dSqWt td |dS( sThe main program controller.iRittestis!not enough command-line argumentst Nsunknown command '%s'(R!RtargvtostpathtbasenameR"toptionDashesREtsubR#ttestOptst parseOptst IndexErrorRt HELP_PAGE1tcompiletfillthelptoptionsR)tversionR (RR+R"R#tmethstmethtmethNamet methInitial((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pytmainws*      cCs|i|i|i}}}|iddj|_}|odpd}t|_|ii}|ddddd d d d d |dddddd d d d|dddddd dd d|dddddd |d d|dddddd td d|ddddddd td d|d dd!dd"d t d d#|d$dddd%d td d&|d'dddd(d td d)|d*dddd+d d d d,|d-dddd.d td d/|d0dddd1d td d2|d3dddd4d dd d5|d6dddd7d d8|d9dddd:d dd d;|d<ddd=d>dd?d d@d dA|dBddCd dDd dE|ii |\}} ||_ t idFjoUg} xB| D]:} ti| } | o| i| q| i| qW| } n| |_|dG|tit|| |io^dOGHdHGHdIdJkl} | }|idKdLx|D]}dM|GHqWt idng}titigD]}|o ||qq~}xtd dgD]f}x]|D]U}t||d}|o6|i|o&|t | }t!|||Pq q WqW|i"|i#o|i$i%dti&n|i'oBt(|i'dN}t'i)|}|i*|i$i%d|ndS(PNitcs.pys.htmls--idirtactiontstoretdesttidirtdefaultRR7s/Input directory (defaults to current directory)s--odirtodirs0Output directory (defaults to current directory)s--iexttiexts.tmpls<File input extension (defaults: compile: .tmpl, fill: .tmpl)s--oexttoexts;File output extension (defaults: compile: .py, fill: .html)s-Rt store_truetrecurses6Recurse through subdirectories looking for input filess--stdouts-ptstdouts2Send output to stdout instead of writing to a files--quiett store_falsetverboses-Do not print informational messages to stdouts--debugtdebugs,Print diagnostic/debug information to stderrs--envtenvs)Pass the environment into the search lists--pickletpickles4Unpickle FILE and pass it through in the search lists--flattflats'Do not build destination subdirectoriess --nobackuptnobackups1Do not make backup files when generating new oness --settingstcompilerSettingsStringscString of compiler settings to pass through, e.g. --settings="useNameMapper=False,useFilters=False"s--print-settingstprint_settingss1Print out the list of available compiler settingss--templateAPIClassttemplateClassNames\Name of a subclass of Cheetah.Template.Template to use for compilation, e.g. MyTemplateClasss --parallelttypetinttparallelis5Compile/fill templates in parallel, e.g. --parallel=4s--shbangtshbangs#!/usr/bin/env pythonsbSpecify the shbang to place at the top of compiled templates, e.g. --shbang="#!/usr/bin/python2.6"twin32s.cheetah compile %s Options are %s Files are %ss'>> Available Cheetah compiler settings:i(t_DEFAULT_COMPILER_SETTINGStkeycSs|ddiS(i(tlower(tl((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pytss %s (default: "%s") %strb((+tchatterRMtwarnR#t isCompileRR(t add_optiontFalsetTrueR!t parse_argsR$RtplatformtglobtextendtappendR%tpprinttpformattvarsRStCheetah.CompilerRZtsortRR,tseptaltseptgetattrtendswithtlentsetattrt_fixExtsRNR'tinserttenvironROtopentloadtclose(RR tCtDtWRbt defaultOexttpaoR$tfilest new_filestspect file_listRZtlistingR]t_[1]RptsepstattrR-tft unpickled((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyR2s  """""%""""""""(     8      cCs|idS(N(t_compileOrFill(R((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyR5scCs%ddkl}||idS(Ni(tinstall(tCheetah.ImportHooksRR(RR((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyR6scCsttdtidS(NR(RR4RRJ(R((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyR7scCs |iiS(N(R(t print_help(R((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyR8scCsd}yt|d}WntidnX|iti|ddkl}ddk}d}d|i jo d}nd |i jo d }n|i d |}|i |i |i dS( Ns&cheetah_test_file_creation_ability.tmptwsCannot run the tests because you don't have write permission in the current directory. The tests need to create temporary files. Change to a directory you do have write permission to and re-run the tests.i(tTestis-qis-vit verbosity(RyRRR{R,tremovet Cheetah.TestsRtunittestR1tTextTestRunnertrunt TestSuitetsuites(RtTEST_WRITE_FILENAMERRRRtrunner((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyR)s"      cCs tGHdS(N(R(R((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyR9 scGs7|iip|ii odStti||dS(stPrint a verbose message to stdout. But don't if .opts.stdout is true or .opts.verbose is false. N(R$RJRLR R(RRR ((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyR`scGs(|iiotti||ndS(sVPrint a debugging message to stderr, but don't if .debug is false. N(R$RMR Rtstderr(RRR ((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyRMs cGstti||dS(s2Always print a warning message to stderr. N(R RR(RRR ((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyRa$scGs$tti||tiddS(sVAlways print a warning message to stderr and exit with an error code. iN(R RRR(RRR ((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyterror)scCsu|ii|ii}}|o%|id od||i_n|o%|id od||i_ndS(Nt.(R$RFRGt startswith(RRFRG((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyRv3s cs|i|i|i}}}|i|i}}|dgjo|idS| oo|ioe|iodpd}|d|g}ti i |iiti }ti i ||i |n1|pttdn|i||it}g} |D]} | ti i| q~ }|d||i|} |dti| |iio|i| n|iidjod } tfd } x| o| i}ti}|oi|n|i|tid t |iijo| } | oPq*qqWx&o| }| p |} q2q2W| otid | qnx| D]}|i|qWdS( Nt-RCtcurrents,Drilling down recursively from %s directory.sNeither files nor -R specified!sAll source files found: %ssAll bundles: %siics,ti\}}i|ti|S(N(R,twaitRt WEXITSTATUS(tpidtstatus(tpid_pool(s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyt child_wait_s s)Child process failed, exited with code %d(!R`RMRaR$R%t_compileOrFillStdinRIRCR,R-tjointcurdirtwalkt_expandSourceFilesWalkRR4t_expandSourceFilesRetnormpatht _getBundlesRkRlRPt_checkForCollisionsRWtsettpoptforktaddt_compileOrFillBundleRRRt(RR|R}R~R$RtwhichR&tdirRtxtbundlestbad_child_exitRtbRt child_exit((Rs</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyR=s\  -          c Cs|i|i|i}}}t}h}xL|D]D}|i|jo||ii|iq0|ig||i %s^s (backup %s)Rsn%s: base name %s contains invalid characters. It must be named according to the same rules as Python modules.RRt moduleNamet classNametcommandlineoptsRR'R("R`RMRaRRRRRR.R,R-RRbRR$RQRR!t moduleNameREtmatchR R5RdRR'tshutiltcopyfileRtmakedirsRJRRRyR{(RRR|R}R~RRRRRR.tdstDirRRttupRRttclassR((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyR9sN      !          N(R RRet MAKE_BACKUPSRR!RRRR>R2R5R6R7R8R)R9R`RMRaRRvRRRRRRRRR(((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyR es6 " M         A   ! * "  cCstidS(N(R R>(((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyt_cheetahkscCs$tiiddtidS(NiR5(RR+RwR R>(((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyt_cheetah_compileost__main__('Rt __author__t __revision__tgetoptRhR,RktreRRtcPickleROtoptparseRtCheetah.VersionRtCheetah.TemplateRRtCheetah.Utils.MiscRR5R/RR t ExceptionR RRRtglobalsRR4tobjectR RRR R>(((s</usr/lib64/python2.6/site-packages/Cheetah/CheetahWrapper.pyts. T