PKRMc4?z¢†\\EGG-INFO/entry_points.txt [python.templating.engines] cheetah = turbocheetah.cheetahsupport:TurboCheetah PK:~š3EGG-INFO/not-zip-safePKRMc4#¼îâEGG-INFO/PKG-INFOMetadata-Version: 1.0 Name: TurboCheetah Version: 0.9.5 Summary: TurboGears plugin to support use of Cheetah templates. Home-page: http://www.turbogears.org/docs/plugins/template.html Author: Kevin Dangoor Author-email: dangoor+turbogears@gmail.com License: MIT Download-URL: http://www.turbogears.org/download/ Description: This template plugin can be used with TurboGears or Buffet. The development version is here: http://www.turbogears.org/svn/turbogears/trunk/plugins/cheetah/#egg=TurboCheetah-dev Platform: UNKNOWN Classifier: Development Status :: 3 - Alpha Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: License :: OSI Approved :: MIT License Classifier: Topic :: Software Development :: Libraries :: Python Modules PKRMc4زlžEGG-INFO/requires.txtCheetah >= 1.0PKRMc4òÏôMEGG-INFO/SOURCES.txtREADME.txt setup.py TurboCheetah.egg-info/PKG-INFO TurboCheetah.egg-info/SOURCES.txt TurboCheetah.egg-info/entry_points.txt TurboCheetah.egg-info/not-zip-safe TurboCheetah.egg-info/requires.txt TurboCheetah.egg-info/top_level.txt turbocheetah/__init__.py turbocheetah/cheetahsupport.py turbocheetah/tests/__init__.py turbocheetah/tests/import_inherit.tmpl turbocheetah/tests/inherit_from.tmpl turbocheetah/tests/simple1.tmpl turbocheetah/tests/test_template.py turbocheetah/tests/sub/master.tmpl turbocheetah/tests/sub/page.tmpl turbocheetah/tests/sub/page_over.tmpl turbocheetah/tests/sub/page_template_over.tmpl turbocheetah/tests/sub/template.tmpl turbocheetah/tests/sub/template_over.tmpl turbocheetah/tests/sub2/page_over.tmpl turbocheetah/tests/sub2/template_over.tmpl PKRMc4Š96 EGG-INFO/top_level.txtturbocheetah PKk~š3g”u3ooturbocheetah/__init__.pyfrom turbocheetah import cheetahsupport TurboCheetah = cheetahsupport.TurboCheetah __all__ = ["TurboCheetah"]PKSMc4¨¥CÎRRturbocheetah/__init__.pyc;ò ËW°Cc@s#dklZeiZdgZdS((scheetahsupports TurboCheetahN(s turbocheetahscheetahsupports TurboCheetahs__all__(scheetahsupports TurboCheetahs__all__((sEbuild/bdist.darwin-8.4.0-Power_Macintosh/egg/turbocheetah/__init__.pys?s  PK&Mc4ƒ?Ú7ppturbocheetah/cheetahsupport.py"Template support for Cheetah" import sys, os, imp from Cheetah import Compiler import pkg_resources def _recompile_template(package, basename, tfile, classname): tmpl = pkg_resources.resource_string(package, "%s.tmpl" % basename) c = Compiler.Compiler(source=tmpl, mainClassName='GenTemplate') code = str(c) mod = imp.new_module(classname) ns = dict() exec code in ns tempclass = ns.get("GenTemplate", ns.get('DynamicallyCompiledCheetahTemplate')) assert tempclass tempclass.__name__ = basename setattr(mod, basename, tempclass) sys.modules[classname] = mod return mod class TurboCheetah: extension = "tmpl" def __init__(self, extra_vars_func=None, options=None): if options is None: options = dict() self.get_extra_vars = extra_vars_func self.options = options self.compiledTemplates = {} self.search_path = [] def load_template(self, template=None, template_string=None, template_file=None, loadingSite=False): """Searches for a template along the Python path. Template files must end in ".tmpl" and be in legitimate packages. """ given = len(filter(None, (template, template_string, template_file))) if given > 1: raise TypeError( "You may give only one of template, template_string, and " "template_file") if not given: raise TypeError( "You must give one of template, template_string, or " "template_file") if template: return self.load_template_module(template) elif template_string: return self.load_template_string(template_string) elif template_file: return self.load_template_file(template_file) def load_template_module(self, classname): ct = self.compiledTemplates divider = classname.rfind(".") if divider > -1: package = classname[0:divider] basename = classname[divider+1:] else: raise ValueError, "All templates must be in a package" if not self.options.get("cheetah.precompiled", False): tfile = pkg_resources.resource_filename(package, "%s.%s" % (basename, self.extension)) if ct.has_key(classname): mtime = os.stat(tfile).st_mtime if ct[classname] != mtime: ct[classname] = mtime del sys.modules[classname] mod = _recompile_template(package, basename, tfile, classname) else: mod = __import__(classname, dict(), dict(), [basename]) else: ct[classname] = os.stat(tfile).st_mtime mod = _recompile_template(package, basename, tfile, classname) else: mod = __import__(classname, dict(), dict(), [basename]) tempclass = getattr(mod, basename) return tempclass def load_template_string(self, content): raise NotImplementedError def load_template_file(self, filename): raise NotImplementedError def render(self, info, format="html", fragment=False, template=None, template_string=None, template_file=None): tclass = self.load_template( template=template, template_string=template_string, template_file=template_file) if self.get_extra_vars: extra = self.get_extra_vars() else: extra = {} tempobj = tclass(searchList=[info, extra]) return str(tempobj) PKSMc4T±/ׇ‡turbocheetah/cheetahsupport.pyc;ò ˆUDc@sWdZdkZdkZdkZdklZdkZd„Zdfd„ƒYZdS(sTemplate support for CheetahN(sCompilerc Bs±ei|d|ƒ}eid|ddƒ}e|ƒ}e i |ƒ} e ƒ}||U|id|idƒƒ}|pt‚||_e| ||ƒ| ei|<| SdS(Ns%s.tmplssources mainClassNames GenTemplates"DynamicallyCompiledCheetahTemplate(s pkg_resourcessresource_stringspackagesbasenamestmplsCompilerscsstrscodesimps new_modules classnamesmodsdictsnssgets tempclasssAssertionErrors__name__ssetattrssyssmodules( spackagesbasenamestfiles classnamestmplscscodes tempclasssnssmod((sKbuild/bdist.darwin-8.4.0-Power_Macintosh/egg/turbocheetah/cheetahsupport.pys_recompile_templates     s TurboCheetahcBsetZdZeed„Zeeeed„Zd„Zd„Zd„Z deeeed„Z RS( NstmplcCsB|tjo tƒ}n||_||_h|_g|_dS(N(soptionssNonesdictsextra_vars_funcsselfsget_extra_varsscompiledTemplatess search_path(sselfsextra_vars_funcsoptions((sKbuild/bdist.darwin-8.4.0-Power_Macintosh/egg/turbocheetah/cheetahsupport.pys__init__s      cCsŸttt|||fƒƒ}|djotdƒ‚n| otdƒ‚n|o|i |ƒSn1|o|i |ƒSn|o|i |ƒSndS(s‚Searches for a template along the Python path. Template files must end in ".tmpl" and be in legitimate packages. isEYou may give only one of template, template_string, and template_files@You must give one of template, template_string, or template_fileN( slensfiltersNonestemplatestemplate_strings template_filesgivens TypeErrorsselfsload_template_modulesload_template_stringsload_template_file(sselfstemplatestemplate_strings template_files loadingSitesgiven((sKbuild/bdist.darwin-8.4.0-Power_Macintosh/egg/turbocheetah/cheetahsupport.pys load_template"s c Csi|i} |idƒ}|djo|d|!}||d}n td‚|i i dt ƒ oÐt i |d||ifƒ}| i|ƒorti|ƒi}| ||jo-|| |4€Œ¥turbocheetah/tests/__init__.py# PKSMc4Ž,Æ ››turbocheetah/tests/__init__.pyc;ò °)ÞCc@sdS(N((((sKbuild/bdist.darwin-8.4.0-Power_Macintosh/egg/turbocheetah/tests/__init__.pys?sPK\O>4}Ûž ž #turbocheetah/tests/test_template.pyimport os from turbocheetah import TurboCheetah here = os.path.dirname(__file__) values = { 'v': 'VV', 'one': 1, } def test_normal(): plugin = TurboCheetah() # Make sure a simple test works: s = plugin.render(values, template='turbocheetah.tests.simple1') assert s.strip() == 'This is a test: VV' # Make sure one template can inherit from another: s = plugin.render(values, template='turbocheetah.tests.import_inherit') assert s.strip() == 'Inherited: import' def test_path(): plugin = TurboCheetah() plugin.search_path = [here] # Make sure we pick up filenames (basic test): s = plugin.render(values, template_file='simple1') assert s.strip() == 'This is a test: VV' # Make sure we pick up subdirectories: s = plugin.render(values, template_file='sub/master') assert s.strip() == 'sub1: 1' def test_search(): plugin = TurboCheetah() plugin.search_path = [os.path.join(here, 'sub'), os.path.join(here, 'sub2'), here] # Pick up from third entry: s = plugin.render(values, template_file='simple1') assert s.strip() == 'This is a test: VV' # Pick up from sub/master, non-ambiguous: s = plugin.render(values, template_file='master') assert s.strip() == 'sub1: 1' # Pick up from sub/page, inherit from sub/template: s = plugin.render(values, template_file='page') assert s.strip() == 'SUB: sub content' # Pick up from sub2/page_over, inherit from sub/template: s = plugin.render(values, template_file='page_over') assert s.strip() == 'SUB: override content' # Pick up from sub/page_template_over, inherit from # sub2/template_over: s = plugin.render(values, template_file='page_template_over') assert s.strip() == 'OVER: sub content' # Change page, make sure that undoes overrides: plugin.search_path = [os.path.join(here, 'sub'), here] s = plugin.render(values, template_file='page_over') assert s.strip() == 'SUB: sub content' def test_string(): # Make sure simple string evaluation works: plugin = TurboCheetah() s = plugin.render(values, template_string="""Hey $v""") assert s == "Hey VV" # Make sure a string can inherit from a file: plugin.search_path = [here] s = plugin.render(values, template_string="#extends inherit_from\ns value") assert s.strip() == 'inherit: s value' PKSMc4æTÓà à $turbocheetah/tests/test_template.pyc;ò °)ÞCc@shdkZdklZeiieƒZhdd<dd4€Œ¥¤i.turbocheetah/tests/__init__.pyPKSMc4Ž,Æ ››¤§.turbocheetah/tests/__init__.pycPK\O>4}Ûž ž #¤/turbocheetah/tests/test_template.pyPKSMc4æTÓà à $¤^9turbocheetah/tests/test_template.pycPKôcE