本文整理汇总了Python中webassets.env.Resolver.resolve_source_to_url方法的典型用法代码示例。如果您正苦于以下问题:Python Resolver.resolve_source_to_url方法的具体用法?Python Resolver.resolve_source_to_url怎么用?Python Resolver.resolve_source_to_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webassets.env.Resolver
的用法示例。
在下文中一共展示了Resolver.resolve_source_to_url方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resolve_source_to_url
# 需要导入模块: from webassets.env import Resolver [as 别名]
# 或者: from webassets.env.Resolver import resolve_source_to_url [as 别名]
def resolve_source_to_url(self, filepath, item):
if not self.use_staticfiles:
return Resolver.resolve_source_to_url(self, filepath, item)
# With staticfiles enabled, searching the url mappings, as the
# parent implementation does, will not help. Instead, we can
# assume that the url is the root url + the original relative
# item that was specified (and searched for using the finders).
return url_prefix_join(self.env.url, item)
示例2: resolve_source_to_url
# 需要导入模块: from webassets.env import Resolver [as 别名]
# 或者: from webassets.env.Resolver import resolve_source_to_url [as 别名]
def resolve_source_to_url(self, filepath, item):
if not self.use_staticfiles:
return Resolver.resolve_source_to_url(self, filepath, item)
# With staticfiles enabled, searching the url mappings, as the
# parent implementation does, will not help. Instead, we can
# assume that the url is the root url + the original relative
# item that was specified (and searched for using the finders).
# The only exception is when the relative url contains a wildcard.
# In that case we need to extract from the filepath the right part
# of the path and then join it with the root url.
if '*' in item:
path, _ = item.rsplit('*', 1)
item = '%s%s' % (path, filepath.rsplit(path, 1)[1])
return url_prefix_join(self.env.url, item)