Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions pipeline/packager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.contrib.staticfiles.storage import staticfiles_storage
from django.contrib.staticfiles.finders import find
from django.contrib.staticfiles.finders import get_finders, find
from django.core.files.base import ContentFile
from django.utils.encoding import smart_bytes

Expand Down Expand Up @@ -98,11 +98,25 @@ def pack_stylesheets(self, package, **kwargs):
variant=package.variant, **kwargs)

def compile(self, paths, compiler_options={}, force=False):
return self.compiler.compile(
paths = self.compiler.compile(
paths,
compiler_options=compiler_options,
force=force,
)
for path in paths:
if not self.storage.exists(path):
if self.verbose:
print("Compiled file '%s' cannot be found with packager's storage. Locating it." % path)

source_storage = self.find_source_storage(path)
if source_storage is not None:
with source_storage.open(path) as source_file:
if self.verbose:
print("Saving: %s" % path)
self.storage.save(path, source_file)
else:
raise IOError("File does not exist: %s" % path)
return paths

def pack(self, package, compress, signal, **kwargs):
output_filename = package.output_filename
Expand All @@ -127,6 +141,15 @@ def pack_templates(self, package):
def save_file(self, path, content):
return self.storage.save(path, ContentFile(smart_bytes(content)))

def find_source_storage(self, path):
for finder in get_finders():
for short_path, storage in finder.list(''):
if short_path == path:
if self.verbose:
print("Found storage: %s" % str(self.storage))
return storage
return None

def create_packages(self, config):
packages = {}
if not config:
Expand Down