9oLc@sdZddkZddkZddkZddklZddkZddkZddkZddk Z ddk Z ddk l Z ddk l ZddklZddklZddklZlZd efd YZeid eid ZZeefZd ZdddYZddZhdd6d d6dd6dddgd6hdd6dd6hdd 6dd6d6ed 6d!6ed"6ed#6eid$6d%d&6dd'6d(d)6d d*6d+d,6d d-6d.d/6d0d16d2d36d4d56d6d76d8d96d:d;6d<d=6d>d>d>gd?6hd d@6d d*6d+d,6hd d@6d d*6d+d,6gdA6ddgdF6dGdHdIgdJ6dKdL6dMdN6Z!dOe i"fdPYZ#dQe#fdRYZ$dSe#fdTYZ%dUe#fdVYZ&dWe#fdXYZ'dYe#fdZYZ(d[e#fd\YZ)d]e#fd^YZ*d_e#fd`YZ+dae#fdbYZ,dce#fddYZ-dee#fdfYZ.dge#fdhYZ/die#fdjYZ0dke#fdlYZ1dme#fdnYZ2doe#fdpYZ3dqe#fdrYZ4dse#fdtYZ5due#fdvYZ6dwe#fdxYZ7dye#fdzYZ8edyp[8nd{e#fd|YZ9d}e#fd~YZ:de#fdYZ;de#fdYZ<de#fdYZ=edjo[=nde#fdYZ>edjo e>`?nde#fdYZ@de#fdYZAde#fdYZBde#fdYZCedjo[Cnde#fdYZDde#fdYZEde#fdYZFde#fdYZGde#fdYZHde#fdYZIde#fdYZJde#fdYZKde#fdYZLde#fdYZMde#fdYZNde#fdYZOde#fdYZPde#fdYZQde#fdYZRde#fdYZSde#fdYZTeiUiVdo [S[Tnde#fdYZWde#fdYZXde#fdYZYde#fdYZZde#fdYZ[de#fdYZFde#fdYZ\de#fdYZ]de#fdYZ^de#fdYZ_de#fdYZ`de#fdYZade#fdYZbde#fdYZce#idoedjoheed6Zfnhed6ZfdZgehdjoege iindS(sW Syntax and Output tests. TODO - #finally - #filter - #errorCatcher - #echo - #silent iN(tdeepcopy(tNotFound(t C_VERSION(tTemplate(t ParseError(tCompilertDEFAULT_COMPILER_SETTINGSt UnspecifiedcBseZRS((t__name__t __module__(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR"siicCs|S(N((tfunc((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyt testdecorator(st DummyClasscBsVeZeZdZddZddZdddZdd Zd d Z RS( cCsdS(Ntobject((tself((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyt__str__-starffcCs t|S(N(tstr(Rtarg((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pytmeth0stdoocCs|S(N((RR((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pytmeth13sta1ta2cCst|t|S(N(R(Rtarg1targ2((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pytmeth26ss110%cCs t|S(N(R(RR((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pytmethWithPercentSignDefaultArg9sicCst|_||_dS(N(tTruet_calledt_callArg(RR((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pytcallIt<s ( RR tFalseRRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR +s    tScoobycCs|S(N((R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyt dummyFuncAstblargtaStrtanIntg?taFloattitem0titem1titem2taListtonettwot nestedItem1t nestedItem2t nestedDictt nestedFunctaDicttaFunctanObjtaMeths $aStr $anInttaStrToBeIncludedtnonett emptyStringtnumOneitnumTwotzeroiIt tenDigitss abc <=> &t webSafeTests# strippable whitespace tstrip1s" strippable whitespace tstrip2s( strippable whitespace 1 2 3 tstrip3s$numOne $numTwotblockToBeParseds$numOne $numTwo $aSetVart includeBlock2s parseTest.txttincludeFileNamecCs|S(((tx((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pytcst listOfLambdastindextlisttjohntdoetjanetsmithtnameListtatbtct letterListcCsd|S(s Translated: ((RD((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyREjst_u aoeu12345ሴt unicodeDatat OutputTestcBszeZdZeZdZeZdZ e gZ eZ dZ dZddedZdZdZdZdZRS( s Template output mismatch: Input Template = %(template)s%(end)s Expected Output = %(expected)s%(end)s Actual Output = %(actual)s%(end)sicCs|iS(N(t _searchList(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyt searchListsc CsO|ioS|tjo |i}n|o.|id|i}|id|i}q]n||_|iop|iph}tid|d|i dt |}|i }|i p|i } |d| |_} n5t|d|i d|i |_} | i }|idjo |GHnz| i} Wd| iXdS(Ns tsourcetcompilerSettingstkeepRefToGeneratedCodeRVi(t_EOLreplacementRt convertEOLstreplacet_inputt_useNewStyleCompilationt_extraCompileKwArgsRtcompilet_getCompilerSettingsRt_CHEETAH_generatedModuleCodeRVRUttemplatetDEBUGLEVtrespondtshutdown( RtinputtexpectedOutputt inputEncodingtoutputEncodingR[t extraKwArgst templateClasst moduleCodeRVt templateObjtoutput((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pytverifys8             cCshS(N((R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRascCs|ioh|io^|i}d}|ih|ii||d6|i||d6|i||d6dd6S|ih|id6|d6|d6dd6SdS(Ns*EOL*Rctexpectedtactuals(end)tend(t_debugEOLReplacementRZtreportR]R\(RRoRhtEOLrepltmarker((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyt_outputMismatchReports  cCs"t|do|iiSdS(NRc(thasattrRctgeneratedClassCode(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyt genClassCodescCs"t|do|iiSdS(NRc(RyRctgeneratedModuleCode(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyt genModuleCodesN(RR RuRR[tNoneRZR RtRdtdefaultTestNameSpaceRUR^R_RVRRpRaRxR{R}(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRTrs     $   t EmptyTemplatecBseZeZdZRS(c Cstiddty|iddWntj onX|idy|iddWntj onX|id|idd|iddd S( s an empty string for the templateterrors,You supplied an empty string for the source!R7s'Should warn about empty source strings.s#implements foos7This should barf about respond() not being implemented.s#implements responds#implements respond(foo=1234)N(twarningstfilterwarningst UserWarningRptfailtNotImplementedError(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest1s   (RR R R[R(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRst BackslashescBsheZeZdZdZdZdZdZdZ dZ dZ dZ d Z RS( cCs5tdd}|idd|i|idS(Nsbackslashes.txttws(\ #LogFormat "%h %l %u %t \"%r\" %>s %b"s (topentwritetflushtclose(Rtfp((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pytsetUps cCs(tiidotidndS(Nsbackslashes.txt(tostpathtexiststremove(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttearDownscCs|idddS(s a single \ using rawstringss\ N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s. a single \ using rawstrings and lots of liness\ s Ns \ s \ (Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest2s cCs|idddS(s$ a single \ without using rawstringss\ \ N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest3s cCs|idddS(s% single line from an apache conf files&#LogFormat "%h %l %u %t \"%r\" %>s %b"N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest4s cCs|idddddS(sS single line from an apache conf file with many NEWLINES The NEWLINES are used to make sure that MethodCompiler.commitStrConst() is handling long and short strings in the same fashion. It uses triple-quotes for strings with lots of \n in them and repr(theStr) for shorter strings with only a few newlines.s&#LogFormat "%h %l %u %t \"%r\" %>s %b"s N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest5 s cCs|iddddS(s, test backslash handling in an included files#include "backslashes.txt"s(\ #LogFormat "%h %l %u %t \"%r\" %>s %b"s N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest6s cCs|idddS(s7 a single \ without using rawstrings plus many NEWLINESs\ \ s Ns \ \ s \ \ (Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest7s cCs|idddddS(sT single line from an apache conf file with single quotes and many NEWLINES s&#LogFormat '%h %l %u %t \"%r\" %>s %b's N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest8"s (RR R R[RRRRRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs        t NonTokenscBsGeZdZdZdZdZdZdZdZRS(cCs|idddS(s!dollar signs not in Cheetah $varss$ $$ $5 $. $ testN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR*s cCs|idddS(shash not in #directivess# \# #5 s# # #5 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR/s cCs|idddS(sescapted commentss \##escaped comment s ##escaped comment N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR4s cCs|idddS(sescapted multi-line commentss \#*escaped comment *# s #*escaped comment *# N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR9s cCs|idddS(s 1 dollar signt$N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR>s cCs|idddS(s1 dollar sign followed by hashs $# N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyt_X_test6Bs cCs;tdo|idtddn|idddS(s)1 dollar sign followed by EOL Slurp Tokent EOLSlurpTokens $%s s $s $# N(RRp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRGs    ( RR RRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR)s      tComments_SingleLinecBskeZdZdZdZdZdZdZdZdZ dZ d Z d Z RS( cCs|idddS(s## followed by WSs## R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRQs cCs|idddS(s## followed by NEWLINEs## R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRVs cCs|idddS(s ## followed by text then NEWLINEs## oeuao aoe uaoe R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR[s cCs|idddS(s## gobbles leading WSs ## oeuao aoe uaoe R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR_s cCs|idddS(s.## followed by text then NEWLINE, + leading WSs ## oeuao aoe uaoe R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRds cCs|idddS(s## followed by EOFs##R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRis cCs|idddS(s"## followed by EOF with leading WSs ##R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRns cCs|idddS(s@## gobble line with text on previous and following linessline1 ## aoeu 1234 line2s line1 line2N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRss cCs|idddS(sF## don't gobble line with text on previous and following linessline1 12 ## aoeu 1234 line2sline1 12 line2N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest9ys cCs|idddS(s$## containing $placeholders s ##$a$b $c($d)R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest10s cCs|idddS(s%## containing #for directive s##for $i in range(15)R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest11s ( RR RRRRRRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRPs          tComments_MultiLine_NoGobblecBs;eZdZdZdZdZdZdZRS(s Multiline comments used to not gobble whitespace. They do now, but this can be turned off with a compilerSetting cCs htd6S(Nt'gobbleWhitespaceAroundMultiLineComments(R (R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRascCs|idddS(s9#* *# followed by WS Shouldn't gobble WS s#* blarg *# s N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(sF#* *# preceded and followed by WS Shouldn't gobble WS s #* blarg *# s N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(sG#* *# followed by WS, with NEWLINE Shouldn't gobble WS s#* blarg *# s N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(sT#* *# preceded and followed by WS, with NEWLINE Shouldn't gobble WS s #* blarg *# s N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs (RR t__doc__RaRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs     tComments_MultiLinecBsqeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z RS( s; Note: Multiline comments don't gobble whitespace! cCs|idddS(s6#* *# followed by WS Should gobble WS s#* blarg *# R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(sC#* *# preceded and followed by WS Should gobble WS s #* blarg *# R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(sG#* *# followed by WS, with NEWLINE Shouldn't gobble WS s#* blarg *# R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(sT#* *# preceded and followed by WS, with NEWLINE Shouldn't gobble WS s #* blarg *# R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s"#* *# containing nothing s#**#R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s'#* *# containing only NEWLINES s #* *# R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s'#* *# containing $placeholders s#* $var $var(1234*$c) *#R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s(#* *# containing #for directive s#* #for $i in range(15) *#R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s5 text around #* *# containing #for directive s+foo foo bar #* #for $i in range(15) *# foo sfoo foo bar foo N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(sm text around #* *# containing #for directive and trailing whitespace which should be gobbled s.foo foo bar #* #for $i in range(15) *# testsfoo foo bar testN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(sx text around #* *# containing #for directive and newlines: trailing whitespace which should be gobbled. s2foo foo bar #* #for $i in range(15) *# testsfoo foo bar testN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs ( RR RRRRRRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs          t PlaceholderscBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZRS(cCs|idddS(s 1 placeholders$aStrR#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s2 placeholderss $aStr $anIntsblarg 1N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s2 placeholders, back-to-backs $aStr$anInttblarg1N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s1 placeholder enclosed in ()s$(aStr)R#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR scCs|idddS(s1 placeholder enclosed in {}s${aStr}R#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s1 placeholder enclosed in []s$[aStr]R#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(sg1 placeholder enclosed in () + WS Test to make sure that $(.. matches s $( aStr )R#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s!1 placeholder enclosed in {} + WSs ${ aStr }R#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s!1 placeholder enclosed in [] + WSs $[ aStr ]R#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR"scCs|idddS(sr1 placeholder enclosed in () + WS + * cache Test to make sure that $*(.. matches s $*( aStr )R#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR&scCs|idddS(s*1 placeholder enclosed in {} + WS + *caches $*{ aStr }R#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR-scCs|idddS(s*1 placeholder enclosed in [] + WS + *caches $*[ aStr ]R#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest121scCs|idddS(s01 placeholder enclosed in {} + WS + **caches$*5*{ aStr }R#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest135scCs|idddS(s01 placeholder enclosed in [] + WS + **caches$*5*[ aStr ]R#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest149scCs|idddS(s21 placeholder enclosed in {} + WS + **caches$*0.5d*{ aStr }R#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest15=scCs|idddS(s21 placeholder enclosed in [] + WS + **caches$*.5*[ aStr ]R#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest16AscCs|idddS(s1 placeholder + **caches$*5*aStrR#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest17EscCs|idddS(s1 placeholder **caches $*0.5h*aStrR#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest18IscCs|idddS(s?1 placeholder surrounded by single quotes and multiple newliness' '$aStr' 's' 'blarg' 'N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest19Ms cCsK|iddy|iddWntj onX|iddS(ssilent mode $!placeholders s0$!aStr$!nonExistant$!*nonExistant$!{nonExistant}R#s$!aStr$nonExistantsshould raise NotFound exceptionN(RpRR(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest20Rs  cCsxd}|i}tiddt}|id}|id}|id}td jo|id}ndS( s,Make sure that $*caching is actually workingsYou Me Them Everyones#for name in $names: $name t baseclasss#for name in $names: $*name s#for name in $names: $*1*name s #for name in $names: $*1*(name) iN(ii(tsplitRR`tdicttsubclasst versionTuple(RtnamesStrtnamesttmpl((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest21^s  (RR RRRRRRRRRRRRRRRRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs*                    tPlaceholders_ValscBs_eZeZdZdZdZdZdZdZ dZ dZ dZ RS( cCs|idddS(tstrings$aStrR#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRuscCs|idddS(sstring - with whitespaces $aStr s blarg N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRyscCs|idddS(sempty string - with whitespaces $emptyStringR7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR}scCs|idddS(tints$anIntt1N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(tfloats$aFloats1.5N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(RHs$aLists['item0', 'item1', 'item2']N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s@None The default output filter is ReplaceNone. s$noneR7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs*|iddttttfdS(sTrue, False s $True $Falses%s %sN(RptreprRR (R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s $_ s $_('foo')sTranslated: fooN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs( RR R R[RRRRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRss        tPlaceholderStringscBsGeZdZdZdZdZdZdZdZRS(cCs|idddS(s&some c'text $placeholder text' stringss$str(c'$aStr')R#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s&some c'text $placeholder text' stringss$str(c'$aStr.upper')tBLARGN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s&some c'text $placeholder text' stringss-$str(c'$(aStr.upper.replace(c"A$str()",""))')tBLRGN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s&some c'text $placeholder text' stringss#echo $str(c'$(aStr.upper)')RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s&some c'text $placeholder text' stringss(#if 1 then $str(c'$(aStr.upper)') else 0RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s&some c'text $placeholder text' stringss1#if 1 $str(c'$(aStr.upper)')#slurp #else 0#end ifRN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s&some c'text $placeholder text' stringssK#def foo(arg=c'$("BLARG")') $arg#slurp #end def $foo()$foo(c'$anInt')#slurptBLARG1N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs ( RR RRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs      tUnicodeStringscBseZdZdZRS(cCs|idtddS(s$unicode data in placeholder u $unicodeDataRSN(RpR(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(sunicode data in body u aoeu12345ሴN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs(RR RR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs tEncodingDirectivecBs5eZdZdZdZdZdZRS(cCs|idddS(sbasic #encoding s#encoding utf-8 1234t1234N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(sbasic #encoding s#encoding ascii 1234RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddddS(sbasic #encoding s#encoding utf-8 ሴuሴRjtutf8N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(sbasic #encoding s#encoding latin-1 ሴuሴN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(sbasic #encoding s#encoding latin-1 AndruAndr‚N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs (RR RRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs     tUnicodeDirectivecBseZdZRS(cCs|idd|idd|idd|idd|idd|idd|id d|id dd S( sbasic #unicode s#unicode utf-8 1234u1234s#unicode ascii 1234s#unicode latin-1 1234s#unicode latin-1 1234u1234üs#unicode: latin-1 1234s# unicode : latin-1 1234u#unicode latin-1 1234üs#encoding latin-1 1234N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs         (RR R(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRstPlaceholders_EsccBs;eZeZdZdZdZdZdZRS(cCs|idddS(s1 escaped placeholders\$vars$varN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s2 escaped placeholderss \$var \$_s$var $_N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s%2 escaped placeholders - back to backs\$var\$_s$var$_N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s2 escaped placeholders - nesteds \$var(\$_)s$var($_)N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s,2 escaped placeholders - nested and encloseds \$(var(\$_)s $(var($_)N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs ( RR R R[RRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs     tPlaceholders_CallscBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZRS(cCs|idddS(sfunc placeholder - no ()s$aFuncR!N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(sfunc placeholder - with ()s$aFunc()R!N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR$s cCs|idddtdS(sfunc placeholder - with (\n\n)s $aFunc( )R!R[N(RpR (R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR)s cCs|idddtdS(s0func placeholder - with (\n\n) and $() enclosures $(aFunc( ))R!R[N(RpR (R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR.s cCs|idddtdS(s0func placeholder - with (\n\n) and ${} enclosures ${aFunc( )}R!R[N(RpR (R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR3s cCs|idddS(sfunc placeholder - with (int)s $aFunc(1234)RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR8s cCs|idddtdS(s!func placeholder - with (\nint\n)s$aFunc( 1234 )RR[N(RpR (R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR=s cCs|idddS(s func placeholder - with (string)s$aFunc('aoeu')taoeuN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRAs cCs|idddS(s&func placeholder - with ('''string''')s$aFunc('''aoeu''')RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRFs cCs|idddS(s*func placeholder - with ('''\nstring\n''')s$aFunc(''' aoeu ''')s aoeu N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRJs cCs|idddS(s+func placeholder - with ('''\nstring'\n''')s$aFunc(''' aoeu' ''')s aoeu' N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyROs cCs|idddS(s*func placeholder - with ("""\nstring\n""")s$aFunc(""" aoeu """)s aoeu N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRTs cCs|idddS(s$func placeholder - with (string*int)s$aFunc('aoeu'*2)taoeuaoeuN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRYs cCs|idddS(s!func placeholder - with (int*int)s $aFunc(2*2)t4N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR^s cCs|idddS(s#func placeholder - with (int*float)s $aFunc(2*2.0)s4.0N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRcs cCs|idddtdS(s'func placeholder - with (int\n*\nfloat)s$aFunc(2 * 2.0)s4.0R[N(RpR (R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRhs cCs|idddS(s$func placeholder - with ($arg=float)s$aFunc($arg=4.0)s4.0N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRms cCs|idddS(s#func placeholder - with (arg=float)s$aFunc(arg=4.0)s4.0N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRrs cCs|idddS(s%deeply nested argstring, no enclosures#$aFunc($arg=$aMeth($arg=$aFunc(1)))RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRws cCs|idddS(s/deeply nested argstring, no enclosure + with WSs.$aFunc( $arg = $aMeth( $arg = $aFunc( 1 ) ) )RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR|s cCs|idddS(s/deeply nested argstring, () enclosure + with WSs1$(aFunc( $arg = $aMeth( $arg = $aFunc( 1 ) ) ) )RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s/deeply nested argstring, {} enclosure + with WSs1${aFunc( $arg = $aMeth( $arg = $aFunc( 1 ) ) ) }RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest22s cCs|idddS(s/deeply nested argstring, [] enclosure + with WSs1$[aFunc( $arg = $aMeth( $arg = $aFunc( 1 ) ) ) ]RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest23s cCs|idddS(s.deeply nested argstring, () enclosure + *caches2$*(aFunc( $arg = $aMeth( $arg = $aFunc( 1 ) ) ) )RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest24s cCs|idddS(s1deeply nested argstring, () enclosure + *15*caches5$*15*(aFunc( $arg = $aMeth( $arg = $aFunc( 1 ) ) ) )RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest25s cCs|idddS(s(a function call with the Python None kw.s $aFunc(None)R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest26s (RR RRRRRRRRRRRRRRRRRRRRRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs4                         t NameMappercBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZRS(cCs|idddS(t autocallings$aFunc! $aFunc().sScooby! Scooby.N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(snested autocallings$aFunc($aFunc).sScooby.N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(slist subscriptions $aList[0]R'N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s list slicings $aList[:2]s['item0', 'item1']N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s%list slicing and subcription combineds $aList[:2][0]R'N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s$dictionary access - NameMapper styles $aDict.oneR(N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s dictionary access - Python styles $aDict['one']R(N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s8dictionary access combined with autocalled string methods$aDict.one.uppertITEM1N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s-dictionary access combined with string methods$aDict.one.upper()RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s+nested dictionary access - NameMapper styles$aDict.nestedDict.twoR.N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s'nested dictionary access - Python styles$aDict['nestedDict']['two']R.N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s,nested dictionary access - alternating styles$aDict['nestedDict'].twoR.N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s9nested dictionary access using method - alternating styles$aDict.get('nestedDict').twoR.N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s@nested dictionary access - NameMapper style - followed by methods$aDict.nestedDict.two.uppert NESTEDITEM2N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(sAnested dictionary access - alternating style - followed by methods$aDict['nestedDict'].two.upperRN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(sLnested dictionary access - NameMapper style - followed by method, then slices$aDict.nestedDict.two.upper[:4]tNESTN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s>nested dictionary access - Python style using a soft-coded keys%$aDict[$anObj.meth('nestedDict')].twoR.N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(sobject method accesss $anObj.meth1RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s/object method access, followed by complex slices-$anObj.meth1[0: ((4/4*2)*2)/$anObj.meth1(2) ]tdoN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(ssobject method access, followed by a very complex slice If it can pass this one, it's safe to say it works!!s4$( anObj.meth1[0: ( (4/4*2)*2)/$anObj.meth1(2) ] )RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(sobject method access with % in the default arg for the meth. This tests a bug that Jeff Johnson found and submitted a patch to SF for.s$$anObj.methWithPercentSignDefaultArgs110%N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs (RR RRRRRRRRRRRRRRRRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs*                    tCacheDirectivecBs>eZdZdZdZdZdZdZRS(cCs|idddS(ssimple #cache s #cache:$anIntRN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(ssimple #cache + WSs #cache $anInt#end cacheRN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(ssimple #cache ... #end caches6#cache id='cache1', timer=150m $anInt #end cache $aStrs1 blargN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR#scCs|iddddS(s2 #cache ... #end cache blockss#slurp #def foo #cache ID='cache1', timer=150m $anInt #end cache #cache id='cache2', timer=15s #for $i in range(5) $i#slurp #end for #end cache $aStr#slurp #end def $foo$foo$foo$foo$foos 1 01234blargiN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR+s cCs|iddddS(snested #cache blockss#slurp #def foo #cache ID='cache1', timer=150m $anInt #cache id='cache2', timer=15s #for $i in range(5) $i#slurp #end for $*(6)#slurp #end cache #end cache $aStr#slurp #end def $foo$foo$foo$foo$foos 1 012346blargiN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR=s cCs$|idd|idddS(s-Make sure that partial directives don't matchs #cache_foos#cachedN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyROs  (RR RRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs      t CallDirectivecBsYeZdZdZdZdZdZdZdZdZ dZ RS( cCs4|idd|idd|idddS(s simple #call s#call int $anInt#end callRs#call int: $anInts#call int: 10 $aStrs10 blargN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRXs    cCs|idddS(ssimple #call + WSs#call int $anInt #end callRN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRbs cCs|idddS(sa longer #callsT#def meth(arg) $arg.upper()#slurp #end def #call $meth $(1234+1) foo#slurp #end calls1235 FOON(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRgscCs|idddS(s#call with keyword #argss#def meth(arg1, arg2) $arg1.upper() - $arg2.lower()#slurp #end def #call self.meth #arg arg1 $(1234+1) foo#slurp #arg arg2 UPPER#slurp #end calls1235 FOO - upperN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRrs cCs|idddS(s%#call with single-line keyword #args s#def meth(arg1, arg2) $arg1.upper() - $arg2.lower()#slurp #end def #call self.meth #arg arg1:$(1234+1) foo#slurp #arg arg2:UPPER#slurp #end calls1235 FOO - upperN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(sM#call with python kwargs and cheetah output for the 1s positional args}#def meth(arg1, arg2) $arg1.upper() - $arg2.lower()#slurp #end def #call self.meth arg2="UPPER" $(1234+1) foo#slurp #end calls1235 FOO - upperN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s"#call with python kwargs and #argss#def meth(arg1, arg2, arg3) $arg1.upper() - $arg2.lower() - $arg3#slurp #end def #call self.meth arg2="UPPER", arg3=999 #arg arg1:$(1234+1) foo#slurp #end calls1235 FOO - upper - 999N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(sh#call with python kwargs and #args, and using a function to get the function that will be calleds#def meth(arg1, arg2, arg3) $arg1.upper() - $arg2.lower() - $arg3#slurp #end def #call getattr(self, "meth") arg2="UPPER", arg3=999 #arg arg1:$(1234+1) foo#slurp #end calls1235 FOO - upper - 999N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(snested #call directivess#def meth(arg1) $arg1#slurp #end def #def meth2(x,y) $x$y#slurp #end def ## #call self.meth 1#slurp #call self.meth 2#slurp #call self.meth 3#slurp #end call 3 #set two = 2 #call self.meth2 y=c"$(10/$two)" #arg x 4#slurp #end call 4 #end call 2 #end call 1t12345N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs( RR RRRRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRVs   t I18nDirectivecBseZdZRS(cCs4|idd|idd|idddS(s simple #call s#i18n $anInt#end i18nRs #i18n: $anInts#i18n: 10 $aStrs10 blargN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs    (RR R(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRstCaptureDirectivecBseZdZdZRS(cCs|idddS(ssimple #captures;#capture cap1 $(1234+1) foo#slurp #end capture $cap1#slurp s1235 fooN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(sslightly more complex #capturesv#def meth(arg) $arg.upper()#slurp #end def #capture cap1 $(1234+1) $anInt $meth("foo")#slurp #end capture $cap1#slurp s 1235 1 FOON(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs(RR RR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs tSlurpDirectivecBs5eZdZdZdZdZdZRS(cCs|idddS(s#slurp with 1 \n s#slurp R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s:#slurp with 1 \n, leading whitespace Should gobbles #slurp R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s:#slurp with 1 \n, leading content Shouldn't gobbles 1234 #slurp s 1234 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s@#slurp with WS then \n, leading content Shouldn't gobbles 1234 #slurp s 1234 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(sQ#slurp with garbage chars then \n, leading content Should eat the garbages 1234 #slurp garbage s 1234 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s (RR RRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs     RcBs?eZedZdZdZdZdZdZRS(RcCs|id|iddS(s#slurp with 1 \n s%s R7N(Rpt_EOLSlurpToken(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|id|iddS(s:#slurp with 1 \n, leading whitespace Should gobbles %s R7N(RpR(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|id|iddS(s:#slurp with 1 \n, leading content Shouldn't gobbles 1234 %s s 1234 N(RpR(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|id|iddS(s@#slurp with WS then \n, leading content Shouldn't gobbles 1234 %s s 1234 N(RpR(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR%scCs"|id|id|idS(sU#slurp with garbage chars then \n, leading content Should NOT eat the garbages 1234 %s garbage N(RpR(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR+s( RR RRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs      t RawDirectivecBs>eZdZdZdZdZdZdZRS(cCs|idddS(s #raw till EOFs#raw $aFunc(). s $aFunc(). N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR5s cCs|idddS(s#raw till #end raws#raw $aFunc(). #end raw $anInts $aFunc(). 1N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR:s cCs|idddS(s#raw till #end raw gobble WSs' #raw $aFunc(). #end raw $anInts $aFunc(). 1N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR?s cCs|idddS(sL#raw till #end raw using explicit directive closure Shouldn't gobbles) #raw # $aFunc(). #end raw # $anInts $aFunc(). 1N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRDs cCs$|idd|idddS(ssingle-line short form #raw: s#raw: $aFunc(). s $aFunc(). s#raw: $aFunc(). $anInts $aFunc(). 1N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRJs  cCs|idddS(s# Escape characters in a #raw block sv#raw: This escape should be preserved: \$unexpanded So should this one: \#blah The string "\012" should not disappear.spThis escape should be preserved: \$unexpanded So should this one: \#blah The string "\012" should not disappear.N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRRs (RR RRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR4s      tBreakpointDirectivecBs#eZdZdZdZRS(cCs|idddS(s(#breakpoint part way through source codes$aFunc(2). #breakpoint $anInts2. N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRYs cCs|idddS(s#breakpoint at BOFs#breakpoint $anIntR7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR^s cCs|idddS(s#breakpoint at EOFs$anInt #breakpoints1 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRcs (RR RRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRXs  t StopDirectivecBs5eZdZdZdZdZdZRS(cCs|idddS(s"#stop part way through source codes$aFunc(2). #stop $anInts2. N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRjs cCs|idddS(s #stop at BOFs #stop $anIntR7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRos cCs|idddS(s #stop at EOFs $anInt #stops1 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRts cCs|idddS(s#stop in pos test blocks4$anInt #if 1 inside the if block #stop #end if blargs1 inside the if block N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRyscCs|idddS(s#stop in neg test blocks4$anInt #if 0 inside the if block #stop #end if blargs1 blargN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs(RR RRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRis     tReturnDirectivecBs#eZdZdZdZRS(cCs|idddS(s#return'ing an int s[1 $str($test-6) 3 #def test #if 1 #return (3 *2) + 2 #else aoeuoaeu #end if #end def s1 2 3 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s#return'ing an string sQ1 $str($test[1]) 3 #def test #if 1 #return '123' #else aoeuoaeu #end if #end def s1 2 3 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(sD#return'ing an string AND streaming other output via the transactionsb1 $str($test(trans=trans)[1]) 3 #def test 1.5 #if 1 #return '123' #else aoeuoaeu #end if #end def s 1 1.5 2 3 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs (RR RRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs  tYieldDirectivecBseZeZdZRS(c Cs{d}d}d}xb|||fD]Q}ti|dt}|i}g}|D]}|t|qW~} q"WdS(ssimple #yield s%#for i in range(10) #yield i #end fors,#for i in range(10) $i#slurp #yield #end fors[#def iterator #for i in range(10) #yield i #end for #end def #for i in $iterator $i#end forRYN(RR`RReR( Rtsrc1tsrc2tsrc3tsrctklasstitert_[1]tiRo((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs'(RR R R[R(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRsit ForDirectivecBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZRS(cCsD|idd|idd|idd|idddS(s#for loop with one local vars#for $i in range(5) $i #end fors 0 1 2 3 4 s #for $i in range(5): $i #end fors*#for $i in range(5): ##comment $i #end fors)#for $i in range(5) ##comment $i #end forN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs    cCs|idddS(s#for loop with WS in loops #for $i in range(5) $i #end fors0 1 2 3 4 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s#for loop gobble WSs, #for $i in range(5) $i #end for s0 1 2 3 4 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s#for loop over lists+#for $i, $j in [(0,1),(2,3)] $i,$j #end fors0,1 2,3 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s #for loop over list, with #slurps1#for $i, $j in [(0,1),(2,3)] $i,$j#slurp #end fors0,12,3N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s #for loop with explicit closuress#for $i in range(5)#$i#end for#t01234N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s'#for loop with explicit closures and WSs# #for $i in range(5)#$i#end for# s 01234 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s#for loop using another $vars+ #for $i in range($aFunc(5))#$i#end for# s 01234 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(stest methods in for loopss3#for $func in $listOfLambdas $func($anInt) #end fors1 1 1 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs$|idd|idddS(s/#for loop over list, using methods of the itemssA#for i, j in [('aa','bb'),('cc','dd')] $i.upper,$j.upper #end fors AA,BB CC,DD sC#for $i, $j in [('aa','bb'),('cc','dd')] $i.upper,$j.upper #end forN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs  cCs$|idd|idddS(s4#for loop over list, using ($i,$j) style target listsC#for (i, j) in [('aa','bb'),('cc','dd')] $i.upper,$j.upper #end fors AA,BB CC,DD sE#for ($i, $j) in [('aa','bb'),('cc','dd')] $i.upper,$j.upper #end forN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs  cCs$|idd|idddS(s5#for loop over list, using i, (j,k) style target listsQ#for i, (j, k) in enumerate([('aa','bb'),('cc','dd')]) $j.upper,$k.upper #end fors AA,BB CC,DD sT#for $i, ($j, $k) in enumerate([('aa','bb'),('cc','dd')]) $j.upper,$k.upper #end forN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR#s  cCs|idddS(ssingle line #fors#for $i in range($aFunc(5)): $iRN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR*s cCs|idddS(s+single line #for with 1 extra leading spaces #for $i in range($aFunc(5)): $is 0 1 2 3 4N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR/s cCs|iddddS(s2 times single line #fors&#for $i in range($aFunc(5)): $i#slurp iRNt 0123401234(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR4s cCs|idddS(sfalse single line #for s!#for $i in range(5): $i #end fors 0 1 2 3 4 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR9s (RR RRRRRRRRRRRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs                tRepeatDirectivecBs>eZdZdZdZdZdZdZRS(cCsD|idd|idd|idd|idddS(s basic #repeats#repeat 3 1 #end repeats1 1 1 s#repeat 3: 1 #end repeats!#repeat 3 ##comment 1 #end repeats"#repeat 3: ##comment 1 #end repeatN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRCs    cCs|idddS(s#repeat with numeric expressions#repeat 3*3/3 1 #end repeats1 1 1 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRPs cCs|idddS(s#repeat with placeholders#repeat $numTwo 1 #end repeats1 1 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRUs cCs|idddS(s#repeat with placeholder * nums#repeat $numTwo*1 1 #end repeats1 1 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRZs cCs|idddS(s#repeat with placeholder and WSs) #repeat $numTwo 1 #end repeat s1 1 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR_s cCs8|idd|iddd |idddS( ssingle-line #repeats#repeat $numTwo: 1t11s#repeat $numTwo: 1 is1 1 s#repeat 3: 1 #end repeats1 1 1 Ns1 1 1 1 (Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRds    (RR RRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRAs     t AttrDirectivecBs5eZdZdZdZdZdZRS(cCs|idddS(s#attr with ints#attr $test = 1234 $testRN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRrs cCs|idddS(s#attr with strings#attr $test = 'blarg' $testR#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRws cCs|idddS(s#attr with expressions%#attr $test = 'blarg'.upper()*2 $testt BLARGBLARGN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR|s cCs|idddS(s,#attr with string + WS Should gobbles# #attr $test = 'blarg' $testR#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s>#attr with string + WS + leading text Shouldn't gobbles% -- #attr $test = 'blarg' $tests -- blargN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs (RR RRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRps     t DefDirectivecBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZRS(cCs4|idd|idd|idddS(s#def without argstrings%#def testMeth 1234 #end def $testMeths1234 s0#def testMeth ## comment 1234 #end def $testMeths1#def testMeth: ## comment 1234 #end def $testMethN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs    cCs|idddS(s!#def without argstring, gobble WSs1 #def testMeth 1234 #end def $testMeths1234 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s#def with argstring, gobble WSs7 #def testMeth($a=999) 1234-$a #end def $testMeths 1234-999 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s3#def with argstring, gobble WS, string used in calls> #def testMeth($a=999) 1234-$a #end def $testMeth('ABC')s 1234-ABC N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s1#def with argstring, gobble WS, list used in calls@ #def testMeth($a=999) 1234-$a #end def $testMeth([1,2,3])s1234-[1, 2, 3] N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s.#def with 2 args, gobble WS, list used in callsL #def testMeth($a, $b='default') 1234-$a$b #end def $testMeth([1,2,3])s1234-[1, 2, 3]default N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s#def with *args, gobble WSs: #def testMeth($*args) 1234-$args #end def $testMeths1234-() N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s#def with **KWs, gobble WSs9 #def testMeth($**KWs) 1234-$KWs #end def $testMeths1234-{} N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s"#def with *args + **KWs, gobble WSsG #def testMeth($*args, $**KWs) 1234-$args-$KWs #end def $testMeths 1234-()-{} N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s"#def with *args + **KWs, gobble WSsS #def testMeth($*args, $**KWs) 1234-$args-$KWs.a #end def $testMeth(1,2, a=1)s1234-(1, 2)-1 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(ssingle line #def with extra WSs%#def testMeth: aoeuaoeu - $testMeth -s - aoeuaoeu -N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s7single line #def with extra WS and nested $placeholderss0#def testMeth: $anInt $aFunc(1234) - $testMeth -s - 1 1234 -N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s&single line #def escaped $placeholderss-#def testMeth: \$aFunc(\$anInt) - $testMeth -s- $aFunc($anInt) -N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s(single line #def 1 escaped $placeholderss,#def testMeth: \$aFunc($anInt) - $testMeth -s - $aFunc(1) -N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s2single line #def 1 escaped $placeholders + more WSs0#def testMeth : \$aFunc($anInt) - $testMeth -s - $aFunc(1) -N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s#multiline #def with $ on methodNames&#def $testMeth 1234 #end def $testMeths1234 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s%single line #def with $ on methodNames#def $testMeth:1234 $testMethRN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s!single line #def with an arguments(#def $testMeth($arg=1234):$arg $testMethRN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs$|idddddddS(s/#def that extends over two lines with argumentss#def $testMeth($arg=1234, s $arg2=5678) s $arg $arg2 s #end def s $testMeths 1234 5678 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs(RR RRRRRRRRRRRRRRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs&                 tDecoratorDirectivecBseZdZdZRS(cCs|idd|idd|idd|idddd|iddddy|idd ddWntj onX|id d S( ssingle line #def with decorators#@ blahs #@23 blahs#@@TR: comments9#from Cheetah.Tests.SyntaxAndOutput import testdecorator s#@testdecorators #def $testMeth():1234 $testMethRs #block $testMeth():1234s#@testdecorator sdfsshould raise a ParseErrorN(RpRR(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs     cCs$|idddddddS(s#def with multiple decoratorss9#from Cheetah.Tests.SyntaxAndOutput import testdecorator s#@testdecorator s#def testMeth s1234 #end def $testMeths1234 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s(RR RR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs itBlockDirectivecBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZRS(cCs$|idd|idddS(s#block without argstrings #block testBlock 1234 #end blocks1234 s*#block testBlock ##comment 1234 #end blockN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR0s  cCs|idddS(s##block without argstring, gobble WSs) #block testBlock 1234 #end block s1234 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR8s cCs|idddS(s#block with argstring, gobble WS Because blocks can be reused in multiple parts of the template arguments (!!with defaults!!) can be given.s4 #block testBlock($a=999) 1234-$a #end block s 1234-999 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR=s cCs|idddS(s#block with 2 args, gobble WSs> #block testBlock($a=999, $b=444) 1234-$a$b #end block s 1234-999444 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRFs cCs|idddS(s#block with 2 nested blocks Blocks can be nested to any depth and the name of the block is optional for the #end block part: #end block OR #end block [name] s#block testBlock this is a test block #block outerNest outer #block innerNest inner #end block innerNest #end block outerNest --- #end block testBlock s%this is a test block outer inner --- N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRLs cCs|idddS(ssingle line #block s!#block testMeth: This is my blocksThis is my blockN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR`scCs|idddS(ssingle line #block with WSs!#block testMeth: This is my blocksThis is my blockN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRfscCs|idddS(s*single line #block 1 escaped $placeholderss #block testMeth: \$aFunc($anInt)s $aFunc(1)N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRlscCs|idddS(s/single line #block 1 escaped $placeholders + WSs"#block testMeth: \$aFunc( $anInt )s $aFunc( 1 )N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRrscCs|idddS(s4single line #block 1 escaped $placeholders + more WSs$#block testMeth : \$aFunc( $anInt )s $aFunc( 1 )N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRxscCs|idddS(smultiline #block $ on argstrings!#block $testBlock 1234 #end blocks1234 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR~s cCs|idddS(s(single line #block with $ on methodName s"#block $testMeth: This is my blocksThis is my blockN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(ssingle line #block with an arg s/#block $testMeth($arg='This is my block'): $argsThis is my blockN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s(single line #block with None for contents'#block $testMeth: $None test $testMeth-stest -N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s+single line #block with nothing for contents1#block $testMeth: foo #end block test $testMeth-sfoo test foo -N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs(RR RRRRRRRRRRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR.s             tIncludeDirectivecBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZRS(cCs1tdd}|id|i|idS(Ns parseTest.txtRs$numOne $numTwo(RRRR(RR((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs  cCs(tiidotidndS(Ns parseTest.txt(RRRR(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s##include raw of source $emptyStrings #include raw source=$emptyStringR7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s'#include raw of source $blockToBeParseds$#include raw source=$blockToBeParseds$numOne $numTwoN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s#include raw of 'parseTest.txt's#include raw 'parseTest.txt's$numOne $numTwoN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s #include raw of $includeFileNames#include raw $includeFileNames$numOne $numTwoN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s)#include raw of $includeFileName, with WSs* #include raw $includeFileName s$numOne $numTwoN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s!#include raw of source= , with WSs8 #include raw source='This is my $Source '*2 s&This is my $Source This is my $Source N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s#include of $blockToBeParseds #include source=$blockToBeParseds1 2N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s%#include of $blockToBeParsed, with WSs& #include source=$blockToBeParsed s1 2N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s$#include of 'parseTest.txt', with WSs& #include source=$blockToBeParsed s1 2N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s$#include of "parseTest.txt", with WSs& #include source=$blockToBeParsed s1 2N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s9#include of 'parseTest.txt', with WS and surrounding texts.aoeu #include source=$blockToBeParsed aoeus aoeu 1 2aoeuN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s9#include of 'parseTest.txt', with WS and explicit closures% #include source=$blockToBeParsed# s 1 2 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs (RR RRRRRRRRRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs             tSilentDirectivecBs#eZdZdZdZRS(cCs|idddS(ssimple #silents#silent $aFuncR7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs$|idd|idddS(ssimple #silents$#silent $anObj.callIt $anObj.callArgRs.#silent $anObj.callIt ##comment $anObj.callArgN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs  cCs|idddS(ssimple #silents(#silent $anObj.callIt(99) $anObj.callArgt99N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs (RR RRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs  t SetDirectivecBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZRS(cCs4|idd|idd|idddS(s simple #sets #set $testVar = 'blarg' $testVarR#s#set testVar = 'blarg' $testVars(#set testVar = 'blarg'##comment $testVarN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs    cCs|idddS(s'simple #set with no WS between operandss#set $testVar='blarg'R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s#set + use of vars #set $testVar = 'blarg' $testVarR#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s#set + use in an #includes:#set global $aSetVar = 1234 #include source=$includeBlock2s1 2 1234N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s#set with a dictionarysY#set $testDict = {'one':'one1','two':'two2','three':'three3'} $testDict.one $testDict.twos one1 two2N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(s(#set with string, then used in #if blocks,#set $test='a string' #if $test#blarg#end ifR#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(ssimple #set, gobble WSs #set $testVar = 'blarg' R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(ssimple #set, don't gobble WSs #set $testVar = 'blarg'#---s ---N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR%s cCs|idddS(ssimple #set with a lists' #set $testVar = [1, 2, 3] $testVars [1, 2, 3]N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR*s cCs|idddS(ssimple #set global with a lists. #set global $testVar = [1, 2, 3] $testVars [1, 2, 3]N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR/s cCs|idddS(ssimple #set global with a list and *cache Caching only works with global #set vars. Local vars are not accesible to the cache namespace. s/ #set global $testVar = [1, 2, 3] $*testVars [1, 2, 3]N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR4s cCs|idddS(s/simple #set global with a list and **caches1 #set global $testVar = [1, 2, 3] $*5*testVars [1, 2, 3]N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR>s cCs|idddS(s*simple #set with a list and **caches2 #set global $testVar = [1, 2, 3] $*.5*testVars [1, 2, 3]N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRCs cCs|idddS(s!simple #set without NameMapper ons7#compiler useNameMapper = 0 #set $testVar = 1 $testVarRN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRHs cCs|idddS(ssimple #set without $s#set testVar = 1 $testVarRN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRMs cCs|idddS(ssimple #set global without $s!#set global testVar = 1 $testVarRN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRRs cCs|idddS(ssimple #set module without $s$#set module __foo__ = 'bar' $__foo__tbarN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRWs cCs$|idd|idddS(s##set with i,j=list style assignments#set i,j = [1,2] $i$jt12s#set $i,$j = [1,2] $i$jN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR\s  cCs$|idd|idddS(s%#set with (i,j)=list style assignments#set (i,j) = [1,2] $i$jRs#set ($i,$j) = [1,2] $i$jN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRcs  cCs$|idd|idddS(s(#set with i, (j,k)=list style assignments #set i, (j,k) = [1,(2,3)] $i$j$kt123s##set $i, ($j,$k) = [1,(2,3)] $i$j$kN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRjs  (RR RRRRRRRRRRRRRRRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs(                 t IfDirectivecBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZRS(cCs|idd|idd|idd|idd|idd|idd|id d|id dd S( ssimple #if blocks#if 1 $aStr #end if sblarg s#if 1: $aStr #end if s#if 1: $aStr #end if s #if 1: ##comment $aStr #end if s#if 1 ##comment $aStr #end if s,#if 1##for i in range(10)#$i#end for##end ift 0123456789s%#if 1: #for i in range(10)#$i#end fors#if 1: #for i in range(10):$iN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRts         cCs|idddS(ssimple #if block, with WSs #if 1 $aStr #end if sblarg N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s/simple #if block, with WS and explicit closuress #if 1# $aStr #end if #-- s blarg -- N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s#if block using $numOnes#if $numOne $aStr #end if sblarg N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s#if block using $zeros#if $zero $aStr #end if R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s#if block using $emptyStrings#if $emptyString $aStr #end if R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s,#if ... #else ... block using a $emptyStrings5#if $emptyString $anInt #else $anInt - $anInt #end ifs1 - 1 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s6#if ... #elif ... #else ... block using a $emptyStrings?#if $emptyString $c #elif $numOne $numOne #else $c - $c #end ifs1 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s#if 'not' test, with #slurps)#if not $emptyString $aStr#slurp #end if R#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs;y|iddWntj onX|iddS(s@#if block using $*emptyString This should barf s #if $*emptyString $aStr #end if R7sThis should barfN(RpRR(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs   cCsLxEd D]=}y|i|dWntj oqX|idqWdS( sE#if block using invalid top-level $(placeholder) syntax - should barfs"#if $*5*emptyString $aStr #end if s!#if ${emptyString} $aStr #end if s!#if $(emptyString) $aStr #end if s!#if $[emptyString] $aStr #end if s #if $!emptyString $aStr #end if R7sThis should barfN(s"#if $*5*emptyString $aStr #end if s!#if ${emptyString} $aStr #end if s!#if $(emptyString) $aStr #end if s!#if $[emptyString] $aStr #end if s #if $!emptyString $aStr #end if (RpRR(Rt badSyntax((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRscCs|idddS(sr#if ... #else if ... #else ... block using a $emptyString Same as test 8 but using else if instead of elifsB#if $emptyString $c #else if $numOne $numOne #else $c - $c #end ifs1 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s5#if# ... #else # ... block using a $emptyString with s4#if $emptyString# $anInt#else#$anInt - $anInt#end ifs1 - 1N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(ssingle-line #if: simples)#if $emptyString then 'true' else 'false'tfalseN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(ssingle-line #if: more complexs##if $anInt then 'true' else 'false'ttrueN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs|idddS(s@single-line #if: with the words 'else' and 'then' in the output sM#if ($anInt and not $emptyString==''' else ''') then $str('then') else 'else'tthenN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs cCs$|idd|idddS(ssingle-line #if: s #if 1: foo #if 0: bar #if 1: foosfoo fooN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs  cCs4|idd|idd|idddS(ssingle-line #if: #else: s#if 1: foo #elif 0: barsfoo s%#if 1: foo #elif 0: bar #else: blarg s%#if 0: foo #elif 0: bar #else: blarg sblarg N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs    (RR RRRRRRRRRRRRRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRrs$                tUnlessDirectivecBs>eZdZdZdZdZdZdZRS(cCsD|idd|idd|idd|idddS(s #unless 1s#unless 1 1234 #end unlessR7s#unless 1: 1234 #end unlesss'#unless 1: ##comment 1234 #end unlesss&#unless 1 ##comment 1234 #end unlessN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s    cCs|idddS(s #unless 0s#unless 0 1234 #end unlesss 1234 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s #unless $nones #unless $none 1234 #end unlesss 1234 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s#unless $numTwos"#unless $numTwo 1234 #end unlessR7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s#unless $numTwo with WSs/ #unless $numTwo 1234 #end unless R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs8|idd|idd|iddd dS( ssingle-line #unlesss#unless 1: 1234R7s#unless 0: 1234Rs#unless 0: 1234 is1234 Ns 1234 1234 (Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR$ s(RR RRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs      tPSPcBskeZdZdZdZdZdZdZdZdZ dZ d Z d Z RS( cCsdS(N(R~(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRV+ scCs|idddS(ssimple <%= [int] %>s <%= 1234 %>RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR. scCs|idddS(ssimple <%= [string] %>s<%= 'blarg' %>R#N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR2 scCs|idddS(ssimple <%= None %>s <%= None %>R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR6 scCs|idddS(ssimple <%= [string] %> + $anInts<%= 'blarg' %>$anIntRN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR9 scCs|idddS(ssimple <%= [EXPR] %> + $anInts <%= ('blarg'*2).upper() %>$anIntt BLARGBLARG1N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR= scCs|idddS(sfor loop in <%%>s<% for i in range(5):%>1<%end%>t11111N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRA scCs|idddS(s!for loop in <%%> and using <%=i%>s$<% for i in range(5):%><%=i%><%end%>RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRE scCs|idddS(s#for loop in <% $%> and using <%=i%>s/<% for i in range(5): i=i*2$%><%=i%><%end%>t02468N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRI scCs|idddS(s3for loop in <% $%> and using <%=i%> plus extra texts0<% for i in range(5): i=i*2$%><%=i%>-<%end%>s 0-2-4-6-8-N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRN scCs-hdd6g|_d}|i|ddS(s% Using getVar and write within a PSP itmesrThis is my template <% me = self.getVar('me') if isinstance(me, int): write('Bork') else: write('Nork') %>sThis is my template BorkN(RURp(RRc((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRS s( RR RVRRRRRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR* s          tWhileDirectivecBseZdZRS(cCs|idddS(ssimple #while with a counters:#set $i = 0 #while $i < 5 $i#slurp #set $i += 1 #end whileRN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRb s (RR R(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR a stContinueDirectivecBseZdZdZRS(cCs|idddS(s#continue with a #whilesq#set $i = 0 #while $i < 5 #if $i == 3 #set $i += 1 #continue #end if $i#slurp #set $i += 1 #end whilet0124N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRh scCs|idddS(s#continue with a #forsE#for $i in range(5) #if $i == 3 #continue #end if $i#slurp #end forRN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRu s(RR RR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR g s tBreakDirectivecBseZdZdZRS(cCs|idddS(s#break with a #whilesW#set $i = 0 #while $i < 5 #if $i == 3 #break #end if $i#slurp #set $i += 1 #end whilet012N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR scCs|idddS(s#break with a #forsB#for $i in range(5) #if $i == 3 #break #end if $i#slurp #end forRN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s(RR RR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s t TryDirectivecBs5eZdZdZdZdZdZRS(cCs|idddS(ssimple #try s #try 1234 #except blarg #end trys1234 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s##try / #except with #raise s-#try #raise ValueError #except blarg #end trysblarg N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s?#try / #except with #raise + WS Should gobble s9 #try #raise ValueError #except blarg #end trysblarg N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s[#try / #except with #raise + WS and leading text Shouldn't gobble s<--#try #raise ValueError #except blarg #end try#--s -- blarg --N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s*nested #try / #except with #raise s`#try #raise ValueError #except #try #raise ValueError #except blarg #end try #end trysblarg N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s (RR RRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s    t PassDirectivecBseZdZdZRS(cCs|idddS(s(#pass in a #try / #except block s-#try #raise ValueError #except #pass #end tryR7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s-#pass in a #try / #except block + WS sB #try #raise ValueError #except #pass #end tryR7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s (RR RR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s tAssertDirectivecBs#eZdZdZdZRS(cCs|idddS(ssimple #assert s!#set $x = 1234 #assert $x == 1234R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs |d}|it|dS(s"simple #assert that fails cSs|iddfdS(Ns #set $x = 1234 #assert $x == 999R7(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyttest s N(tfailUnlessRaisestAssertionError(RR((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(ssimple #assert with WS s'#set $x = 1234 #assert $x == 1234 R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s (RR RRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s  tRaiseDirectivecBs#eZdZdZdZRS(cCs |d}|it|dS(sBsimple #raise ValueError Should raise ValueError cSs|iddfdS(Ns#raise ValueErrorR7(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s N(Rt ValueError(RR((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs |d}|it|dS(sH#raise ValueError in #if block Should raise ValueError cSs|idddS(Ns #if 1 #raise ValueError #end if R7(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s N(RR(RR((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(sK#raise ValueError in #if block Shouldn't raise ValueError s+#if 0 #raise ValueError #else blarg#end if sblarg N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s (RR RRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s tImportDirectivecBskeZdZdZdZdZdZdZdZdZ dZ d Z d Z RS( cCs|idddS(s#import math s #import mathR7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s1#import math + WS Should gobble s #import math R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(sK#import math + WS + leading text Shouldn't gobble s -- #import math s -- N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s#from math import syn s#from math import cosR7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s:#from math import cos + WS Should gobble s #from math import cos R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR& s cCs|idddS(sL#from math import cos + WS + leading text Shouldn't gobble s -- #from math import cos s -- N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR- s cCs|idddS(s(#from math import cos -- use it s#from math import cos $cos(0)s1.0N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR4 s cCs|idddS(s6#from math import cos,tan,sin -- and use them s7#from math import cos, tan, sin $cos(0)-$tan(0)-$sin(0)s 1.0-0.0-0.0N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR: s cCs|idttdS(s"#import os.path -- use it s$#import os.path $os.path.exists('.')N(RpRR(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR@ s cCs|idttdS(s=#import os.path -- use it with NameMapper turned off se## #compiler-settings useNameMapper=False #end compiler-settings #import os.path $os.path.exists('.')N(RpRR(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRG scCs|idddS(s#from math import * s(#from math import * $pow(1,2) $log10(10)s1.0 1.0N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRR s ( RR RRRRRRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s          tCompilerDirectivecBseZdZdZRS(cCs|idddS(s)overriding the commentStartToken sC$anInt##comment #compiler commentStartToken = '//' $anInt//comment s1 1 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRZ scCs|idddS(s7overriding and resetting the commentStartToken sc$anInt##comment #compiler commentStartToken = '//' $anInt//comment #compiler reset $anInt//comment s1 1 1//comment N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRc s(RR RR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRY s tCompilerSettingsDirectivecBs#eZdZdZdZRS(cCs|idddS(s,overriding the cheetahVarStartToken sq$anInt #compiler-settings cheetahVarStartToken = @ #end compiler-settings @anInt #compiler-settings reset $anInt s1 1 1 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRq scCs|idddS(s+overriding the directiveStartToken sf#set $x = 1234 $x #compiler-settings directiveStartToken = @ #end compiler-settings @set $x = 1234 $x s 1234 1234 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR~ scCs|idddS(s)overriding the commentStartToken sa$anInt##comment #compiler-settings commentStartToken = // #end compiler-settings $anInt//comment s1 1 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s(RR RRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRo s tjavatExtendsDirectivecBs,eZdZdZdZdZRS(cCs$|idd|idddS(s(#extends Cheetah.Templates._SkeletonPagesp#from Cheetah.Templates._SkeletonPage import _SkeletonPage #extends _SkeletonPage #implements respond $spacer() s5 s~#from Cheetah.Templates._SkeletonPage import _SkeletonPage #extends _SkeletonPage #implements respond(foo=1234) $spacer()$foo s91234 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s7#extends Cheetah.Templates.SkeletonPage without #importsF#extends Cheetah.Templates.SkeletonPage #implements respond $spacer() s5 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR scCs|idddS(sD#extends Cheetah.Templates.SkeletonPage.SkeletonPage without #importsS#extends Cheetah.Templates.SkeletonPage.SkeletonPage #implements respond $spacer() s5 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR scCs|idddS(s)#extends with globals and searchList tests]#extends Cheetah.Templates.SkeletonPage #set global g="Hello" #implements respond $g $numOne sHello 1 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s(RR RRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s   tSuperDirectivecBseZdZRS(cCs(tid}|id}d}dS(NsR$foo $bar(99) #def foo: this is base foo #def bar(arg): super-$args #implements dummy #def foo #super This is child foo #super(trans=trans) $bar(1234) #end def #def bar(arg): #super($arg) sZthis is base foo This is child foo this is base foo super-1234 super-99(RR`R(Rttmpl1ttmpl2Rq((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s   (RR R(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR stImportantExampleCasescBseZdZRS(cCs|idddS(s"how to make a comma-delimited listsW#set $sep = '' #for $letter in $letterList $sep$letter#slurp #set $sep = ', ' #end for sa, b, cN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s(RR R(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR! stFilterDirectivecBszeZeZdZdZdZdZdZdZ dZ dZ dZ d Z d Zd ZRS( cCs htd6S(NtuseFilterArgsInPlaceholders(R(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRa scCs$|idd|idddS(s#filter Filter s#filter Filter $none#end filterR7s#filter Filter: $noneN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s  cCs|idddS(s$#filter ReplaceNone with WS s!#filter Filter $none#end filterR7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s#filter MaxLen -- maxlen of 5s3#filter MaxLen ${tenDigits, $maxlen=5}#end filterRN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s$#filter MaxLen -- no maxlen s(#filter MaxLen ${tenDigits}#end filtert 1234567890N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s'#filter WebSafe -- basic usage s)#filter WebSafe $webSafeTest#end filtersabc <=> &N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s&#filter WebSafe -- also space s6#filter WebSafe ${webSafeTest, $also=' '}#end filtersabc <=> &N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s=#filter WebSafe -- also space, without $ on the args s5#filter WebSafe ${webSafeTest, also=' '}#end filtersabc <=> &N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s*#filter Strip -- trailing newline s #filter Strip $strip1#end filtersstrippable whitespace N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCs|idddS(s,#filter Strip -- no trailing newine s #filter Strip $strip2#end filtersstrippable whitespaceN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR! s cCs|idddS(s$#filter Strip -- multi-line s #filter Strip $strip3#end filtersstrippable whitespace 1 2 3 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR' s cCs|idddS(sC#filter StripSqueeze -- canonicalize all whitespace to ' ' s'#filter StripSqueeze $strip3#end filtersstrippable whitespace 1 2 3N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR- s (RR R R[RaRRRRRRRRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR" s          t EchoDirectivecBseZdZRS(cCs|idddS(s#echo 1234 s #echo 1234RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR5 s (RR R(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR%4 scBseZdZRS(cCs|idddS(s#silent 1234 s #silent 1234R7N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR< s (RR R(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR; stErrorCatcherDirectivecBseZRS((RR (((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR&B st VarExistscBs5eZdZdZdZdZdZRS(cCs|idttdS(s$varExists('$anInt') s$varExists('$anInt')N(RpRR(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRH s cCs|idttdS(s$varExists('anInt') s$varExists('anInt')N(RpRR(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRN s cCs|idttdS(s$varExists('$anInt') s$varExists('$bogus')N(RpRR (R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRT s cCs|idddS(s5$varExists('$anInt') combined with #if false s/#if $varExists('$bogus') 1234 #else 999 #end ifs999 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRZ s cCs|idddS(s4$varExists('$anInt') combined with #if true s.#if $varExists('$anInt') 1234 #else 999#end ifs1234 N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR` s (RR RRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR'F s     tGetVarcBs5eZdZdZdZdZdZRS(cCs|idddS(s$getVar('$anInt') s$getVar('$anInt')RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRg s cCs|idddS(s$getVar('anInt') s$getVar('anInt')RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRm s cCs|idddS(s$self.getVar('anInt') s$self.getVar('anInt')RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRs s cCs|idddS(s$getVar('bogus', 1234) s$getVar('bogus', 1234)RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyRy s cCs|idddS(s $getVar('$bogus', 1234) s$getVar('$bogus', 1234)RN(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s (RR RRRRR(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR(f s     tMiscComplexSyntaxcBseZdZRS(cCs|idddS(sComplex use of {},[] and () in a #set expression ---- #set $c = {'A':0}[{}.get('a', {'a' : 'A'}['a'])] $c s3#set $c = {'A':0}[{}.get('a', {'a' : 'A'}['a'])] $ct0N(Rp(R((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s (RR R(((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR) stCGIcBsPeZdZeZdZdZeZdZdZ dZ dZ RS(sKCGI scripts with(out) the CGI environment and with(out) GET variables. cCsdtid|iddddd}|i|d|idS(sA (pseudo) Webware servlet. This uses the Python syntax escape to set self._CHEETAH__isControlledByWebKit. We could instead do '#silent self._CHEETAH__isControlledByWebKit = True', taking advantage of the fact that it will compile unchanged as long as there's no '$' in the statement. (It won't compile with an '$' because that would convert to a function call, and you can't assign to a function call.) Because this isn't really being called from Webware, we'd better not use any Webware services! Likewise, we'd better not call $cgiImport() because it would be misled. s##extends Cheetah.Tools.CGITemplate s#implements respond s7<% self._CHEETAH__isControlledByWebKit = True %>#slurp s$cgiHeaders#slurp s Hello, world!N(R/RpR1(RRW((sC/usr/lib64/python2.6/site-packages/Cheetah/Tests/SyntaxAndOutput.pyR s cCsU|idtid s                    _='<%Mu+$ z?v   $%2 c  /r+ mIz+7. P'- L   KJ\