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


Python packager.Packager类代码示例

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


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

示例1: post_process

    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)

            from pipeline.packager import Packager
            packager = Packager(storage=self, css_packages=css_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

        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:lduarte1991,项目名称:edx-platform,代码行数:25,代码来源:storage.py

示例2: CompressedCSSNode

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,代码行数:33,代码来源:compressed.py

示例3: post_process

    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,代码行数:35,代码来源:storage.py

示例4: compressed_css

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,代码行数:30,代码来源:_pipeline.py

示例5: CompressedCSSNode

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,代码行数:33,代码来源:compressed.py

示例6: test_individual_url

 def test_individual_url(self):
     """Check that individual URL is correctly generated"""
     packager = Packager()
     filename = os.path.join(settings.PIPELINE_ROOT, u'js/application.js')
     individual_url = packager.individual_url(filename)
     self.assertEqual(individual_url,
         "http://localhost/static/js/application.js")
开发者ID:rfkrocktk,项目名称:django-pipeline,代码行数:7,代码来源:packager.py

示例7: compressed_css

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,代码行数:31,代码来源:_pipeline.py

示例8: CommonNode

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,代码行数:30,代码来源:compressed.py

示例9: CompressedJSNode

class CompressedJSNode(template.Node):
    def __init__(self, name):
        self.name = name

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

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

        if 'externals' in package:
            return '\n'.join([self.render_external(package, url) for url in package['externals']])

        if settings.PIPELINE:
            compressed_path = self.packager.pack_javascripts(package)
            return self.render_js(package, compressed_path)
        else:
            package['paths'] = self.packager.compile(package['paths'])
            templates = self.packager.pack_templates(package)
            return self.render_individual(package, templates)

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

    def render_external(self, package, url):
        if not 'template' in package:
            package['template'] = "pipeline/js.html"
        return render_to_string(package['template'], {
            'url': url
        })

    def render_inline(self, package, js):
        context = {}
        if 'context' in package:
            context = package['context']
        context.update({
            'source': js
        })
        return render_to_string("pipeline/inline_js.html", context)

    def render_individual(self, package, templates=None):
        tags = [self.render_js(package, js) for js in package['paths']]
        if templates:
            tags.append(self.render_inline(package, templates))
        return '\n'.join(tags)
开发者ID:UniIsland,项目名称:django-pipeline,代码行数:59,代码来源:compressed.py

示例10: test_periods_safe_individual_url

 def test_periods_safe_individual_url(self):
     """Check that the periods in file names do not get replaced by individual_url when
     PIPELINE_ROOT/STATIC_ROOT is not set, such as in development
     """
     settings.PIPELINE_ROOT = settings.STATIC_ROOT = settings.MEDIA_ROOT = ""
     packager = Packager()
     filename = os.path.join(settings.PIPELINE_ROOT, u"js/application.js")
     individual_url = packager.individual_url(filename)
     self.assertEqual(individual_url, "http://localhost/static/js/application.js")
开发者ID:UniIsland,项目名称:django-pipeline,代码行数:9,代码来源:packager.py

示例11: render_compressed

 def render_compressed(self, package, package_type):
     if not settings.DEBUG:
         method = getattr(self, "render_{0}".format(package_type))
         return method(package, package.output_filename)
     else:
         packager = Packager()
         method = getattr(self, "render_individual_{0}".format(package_type))
         paths = packager.compile(package.paths)
         templates = packager.pack_templates(package)
         return method(package, paths, templates=templates)
开发者ID:EDITD,项目名称:django-pipeline,代码行数:10,代码来源:compressed.py

示例12: tabzilla_css_redirect

def tabzilla_css_redirect(r):
    packer = Packager()
    tabzilla_package = packer.package_for('css', 'tabzilla')
    if not settings.DEBUG:
        file_path = tabzilla_package.output_filename
    else:
        default_collector.collect()
        paths = packer.compile(tabzilla_package.paths)
        file_path = paths[0]

    return static(file_path)
开发者ID:ckprice,项目名称:bedrock,代码行数:11,代码来源:urls.py

示例13: test_templates

 def test_templates(self):
     packager = Packager()
     packages = packager.create_packages({
         'templates': {
             'source_filenames': (
                 'templates/photo/list.jst',
             ),
             'output_filename': 'templates.js',
         }
     })
     self.assertEqual(packages['templates'].templates, ['templates/photo/list.jst'])
开发者ID:GbalsaC,项目名称:bitnamiP,代码行数:11,代码来源:packager.py

示例14: compressed_css

def compressed_css(package_name, raw=False):
    package = settings.PIPELINE_CSS.get(package_name, {})
    if package:
        package = {package_name: package}
    packager = Packager(css_packages=package, js_packages={})

    package = packager.package_for('css', package_name)

    if settings.PIPELINE_ENABLED:
        return render_css(package, package.output_filename, raw=raw)
    else:
        paths = packager.compile(package.paths)
        return render_individual_css(package, paths, raw=raw)
开发者ID:28554010,项目名称:edx-platform,代码行数:13,代码来源:__init__.py

示例15: compressed_js

def compressed_js(package_name):
    package = settings.PIPELINE_JS.get(package_name, {})
    if package:
        package = {package_name: package}
    packager = Packager(css_packages={}, js_packages=package)

    package = packager.package_for('js', package_name)

    if settings.PIPELINE_ENABLED:
        return render_js(package, package.output_filename)
    else:
        paths = packager.compile(package.paths)
        templates = packager.pack_templates(package)
        return render_individual_js(package, paths, templates)
开发者ID:28554010,项目名称:edx-platform,代码行数:14,代码来源:__init__.py


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