本文整理汇总了Python中webassets.env.Resolver.search_for_source方法的典型用法代码示例。如果您正苦于以下问题:Python Resolver.search_for_source方法的具体用法?Python Resolver.search_for_source怎么用?Python Resolver.search_for_source使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webassets.env.Resolver
的用法示例。
在下文中一共展示了Resolver.search_for_source方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search_for_source
# 需要导入模块: from webassets.env import Resolver [as 别名]
# 或者: from webassets.env.Resolver import search_for_source [as 别名]
def search_for_source(self, item):
if self.env.load_path:
# Note: With only env.directory set, we don't go to default;
# Setting env.directory only makes the output directory fixed.
return Resolver.search_for_source(self, item)
# Look in correct blueprint's directory
directory, item = self.split_prefix(item)
try:
return self.consider_single_directory(directory, item)
except IOError:
# XXX: Hack to make the tests pass, which are written to not
# expect an IOError upon missing files. They need to be rewritten.
return path.normpath(path.join(directory, item))
示例2: search_for_source
# 需要导入模块: from webassets.env import Resolver [as 别名]
# 或者: from webassets.env.Resolver import search_for_source [as 别名]
def search_for_source(self, ctx, item):
if not self.use_staticfiles:
return Resolver.search_for_source(self, ctx, item)
if has_magic(item):
return list(self.glob_staticfiles(item))
else:
f = finders.find(item)
if f is not None:
return f
raise IOError(
"'%s' not found (using staticfiles finders)" % item)
示例3: search_for_source
# 需要导入模块: from webassets.env import Resolver [as 别名]
# 或者: from webassets.env.Resolver import search_for_source [as 别名]
def search_for_source(self, ctx, item):
# If a load_path is set, use it instead of the Flask static system.
#
# Note: With only env.directory set, we don't go to default;
# Setting env.directory only makes the output directory fixed.
if self.use_webassets_system_for_sources(ctx):
return Resolver.search_for_source(self, ctx, item)
# Look in correct blueprint's directory
directory, item, endpoint = self.split_prefix(ctx, item)
try:
return self.consider_single_directory(directory, item)
except IOError:
# XXX: Hack to make the tests pass, which are written to not
# expect an IOError upon missing files. They need to be rewritten.
return path.normpath(path.join(directory, item))
示例4: search_for_source
# 需要导入模块: from webassets.env import Resolver [as 别名]
# 或者: from webassets.env.Resolver import search_for_source [as 别名]
def search_for_source(self, ctx, item):
if not self.use_staticfiles:
return Resolver.search_for_source(self, ctx, item)
# We can't import too early because of unit tests
try:
from django.contrib.staticfiles import finders
except ImportError:
# Support pre-1.3 versions.
finders = None
# Use the staticfiles finders to determine the absolute path
if finders:
if has_magic(item):
return list(self.glob_staticfiles(item))
else:
f = finders.find(item)
if f is not None:
return f
raise IOError(
"'%s' not found (using staticfiles finders)" % item)