本文整理汇总了Python中pipeline.packager.Packager.individual_url方法的典型用法代码示例。如果您正苦于以下问题:Python Packager.individual_url方法的具体用法?Python Packager.individual_url怎么用?Python Packager.individual_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pipeline.packager.Packager
的用法示例。
在下文中一共展示了Packager.individual_url方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PipelineManifest
# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import individual_url [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))
示例2: PipelineManifest
# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import individual_url [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))
示例3: PipelineManifest
# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import individual_url [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))
示例4: test_individual_url
# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import individual_url [as 别名]
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")
示例5: CompressedCSSNode
# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import individual_url [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)
示例6: CompressedJSNode
# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import individual_url [as 别名]
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)
示例7: test_periods_safe_individual_url
# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import individual_url [as 别名]
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")
示例8: PipelineManifest
# 需要导入模块: from pipeline.packager import Packager [as 别名]
# 或者: from pipeline.packager.Packager import individual_url [as 别名]
class PipelineManifest(Manifest):
def __init__(self):
self.packager = Packager()
self.packages = self.collect_packages()
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:
filename_base, filename = os.path.split(package['output'])
version = self.packager.versioning.version_from_file(filename_base, filename)
output_filename = self.packager.versioning.output_filename(package['output'], version)
yield str(self.packager.individual_url(output_filename))
else:
for package in self.packages:
for path in self.packager.compile(package['paths']):
yield str(self.packager.individual_url(path))
def revision(self):
versions = []
if settings.PIPELINE:
for package in self.packages:
filename_base, filename = os.path.split(package['output'])
version = self.packager.versioning.version_from_file(filename_base, filename)
versions.append(str(version))
else:
for package in self.packages:
version = self.packager.versioning.version(package['paths'])
versions.append(str(version))
versions.sort()
return versions[-1]