当前位置: 首页>>代码示例>>Python>>正文


Python Packager.package_for方法代码示例

本文整理汇总了Python中pipeline.packager.Packager.package_for方法的典型用法代码示例。如果您正苦于以下问题:Python Packager.package_for方法的具体用法?Python Packager.package_for怎么用?Python Packager.package_for使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pipeline.packager.Packager的用法示例。


在下文中一共展示了Packager.package_for方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post_process

# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import package_for [as 别名]
    def post_process(self, paths, dry_run=False, **options):
        if dry_run:
            return

        packager = Packager(storage=self)
        for _abs_path, rel_path in paths:
            files_to_process = OrderedDict()
            files_to_process[rel_path] = (self, rel_path)
            for package_name in packager.packages['css']:
                package = packager.package_for('css', package_name)
                output_file = package.output_filename

                if rel_path in package.paths:
                    if self.packing:
                        packager.pack_stylesheets(package)
                    files_to_process[output_file] = (self, output_file)
                    yield output_file, output_file, True
            for package_name in packager.packages['js']:
                package = packager.package_for('js', package_name)
                output_file = package.output_filename
                if rel_path in package.paths:
                    if self.packing:
                        packager.pack_javascripts(package)
                    files_to_process[output_file] = (self, output_file)
                    yield output_file, output_file, True

            super_class = super(PipelineMixin, self)

            if hasattr(super_class, 'post_process'):
                for name, hashed_name, processed in super_class.post_process(
                        files_to_process.copy(), dry_run, **options):
                    yield name, hashed_name, processed
开发者ID:pfertyk,项目名称:django-deploy-utils,代码行数:34,代码来源:storage.py

示例2: post_process

# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import package_for [as 别名]
    def post_process(self, paths, dry_run=False, **options):
        if dry_run:
            return []

        from pipeline.packager import Packager
        packager = Packager(storage=self)
        for package_name in packager.packages['css']:
            package = packager.package_for('css', package_name)
            output_file = package.output_filename
            if self.packing:
                packager.pack_stylesheets(package)
            paths[output_file] = (self, output_file)
        for package_name in packager.packages['js']:
            package = packager.package_for('js', package_name)
            output_file = package.output_filename
            if self.packing:
                packager.pack_javascripts(package)
            paths[output_file] = (self, output_file)

        super_class = super(PipelineMixin, self)
        if hasattr(super_class, 'post_process'):
            return super_class.post_process(paths, dry_run, **options)

        return [
            (path, path, True)
            for path in paths
        ]
开发者ID:edwinlunando,项目名称:django-pipeline,代码行数:29,代码来源:storage.py

示例3: post_process

# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import package_for [as 别名]
    def post_process(self, paths, dry_run=False, **options):
        if dry_run:
            return []

        from pipeline.packager import Packager
        packager = Packager(storage=self)
        for package_name in packager.packages['css']:
            package = packager.package_for('css', package_name)
            if self.packing:
                paths_written = packager.pack_stylesheets(package)
                for path in paths_written:
                    paths[path] = (self, path)
            else:
                # TODO: bcooksey 5/15/13. Not sure why we pretend we packed if packing is false...will this mess up source maps
                output_file = package.output_filename
                paths[output_file] = (self, output_file)
        for package_name in packager.packages['js']:
            package = packager.package_for('js', package_name)
            if self.packing:
                paths_written = packager.pack_javascripts(package)
                for path in paths_written:
                    paths[path] = (self, path)
            else:
                # TODO: bcooksey 5/15/13. Not sure why we pretend we packed if packing is false...will this mess up source maps
                output_file = package.output_filename
                paths[output_file] = (self, output_file)

        super_class = super(PipelineMixin, self)
        if hasattr(super_class, 'post_process'):
            return super_class.post_process(paths, dry_run, **options)

        return [
            (path, path, True)
            for path in paths
        ]
开发者ID:zapier,项目名称:django-pipeline,代码行数:37,代码来源:storage.py

示例4: post_process

# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import package_for [as 别名]
    def post_process(self, paths, dry_run=False, **options):
        if dry_run:
            return

        from pipeline.packager import Packager
        packager = Packager(storage=self)
        for package_name in packager.packages['css']:
            package = packager.package_for('css', package_name)
            output_file = package.output_filename
            if self.packing:
                packager.pack_stylesheets(package)
            paths[output_file] = (self, output_file)
            yield output_file, output_file, True
        for package_name in packager.packages['js']:
            package = packager.package_for('js', package_name)
            output_file = package.output_filename
            if self.packing:
                packager.pack_javascripts(package)
            paths[output_file] = (self, output_file)
            yield output_file, output_file, True

        super_class = super(PipelineMixin, self)
        if hasattr(super_class, 'post_process'):
            for name, hashed_name, processed in super_class.post_process(paths.copy(), dry_run, **options):
                yield name, hashed_name, processed
开发者ID:newscred,项目名称:django-pipeline,代码行数:27,代码来源:storage.py

示例5: handle

# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import package_for [as 别名]
    def handle(self, *args, **options):
        from pipeline.packager import Packager

        force = options.get('force', False)
        verbose = int(options.get('verbosity', 1)) >= 2
        sync = options.get('dry_run', True)

        packager = Packager(verbose=verbose)
        for package_name in packager.packages['css']:
            if args and package_name not in args:
                continue
            package = packager.package_for('css', package_name)
            if verbose:
                print
                message = "CSS Group '%s'" % package_name
                print message
                print len(message) * '-'
            packager.pack_stylesheets(package, sync=sync, force=force)

        for package_name in packager.packages['js']:
            if args and package_name not in args:
                continue
            package = packager.package_for('js', package_name)
            if verbose:
                print
                message = "JS Group '%s'" % package_name
                print message
                print len(message) * '-'
            packager.pack_javascripts(package, sync=sync, force=force)
开发者ID:UniIsland,项目名称:django-pipeline,代码行数:31,代码来源:synccompress.py

示例6: post_process

# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import package_for [as 别名]
    def post_process(self, paths, dry_run=False, **options):
        """
        This post_process hook is used to package all themed assets.
        """
        if dry_run:
            return
        themes = get_themes()

        for theme in themes:
            css_packages = self.get_themed_packages(theme.theme_dir_name, settings.PIPELINE_CSS)
            js_packages = self.get_themed_packages(theme.theme_dir_name, settings.PIPELINE_JS)

            from pipeline.packager import Packager
            packager = Packager(storage=self, css_packages=css_packages, js_packages=js_packages)
            for package_name in packager.packages['css']:
                package = packager.package_for('css', package_name)
                output_file = package.output_filename
                if self.packing:
                    packager.pack_stylesheets(package)
                paths[output_file] = (self, output_file)
                yield output_file, output_file, True
            for package_name in packager.packages['js']:
                package = packager.package_for('js', package_name)
                output_file = package.output_filename
                if self.packing:
                    packager.pack_javascripts(package)
                paths[output_file] = (self, output_file)
                yield output_file, output_file, True

        super_class = super(ThemePipelineMixin, self)
        if hasattr(super_class, 'post_process'):
            for name, hashed_name, processed in super_class.post_process(paths.copy(), dry_run, **options):
                yield name, hashed_name, processed
开发者ID:CraftAcademy,项目名称:edx-platform,代码行数:35,代码来源:storage.py

示例7: PipelineManifest

# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import package_for [as 别名]
class PipelineManifest(Manifest):
    def __init__(self):
        self.packager = Packager()
        self.packages = self.collect_packages()
        self.finder = DefaultStorageFinder()

    def collect_packages(self):
        packages = []
        for package_name in self.packager.packages['css']:
            package = self.packager.package_for('css', package_name)
            if package.manifest:
                packages.append(package)
        for package_name in self.packager.packages['js']:
            package = self.packager.package_for('js', package_name)
            if package.manifest:
                packages.append(package)
        return packages

    def cache(self):
        ignore_patterns = getattr(settings, "STATICFILES_IGNORE_PATTERNS", None)
        
        if settings.PIPELINE:
            for package in self.packages:
                yield str(self.packager.individual_url(package.output_filename))
        else:
            for package in self.packages:
                for path in self.packager.compile(package.paths):
                    yield str(self.packager.individual_url(path))
        for path in self.finder.list(ignore_patterns):
            yield str(self.packager.individual_url(path))
开发者ID:ZibMedia,项目名称:django-pipeline,代码行数:32,代码来源:manifest.py

示例8: PipelineManifest

# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import package_for [as 别名]
class PipelineManifest(Manifest):
    def __init__(self):
        self.packager = Packager()
        self.packages = self.collect_packages()
        self.finder = DefaultStorageFinder()

    def collect_packages(self):
        packages = []
        for package_name in self.packager.packages["css"]:
            package = self.packager.package_for("css", package_name)
            if package.manifest:
                packages.append(package)
        for package_name in self.packager.packages["js"]:
            package = self.packager.package_for("js", package_name)
            if package.manifest:
                packages.append(package)
        return packages

    def cache(self):
        if settings.PIPELINE:
            for package in self.packages:
                yield str(self.packager.individual_url(package.output_filename))
        else:
            for package in self.packages:
                for path in self.packager.compile(package.paths):
                    yield str(self.packager.individual_url(path))
        for path in self.finder.list():
            yield str(self.packager.individual_url(path))
开发者ID:GbalsaC,项目名称:bitnamiP,代码行数:30,代码来源:manifest.py

示例9: test_package_for

# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import package_for [as 别名]
 def test_package_for(self):
     packager = Packager()
     packager.packages["js"] = packager.create_packages(
         {"application": {"source_filenames": ("js/application.js",), "output_filename": "application.r?.js"}}
     )
     try:
         packager.package_for("js", "application")
     except PackageNotFound:
         self.fail()
     try:
         packager.package_for("js", "broken")
         self.fail()
     except PackageNotFound:
         pass
开发者ID:UniIsland,项目名称:django-pipeline,代码行数:16,代码来源:packager.py

示例10: PipelineManifest

# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import package_for [as 别名]
class PipelineManifest(Manifest):
    def __init__(self):
        self.packager = Packager()
        self.packages = self.collect_packages()
        self.finders = get_finders()
        self.package_files = self.get_package_files()

    def get_package_files(self):
        files = list()
        for package in self.packages:
            files.append(package.output_filename)
            for path in self.packager.compile(package.paths):
                files.append(path)

        return files     

    def collect_packages(self):
        packages = []
        for package_name in self.packager.packages['css']:
            package = self.packager.package_for('css', package_name)
            if package.manifest:
                packages.append(package)
        for package_name in self.packager.packages['js']:
            package = self.packager.package_for('js', package_name)
            if package.manifest:
                packages.append(package)
        return packages

    def cache(self):
        ignore_patterns = getattr(settings, "STATICFILES_IGNORE_PATTERNS", None)
        
        if PIPELINE:
            for package in self.packages:
                yield str(self.packager.individual_url(package.output_filename))
        else:
            for package in self.packages:
                for path in self.packager.compile(package.paths):
                    yield str(self.packager.individual_url(path))

        for finder in self.finders:
            for path, storage in finder.list(ignore_patterns):
                # Prefix the relative path if the source storage contains it
                if getattr(storage, 'prefix', None):
                    prefixed_path = os.path.join(storage.prefix, path)
                else:
                    prefixed_path = path

                # Dont add any doubles
                if prefixed_path not in self.package_files:
                    yield str(self.packager.individual_url(prefixed_path))
开发者ID:reshift,项目名称:django-pipeline,代码行数:52,代码来源:manifest.py

示例11: compressed_css

# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import package_for [as 别名]
def compressed_css(ctx, name):
    package = settings.PIPELINE_CSS.get(name, {})
    if package:
        package = {name: package}

    packager = Packager(css_packages=package, js_packages={})

    try:
        package = packager.package_for('css', name)
    except PackageNotFound:
        return ""

    def _render_css(path):
        template_name = package.template_name or "pipeline/css.jinja"

        context = package.extra_context
        context.update({
            'type': guess_type(path, 'text/css'),
            'url': staticfiles_storage.url(path)
        })

        template = ctx.environment.get_template(template_name)
        return template.render(context)

    if settings.PIPELINE_ENABLED:
        return _render_css(package.output_filename)
    else:
        default_collector.collect()
        paths = packager.compile(package.paths)
        tags = [_render_css(path) for path in paths]
        return '\n'.join(tags)
开发者ID:AsymmetricVentures,项目名称:django-jinja,代码行数:33,代码来源:_pipeline.py

示例12: CompressedCSSNode

# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import package_for [as 别名]
class CompressedCSSNode(template.Node):
    def __init__(self, name):
        self.name = name

    def render(self, context):
        package_name = template.Variable(self.name).resolve(context)
        package = settings.PIPELINE_CSS.get(package_name, {})
        if package:
            package = {package_name: package}
        self.packager = Packager(css_packages=package, js_packages={})

        try:
            package = self.packager.package_for('css', package_name)
        except PackageNotFound:
            return ''  # fail silently, do not return anything if an invalid group is specified

        if settings.PIPELINE:
            return self.render_css(package, package.output_filename)
        else:
            paths = self.packager.compile(package.paths)
            return self.render_individual(package, paths)

    def render_css(self, package, path):
        template_name = package.template_name or "pipeline/css.html"
        context = package.extra_context
        context.update({
            'url': staticfiles_storage.url(path)
        })
        return render_to_string(template_name, context)

    def render_individual(self, package, paths):
        tags = [self.render_css(package, path) for path in paths]
        return '\n'.join(tags)
开发者ID:trapeze,项目名称:django-pipeline,代码行数:35,代码来源:compressed.py

示例13: compressed_css

# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import package_for [as 别名]
def compressed_css(name):
    package = settings.PIPELINE_CSS.get(name, {})
    if package:
        package = {name: package}

    packager = Packager(css_packages=package, js_packages={})

    try:
        package = packager.package_for('css', name)
    except PackageNotFound:
        return ""

    def _render_css(path):
        template_name = package.template_name or "pipeline/css.jinja"

        context = package.extra_context
        context.update({
            'type': guess_type(path, 'text/css'),
            'url': staticfiles_storage.url(path)
        })

        return render_to_string(template_name, context)

    if not settings.DEBUG:
        return _render_css(package.output_filename)

    paths = packager.compile(package.paths)
    tags = [_render_css(path) for path in paths]

    return '\n'.join(tags)
开发者ID:andreif,项目名称:django-jinja,代码行数:32,代码来源:_pipeline.py

示例14: CommonNode

# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import package_for [as 别名]
class CommonNode(template.Node):
    def __init__(self, name):
        self.name = name

    def render(self, context):
        package_name = template.Variable(self.name).resolve(context)
        package = self.packages.get(package_name, {})
        if package:
            package = {package_name: package}
        self.packager = Packager(css_packages=package, js_packages=package)

        try:
            package = self.packager.package_for(self.type, package_name)
        except PackageNotFound:
            return ''  # fail silently, do not return anything if an invalid group is specified

        if settings.PIPELINE:
            return self.render_type_specific(package, package.output_filename)
        else:
            paths = self.packager.compile(package.paths)
            return self.render_individual(package, paths)

    def render_individual(self, package, paths):
        tags = [self.render_type_specific(package, path) for path in paths]
        return '\n'.join(tags)

    def get_url(self, path):
        if path_is_url(path):
            return path
        return default_storage.url(path)
开发者ID:fahhem,项目名称:django-pipeline,代码行数:32,代码来源:compressed.py

示例15: CompressedCSSNode

# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import package_for [as 别名]
class CompressedCSSNode(template.Node):
    def __init__(self, name):
        self.name = name
        self.packager = Packager()

    def render(self, context):
        package_name = template.Variable(self.name).resolve(context)
        try:
            package = self.packager.package_for('css', package_name)
        except PackageNotFound:
            return ''  # fail silently, do not return anything if an invalid group is specified

        if settings.PIPELINE:
            compressed_path = self.packager.pack_stylesheets(package)
            return self.render_css(package, compressed_path)
        else:
            package['paths'] = self.packager.compile(package['paths'])
            return self.render_individual(package)

    def render_css(self, package, path):
        context = {}
        if not 'template' in package:
            package['template'] = "pipeline/css.html"
        if not 'context' in package:
            context = package['context']
        context.update({
            'url': self.packager.individual_url(path)
        })
        return render_to_string(package['template'], context)

    def render_individual(self, package):
        tags = [self.render_css(package, path) for path in package['paths']]
        return '\n'.join(tags)
开发者ID:foonnnnn,项目名称:django-pipeline,代码行数:35,代码来源:compressed.py


注:本文中的pipeline.packager.Packager.package_for方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。