本文整理汇总了Python中template.Template.find方法的典型用法代码示例。如果您正苦于以下问题:Python Template.find方法的具体用法?Python Template.find怎么用?Python Template.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类template.Template
的用法示例。
在下文中一共展示了Template.find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCompile
# 需要导入模块: from template import Template [as 别名]
# 或者: from template.Template import find [as 别名]
def testCompile(self):
ttcfg = { "POST_CHOMP": 1,
"INCLUDE_PATH": "test/src",
"COMPILE_EXT": ".ttc" }
# Check that compiled template files exist.
compiled = "test/src/foo.ttc"
self.assert_(os.path.exists(compiled))
self.assert_(os.path.exists("test/src/complex.ttc"))
# Ensure template metadata is saved in compiled file.
output = Template(ttcfg).process("baz", { "showname": 1 })
self.assertNotEqual(-1, output.find("name: baz"))
# We're going to hack on the foo.ttc file to change some key text.
# This way we can tell that the template was loaded from the compiled
# version and not the source.
fh = open(compiled, "r+")
stat = os.fstat(fh.fileno())
foo = fh.read()
fh.seek(0)
fh.write(foo.replace("the foo file", "the hacked foo file"))
fh.close()
os.utime(compiled, (stat.st_atime, stat.st_mtime))
self.Expect(DATA, ttcfg)