When loading the compiler settings, raise an exception if no compiler can be found.

This commit is contained in:
Jannis Leidel
2011-04-08 17:15:27 +02:00
parent 019685e87e
commit 5a1851b795

View File

@@ -29,6 +29,7 @@ class Compressor(object):
self.storage = default_storage
self.split_content = []
self.extra_context = {}
self.all_mimetypes = dict(settings.COMPRESS_PRECOMPILERS)
def split_contents(self):
"""
@@ -105,10 +106,13 @@ class Compressor(object):
attrs = self.parser.elem_attribs(elem)
mimetype = attrs.get("type", None)
if mimetype is not None:
for mimetypes, command in settings.COMPRESS_PRECOMPILERS:
if not isinstance(mimetypes, (list, tuple)):
mimetypes = (mimetypes,)
if mimetype in mimetypes:
command = self.all_mimetypes.get(mimetype)
if command is None:
if mimetype not in ("text/css", "text/javascript"):
raise CompressorError(
"Couldn't find any configured precompiler "
"for mimetype '%s'." % mimetype)
else:
content = CompilerFilter(content, filter_type=self.type,
command=command).output(**kwargs)
return content