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)
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)
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))
def resolve_source_to_url(self, ctx, filepath, item): if not self.use_staticfiles: return Resolver.resolve_source_to_url(self, ctx, 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(ctx.url, item)
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)
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)
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))
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)
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)
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))
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)
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)
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))
def __init__(self, env): Resolver.__init__(self, env) self.resolver = AssetResolver(None)