本文整理汇总了Python中webassets.env.Resolver类的典型用法代码示例。如果您正苦于以下问题:Python Resolver类的具体用法?Python Resolver怎么用?Python Resolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Resolver类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resolve_output_to_url
def resolve_output_to_url(self, target):
# With a directory/url pair set, use it for output files.
if self.use_webassets_system_for_output:
return Resolver.resolve_output_to_url(self, target)
# Otherwise, behaves like generating urls to a source file.
return self.resolve_source_to_url(None, target)
示例2: resolve_output_to_url
def resolve_output_to_url(self, ctx, target):
# With a directory/url pair set, use it for output files.
if self.use_webassets_system_for_output(ctx):
return Resolver.resolve_output_to_url(self, ctx, target)
# Otherwise, behaves like all other flask URLs.
return self.convert_item_to_flask_url(ctx, target)
示例3: resolve_output_to_path
def resolve_output_to_path(self, ctx, target, bundle):
# If a directory/url pair is set, always use it for output files
if self.use_webassets_system_for_output(ctx):
return Resolver.resolve_output_to_path(self, ctx, target, bundle)
# Allow targeting blueprint static folders
directory, rel_path, endpoint = self.split_prefix(ctx, target)
return path.normpath(path.join(directory, rel_path))
示例4: resolve_source_to_url
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)
示例5: search_for_source
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)
示例6: search_for_source
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))
示例7: resolve_source_to_url
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)
示例8: search_for_source
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))
示例9: search_for_source
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)
示例10: resolve_output_to_path
def resolve_output_to_path(self, target, bundle):
if self.env.config.get('directory'):
return Resolver.resolve_output_to_path(self, target, bundle)
# Allow targeting blueprint static folders
directory, rel_path = self.split_prefix(target)
return path.normpath(path.join(directory, rel_path))
示例11: __init__
def __init__(self, env):
Resolver.__init__(self, env)
self.resolver = AssetResolver(None)