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