Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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))
Exemplo n.º 6
0
    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))
Exemplo n.º 7
0
    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)
Exemplo n.º 8
0
    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)
Exemplo n.º 9
0
    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)
Exemplo n.º 10
0
 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))
Exemplo n.º 11
0
    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)
Exemplo n.º 12
0
 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))
Exemplo n.º 13
0
    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)
Exemplo n.º 14
0
    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))
Exemplo n.º 15
0
    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))
Exemplo n.º 16
0
    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)
Exemplo n.º 17
0
    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)
Exemplo n.º 18
0
 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))
Exemplo n.º 19
0
 def __init__(self, env):
     Resolver.__init__(self, env)
     self.resolver = AssetResolver(None)
Exemplo n.º 20
0
 def __init__(self, env):
     Resolver.__init__(self, env)
     self.resolver = AssetResolver(None)
Exemplo n.º 21
0
 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))