本文整理汇总了Python中pipeline.packager.Packager.pack_stylesheets方法的典型用法代码示例。如果您正苦于以下问题:Python Packager.pack_stylesheets方法的具体用法?Python Packager.pack_stylesheets怎么用?Python Packager.pack_stylesheets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pipeline.packager.Packager
的用法示例。
在下文中一共展示了Packager.pack_stylesheets方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_process
# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import pack_stylesheets [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
示例2: post_process
# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import pack_stylesheets [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)
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
示例3: post_process
# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import pack_stylesheets [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
]
示例4: post_process
# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import pack_stylesheets [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
示例5: handle
# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import pack_stylesheets [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)
示例6: CompressedCSSNode
# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import pack_stylesheets [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)
示例7: post_process
# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import pack_stylesheets [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
]
示例8: handle_noargs
# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import pack_stylesheets [as 别名]
def handle_noargs(self, **options):
from pipeline.packager import Packager
packager = Packager(
force=options.get('force', False),
verbose=int(options.get('verbosity', 1)) >= 2
)
for package_name in packager.packages['css']:
package = packager.package_for('css', package_name)
if packager.verbose or packager.force:
print
message = "CSS Group '%s'" % package_name
print message
print len(message) * '-'
packager.pack_stylesheets(package)
for package_name in packager.packages['js']:
package = packager.package_for('js', package_name)
if packager.verbose or packager.force:
print
message = "JS Group '%s'" % package_name
print message
print len(message) * '-'
packager.pack_javascripts(package)