PKv¤9<“×2EGG-INFO/dependency_links.txt PKv¤9<£L¨UNNEGG-INFO/entry_points.txt [python.templating.engines] kid = turbokid.kidsupport:KidSupport PKY¤9<“×2EGG-INFO/not-zip-safe PKv¤9<¹ÎfQÚÚEGG-INFO/PKG-INFOMetadata-Version: 1.0 Name: TurboKid Version: 1.0.5 Summary: TurboGears plugin to support use of Kid templates Home-page: http://docs.turbogears.org/TurboKid Author: Christoph Zwerschke Author-email: cito@online.de License: MIT Download-URL: http://pypi.python.org/pypi/TurboKid Description: UNKNOWN Keywords: python.templating.engines,turbogears Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Framework :: TurboGears Classifier: Environment :: Web Environment :: Buffet Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: License :: OSI Approved :: MIT License Classifier: Topic :: Software Development :: Libraries :: Python Modules PKv¤9<·"å EGG-INFO/requires.txtkid >= 0.9.6PKv¤9<*¤‡ffEGG-INFO/SOURCES.txtREADME.txt setup.cfg setup.py TurboKid.egg-info/PKG-INFO TurboKid.egg-info/SOURCES.txt TurboKid.egg-info/dependency_links.txt TurboKid.egg-info/entry_points.txt TurboKid.egg-info/not-zip-safe TurboKid.egg-info/requires.txt TurboKid.egg-info/top_level.txt turbokid/__init__.py turbokid/kidsupport.py turbokid/tests/__init__.py turbokid/tests/a.kid turbokid/tests/b.kid turbokid/tests/c.kid turbokid/tests/d.kid turbokid/tests/e.kid turbokid/tests/extra.kid turbokid/tests/fruits.kid turbokid/tests/hello.kid turbokid/tests/master.kid turbokid/tests/simple.kid turbokid/tests/site.kid turbokid/tests/test_template.pyPKv¤9<\Q:À EGG-INFO/top_level.txtturbokid PK ¤9 ttime if reload_modules: ttime = mtime # check the status of all base modules for module in _get_extended_modules(tclass): ctime = ct.get(module) try: mtime = stat(sys.modules[module].__file__).st_mtime except KeyError: if ctime is None: mtime = ttime else: mtime = ctime if ctime is None or mtime > ctime: # base template is new or has changed reload_modules = True if mtime > ttime: # base template has changed reload_template = True ttime = mtime if reload_modules: # we need to recompile the template log.debug('Recompiling template for %s' % classname) # This may have been also loaded as base from other templates # by the Kid importer using a hashed module name, # so we first invalidate the module loaded under that name. temp_name = kid.importer.get_template_name(None, tfile) if temp_name != classname and temp_name in sys.modules: sys.modules[temp_name] = kid.load_template(tfile, temp_name) # then we invalidate the template under its real name del sys.modules[classname] ct[classname] = ttime # now we reload and recompile the template mod = _compile_template( package, basename, tfile, classname) else: # No need to recompile the template or its bases, # just reuse the existing modules. mod = __import__(classname, dict(), dict(), [basename]) else: # This means that in sys.modules there isn't yet the # compiled template, let's compile it along with its bases # and store in self.compiled_templates their mtime. log.debug('Compiling template for %s' % classname) mod = _compile_template(package, basename, tfile, classname) tclass = mod.Template ttime = stat(sys.modules[classname].__file__).st_mtime for module in _get_extended_modules(tclass): mtime = stat(sys.modules[module].__file__).st_mtime ct[module] = mtime if mtime > ttime: ttime = mtime # store max of mtimes of template and all of its bases ct[classname] = ttime finally: self.compile_lock.release() tempclass = mod.Template tempclass.serializer = self.serializer return tempclass def render(self, info, format='html', fragment=False, template=None): """Renders data in the desired format. @param info: the data itself @type info: dict @param format: Kid output method and format, separated by whitespace @type format: string @param fragment: passed through to tell the template if only a fragment of a page is desired @type fragment: bool @param template: the name of the template to use @type template: string """ if isinstance(template, type): tclass = template else: tclass = self.load_template(template) log.debug('Applying template %s' % (tclass.__module__)) data = dict() if self.get_extra_vars: data.update(self.get_extra_vars()) if info: data.update(info) template = tclass(**data) if self.assume_encoding: template.assume_encoding = self.assume_encoding if self.filter and self.filter not in template._filters: template._filters.append(self.filter) if isinstance(format, str): if format.endswith('-straight'): # support old notation 'html-straight' instead 'html straight' format = (format[:-9], format[-8:]) else: format = format.split() elif not isinstance(format, (tuple, list)): format = (format,) if len(format) < 2: output, format = format[0], None else: output, format = format[:2] return template.serialize(encoding=self.encoding, fragment=fragment, output=output, format=format) def transform(self, info, template): if isinstance(template, type): tclass = template else: tclass = self.load_template(template) data = dict() if self.get_extra_vars: data.update(self.get_extra_vars()) data.update(info) template = tclass(**data) if self.filter and self.filter not in template._filters: template._filters.append(self.filter) return kid.ElementStream(template.transform()).expand() PKv¤9<ƒ¸ÿâ˜"˜"turbokid/kidsupport.pyc;ò íñ]Kc@s‘dZdkZdklZdklZdklZdkl Z dk l Z dk Z e dƒZ d„Zd „Zd efd „ƒYZdS( sTemplate support for KidN(sstat(scount(sRLock(s getLogger(sresource_filenamesturbokid.kidsupportcCs4ti|d|ƒ}tti|||ƒ|SdS(Nsname( skids load_templatestfiles classnamesmodssetattrssyssmodulesspackagesbasename(spackagesbasenamestfiles classnamesmod((s,build\bdist.win32\egg\turbokid\kidsupport.pys_compile_templatescCsyddg}g}x\|iD]Q}|i|jo|i|iƒnt|dƒo|it |ƒƒqqW|SdS(sRecursively builds and returns a list containing all modules of the templates extended from the template passed as parameter.s __builtin__skids __bases__N( sexcluded_moduless modules_liststemplates __bases__s base_templates __module__sappendshasattrsextends_get_extended_modules(stemplatesexcluded_moduless modules_lists base_template((s,build\bdist.win32\egg\turbokid\kidsupport.pys_get_extended_moduless  s KidSupportcBsltZdZdZZeZeƒZe e d„Z d„Z e e ed„Z dee d„Z d„ZRS( Ns.kidsutf-8cCs|tjo tƒ}n||_||_|idtiƒ|_|idti ƒ|_ |idti ƒ|_ |i ot ƒ|_ nt id|i ƒ|_t|_|idtƒ|_|idtƒo+|idƒ}t|ƒ o t}q nt}||_h|_dS(Nskid.assume_encodings kid.encodingskid.precompiledsencodingskid.sitetemplateskid.i18n.run_template_filterskid.i18n_filter(soptionssNonesdictsselfsextra_vars_funcsget_extra_varssgets KidSupportsassume_encodingsencodings precompiledsRLocks compile_lockskidsHTMLSerializers serializers sitetemplatesstnamesFalsestemplate_filterscallablesfilterscompiled_templates(sselfsextra_vars_funcsoptionsstemplate_filter((s,build\bdist.win32\egg\turbokid\kidsupport.pys__init__+s&       cCs`t|tƒ otdƒ‚n|iiƒ}ti |dd|ƒi }|i |_ |SdS(NsYou must pass a template stringsnamesKidTemplateFromString-%d( s isinstancestemplate_strings basestrings ValueErrorsselfsstring_template_serialsnextsserialskids load_templatesTemplates tempclasss serializer(sselfstemplate_strings tempclasssserial((s,build\bdist.win32\egg\turbokid\kidsupport.pysload_template_stringDs  cCs|tj o|i|ƒSn|tjotdƒ‚n| om|io|i p|it i joA|i |idt ƒt i |it i dCheck: My value!

' def test_kid(): """Make sure kid directives work.""" engine = get_engine() values = {'title': 'Fruit Test', 'fruits': 'apple orange kiwi M&M'.split()} s = engine.render(values, template='turbokid.tests.fruits') assert s == """ Fruit Test

These are some of my favorite fruits:

""" def test_not_found(): """Make sure undefined variables do not go unnoticed.""" engine = get_engine() try: s = engine.render(None, template='turbokid.tests.simple') except NameError: pass except Exception, e: assert False, 'Undefined name raised wrong exception (%s)' % str(e) else: assert s.splitlines()[-1] != 'Check:', 'Undefined name was ignored' assert False, 'Undefined name did not raise any exception' def test_extra(): """Make sure extra variables work.""" engine = get_engine() s = engine.render(None, template='turbokid.tests.extra') s = s.splitlines()[-1] assert s == '

Another check: Extra value!

' def test_unicode(): """Make sure unicode values work.""" engine = get_engine() s = engine.render({'v': u"K\xe4se!"}, template='turbokid.tests.simple') assert isinstance(s, str) s = s.splitlines()[-1] assert s == u'

Check: K\xe4se!

'.encode('utf-8') def test_extend(): """Make sure one template can inherit from another.""" engine = get_engine() values = {'name': 'World', 'flash': 'flash', 'header': 'head', 'footer': 'foot'} s = engine.render(values, template='turbokid.tests.hello') assert s == """ Welcome to TurboKid
top
head
flash

Hello, World!

foot
bottom
""" def test_template_string(): """Check rendering of template strings.""" engine = get_engine() t = engine.load_template(values, template_string='

String: $v

') s = t(**values).serialize().splitlines()[-1] assert s == '

String: My value!

' def load_and_render(engine, template, **kwargs): """Auxiliary function for loading and rendering a template.""" template = engine.load_template('turbokid.tests.%s' % template) engine.render(kwargs, template=template) return template def touch(template, times=None): """Auxiliary function for changing the modification time of a template.""" fname = sys.modules['turbokid.tests.%s' % template].__file__ fhandle = file(fname, 'a') try: for n in range(6): mtime = os.stat(fname).st_mtime os.utime(fname, times) if times or os.stat(fname).st_mtime != mtime: break time.sleep(0.5) else: raise OSError("Could not change modification time of %s." % fname) finally: fhandle.close() def test_use_cache(): """Make sure that load_template returns cached templates if there are no changes.""" engine = get_engine() a1 = load_and_render(engine, 'a') b1 = load_and_render(engine, 'b') a2 = load_and_render(engine, 'a') b2 = load_and_render(engine, 'b') assert a1 is a2 assert b1 is b2 def test_template_reloads(): """Make sure that templates reloads when it was changed.""" engine = get_engine() a1 = load_and_render(engine, 'a') b1 = load_and_render(engine, 'b') touch('a') a2 = load_and_render(engine, 'a') b2 = load_and_render(engine, 'b') assert a1 is not a2 assert b1 is not b2 def test_relations_1(): """Make sure that template reloads in relations 1.""" engine = get_engine() a1 = load_and_render(engine, 'a') b1 = load_and_render(engine, 'b') c1 = load_and_render(engine, 'c') d1 = load_and_render(engine, 'd') touch('a') a2 = load_and_render(engine, 'a') b2 = load_and_render(engine, 'b') c2 = load_and_render(engine, 'c') d2 = load_and_render(engine, 'd') assert a1 is not a2 assert b1 is not b2 assert c1 is not c2 assert d1 is not d2 def test_relations_2(): """Make sure that template reloads in relations 2.""" engine = get_engine() a1 = load_and_render(engine, 'a') b1 = load_and_render(engine, 'b') c1 = load_and_render(engine, 'c') d1 = load_and_render(engine, 'd') touch('a') c2 = load_and_render(engine, 'c') a2 = load_and_render(engine, 'a') d2 = load_and_render(engine, 'd') b2 = load_and_render(engine, 'b') assert a1 is not a2 assert b1 is not b2 assert c1 is not c2 assert d1 is not d2 def test_relations_3(): """Make sure that template reloads in relations 3.""" engine = get_engine() tmpls = 'abcde' for t1 in tmpls: for t2 in tmpls: load_and_render(engine, t2) touch(t1) for t2 in tmpls: load_and_render(engine, t2) def test_relations_4(): """Make sure that template reloads in relations 4.""" engine = get_engine() tmpls = 'cebae' # use random order for t1 in tmpls: for t2 in tmpls: load_and_render(engine, t2) touch(t1) for t2 in tmpls: load_and_render(engine, t2) PKv¤9Check: My value!

N(s get_enginesenginesrendersvaluessss splitlinessAssertionError(senginess((s5build\bdist.win32\egg\turbokid\tests\test_template.pys test_simple$s  cCsTtƒ}hdd<ddiƒ<}|i|ddƒ}|djpt‚dS( sMake sure kid directives work.stitles Fruit Testsfruitssapple orange kiwi M&Mstemplatesturbokid.tests.fruitssâ Fruit Test

These are some of my favorite fruits:

  • I like apples
  • I like oranges
  • I like kiwis
  • I like M&Ms
N(s get_enginesenginessplitsvaluessrendersssAssertionError(senginesssvalues((s5build\bdist.win32\egg\turbokid\tests\test_template.pystest_kid+s  cCstƒ}y|itddƒ}WnBtj onctj o$}tpt dt |ƒ‚n4X|i ƒddjp t d‚tp t d‚dS( s2Make sure undefined variables do not go unnoticed.stemplatesturbokid.tests.simples*Undefined name raised wrong exception (%s)iÿÿÿÿsCheck:sUndefined name was ignoreds*Undefined name did not raise any exceptionN( s get_enginesenginesrendersNonesss NameErrors ExceptionsesFalsesAssertionErrorsstrs splitlines(senginesess((s5build\bdist.win32\egg\turbokid\tests\test_template.pystest_not_foundHs  !cCsFtƒ}|itddƒ}|iƒd}|djpt‚dS(sMake sure extra variables work.stemplatesturbokid.tests.extraiÿÿÿÿs"

Another check: Extra value!

N(s get_enginesenginesrendersNonesss splitlinessAssertionError(senginess((s5build\bdist.win32\egg\turbokid\tests\test_template.pys test_extraUs  cCsotƒ}|ihddCheck: Käse!

sutf-8N( s get_enginesenginesrendersss isinstancesstrsAssertionErrors splitlinessencode(senginess((s5build\bdist.win32\egg\turbokid\tests\test_template.pys test_unicode\s  cCs`tƒ}hdd<dd<dd<dd<}|i|dd ƒ}|d jpt‚d S( s0Make sure one template can inherit from another.snamesWorldsflashsheadersheadsfootersfootstemplatesturbokid.tests.hellosÙ Welcome to TurboKid
top
head
flash

Hello, World!

foot
bottom
N(s get_enginesenginesvaluessrendersssAssertionError(senginesssvalues((s5build\bdist.win32\egg\turbokid\tests\test_template.pys test_extendds  *cCsRtƒ}|itddƒ}|tiƒiƒd}|djpt‚dS(s$Check rendering of template strings.stemplate_strings

String: $v

iÿÿÿÿs

String: My value!

N( s get_enginesengines load_templatesvaluessts serializes splitlinessssAssertionError(senginessst((s5build\bdist.win32\egg\turbokid\tests\test_template.pystest_template_string~s  cKs.|id|ƒ}|i|d|ƒ|SdS(s8Auxiliary function for loading and rendering a template.sturbokid.tests.%sstemplateN(sengines load_templatestemplatesrenderskwargs(senginestemplateskwargs((s5build\bdist.win32\egg\turbokid\tests\test_template.pysload_and_render…scCs´tid|i}t|dƒ}zxxtdƒD]Z}t i |ƒi }t i ||ƒ|pt i |ƒi |joPntidƒq3Wtd|ƒ‚Wd|iƒXdS(sDAuxiliary function for changing the modification time of a template.sturbokid.tests.%ssaif0.5s)Could not change modification time of %s.N(ssyssmodulesstemplates__file__sfnamesfilesfhandlesrangesnsossstatsst_mtimesmtimesutimestimesstimessleepsOSErrorsclose(stemplatestimessfhandlesfnamesmtimesn((s5build\bdist.win32\egg\turbokid\tests\test_template.pystouch‹s  cCsqtƒ}t|dƒ}t|dƒ}t|dƒ}t|dƒ}||jpt‚||jpt‚dS(sNMake sure that load_template returns cached templates if there are no changes.sasbN(s get_enginesenginesload_and_rendersa1sb1sa2sb2sAssertionError(senginesb2sa1sa2sb1((s5build\bdist.win32\egg\turbokid\tests\test_template.pystest_use_cache›s cCs{tƒ}t|dƒ}t|dƒ}tdƒt|dƒ}t|dƒ}||j pt‚||j pt‚dS(s5Make sure that templates reloads when it was changed.sasbN( s get_enginesenginesload_and_rendersa1sb1stouchsa2sb2sAssertionError(senginesb2sa1sa2sb1((s5build\bdist.win32\egg\turbokid\tests\test_template.pystest_template_reloads¥s  c Csßtƒ}t|dƒ}t|dƒ}t|dƒ}t|dƒ}tdƒt|dƒ}t|dƒ}t|dƒ}t|dƒ}||j pt ‚||j pt ‚||j pt ‚||j pt ‚dS(s/Make sure that template reloads in relations 1.sasbscsdN( s get_enginesenginesload_and_rendersa1sb1sc1sd1stouchsa2sb2sc2sd2sAssertionError( senginesb2sa1sa2sb1sc2sc1sd2sd1((s5build\bdist.win32\egg\turbokid\tests\test_template.pystest_relations_1°s  c Csßtƒ}t|dƒ}t|dƒ}t|dƒ}t|dƒ}tdƒt|dƒ}t|dƒ}t|dƒ}t|dƒ}||j pt ‚||j pt ‚||j pt ‚||j pt ‚dS(s/Make sure that template reloads in relations 2.sasbscsdN( s get_enginesenginesload_and_rendersa1sb1sc1sd1stouchsc2sa2sd2sb2sAssertionError( senginesb2sa1sa2sb1sc2sc1sd2sd1((s5build\bdist.win32\egg\turbokid\tests\test_template.pystest_relations_2Ás  cCsjtƒ}d}xT|D]L}x|D]}t||ƒq#Wt|ƒx|D]}t||ƒqKWqWdS(s/Make sure that template reloads in relations 3.sabcdeN(s get_enginesenginestmplsst1st2sload_and_renderstouch(senginest2st1stmpls((s5build\bdist.win32\egg\turbokid\tests\test_template.pystest_relations_3Òs  cCsjtƒ}d}xT|D]L}x|D]}t||ƒq#Wt|ƒx|D]}t||ƒqKWqWdS(s/Make sure that template reloads in relations 4.scebaeN(s get_enginesenginestmplsst1st2sload_and_renderstouch(senginest2st1stmpls((s5build\bdist.win32\egg\turbokid\tests\test_template.pystest_relations_4Ýs  (s__doc__sosssysstimesturbokids KidSupportsdictsvaluess extra_varssFalsesoptionss get_engines test_optionss test_simplestest_kidstest_not_founds test_extras test_unicodes test_extendstest_template_stringsload_and_rendersNonestouchstest_use_cachestest_template_reloadsstest_relations_1stest_relations_2stest_relations_3stest_relations_4(stest_not_foundstest_use_cachestest_template_reloadssload_and_renderstouchstest_template_stringstest_relations_4s test_extendstest_relations_2stest_relations_1stest_kids test_optionss get_enginessyss test_extras test_unicodestest_relations_3s KidSupports extra_varss test_simplesvaluesstimesossoptions((s5build\bdist.win32\egg\turbokid\tests\test_template.pys?s0     3            PK ¤9<ðUturbokid/tests/__init__.py# turbokid.tests PKv¤9<\¡£@€€turbokid/tests/__init__.pyc;ò íñ]Kc@sdS(N((((s0build\bdist.win32\egg\turbokid\tests\__init__.pys?sPKv¤9<“×2¶EGG-INFO/dependency_links.txtPKv¤9<£L¨UNN¶<EGG-INFO/entry_points.txtPKY¤9<“×2¶ÁEGG-INFO/not-zip-safePKv¤9<¹ÎfQÚÚ¶õEGG-INFO/PKG-INFOPKv¤9<·"å ¶þEGG-INFO/requires.txtPKv¤9<*¤‡ff¶=EGG-INFO/SOURCES.txtPKv¤9<\Q:À ¶ÕEGG-INFO/top_level.txtPK ¤9