本文整理汇总了Python中pyramid.path.AssetResolver.exists方法的典型用法代码示例。如果您正苦于以下问题:Python AssetResolver.exists方法的具体用法?Python AssetResolver.exists怎么用?Python AssetResolver.exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.path.AssetResolver
的用法示例。
在下文中一共展示了AssetResolver.exists方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_template
# 需要导入模块: from pyramid.path import AssetResolver [as 别名]
# 或者: from pyramid.path.AssetResolver import exists [as 别名]
def get_template(self, uri):
"""Fetch a template from the cache, or check the filesystem
for it
In addition to the basic filesystem lookup, this subclass will
use pkg_resource to load a file using the asset
specification syntax.
"""
isabs = os.path.isabs(uri)
if (not isabs) and (':' in uri):
# Windows can't cope with colons in filenames, so we replace the
# colon with a dollar sign in the filename mako uses to actually
# store the generated python code in the mako module_directory or
# in the temporary location of mako's modules
adjusted = uri.replace(':', '$')
try:
if self.filesystem_checks:
return self._check(adjusted, self._collection[adjusted])
else:
return self._collection[adjusted]
except KeyError:
asset = AssetResolver().resolve(uri)
if asset.exists():
srcfile = asset.abspath()
return self._load(srcfile, adjusted)
raise TopLevelLookupException(
"Can not locate template for uri %r" % uri)
try:
return TemplateLookup.get_template(self, uri)
except TemplateLookupException:
if isabs:
return self._load(uri, uri)
else:
raise