From 5a1851b795a47776ab82fb1ad5eaf0d0ceb37bc3 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Fri, 8 Apr 2011 17:15:27 +0200 Subject: [PATCH] When loading the compiler settings, raise an exception if no compiler can be found. --- compressor/base.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/compressor/base.py b/compressor/base.py index c1f1294..cc9372c 100644 --- a/compressor/base.py +++ b/compressor/base.py @@ -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,12 +106,15 @@ 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: - content = CompilerFilter(content, filter_type=self.type, - command=command).output(**kwargs) + 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 def filter(self, content, method, **kwargs):