Minor refactoring in Compressor's constructor

This commit is contained in:
Johannes Linke
2015-09-11 15:09:51 +02:00
parent 6129c9a621
commit 0a0e0b376e
3 changed files with 8 additions and 9 deletions

View File

@@ -36,15 +36,17 @@ class Compressor(object):
Base compressor object to be subclassed for content type
depending implementations details.
"""
type = None
def __init__(self, content=None, output_prefix=None, context=None, *args, **kwargs):
def __init__(self, content=None, output_prefix=None,
context=None, filters=None, *args, **kwargs):
self.content = content or "" # rendered contents of {% compress %} tag
self.output_prefix = output_prefix or "compressed"
self.output_dir = settings.COMPRESS_OUTPUT_DIR.strip('/')
self.charset = settings.DEFAULT_CHARSET
self.split_content = []
self.context = context or {}
self.type = output_prefix or ""
self.filters = filters or []
self.extra_context = {}
self.precompiler_mimetypes = dict(settings.COMPRESS_PRECOMPILERS)
self.finders = staticfiles.finders

View File

@@ -5,10 +5,8 @@ from compressor.conf import settings
class CssCompressor(Compressor):
def __init__(self, content=None, output_prefix="css", context=None):
super(CssCompressor, self).__init__(content=content,
output_prefix=output_prefix, context=context)
self.filters = list(settings.COMPRESS_CSS_FILTERS)
self.type = output_prefix
filters = list(settings.COMPRESS_CSS_FILTERS)
super(CssCompressor, self).__init__(content, output_prefix, context, filters)
def split_contents(self):
if self.split_content:

View File

@@ -5,9 +5,8 @@ from compressor.base import Compressor, SOURCE_HUNK, SOURCE_FILE
class JsCompressor(Compressor):
def __init__(self, content=None, output_prefix="js", context=None):
super(JsCompressor, self).__init__(content, output_prefix, context)
self.filters = list(settings.COMPRESS_JS_FILTERS)
self.type = output_prefix
filters = list(settings.COMPRESS_JS_FILTERS)
super(JsCompressor, self).__init__(content, output_prefix, context, filters)
def split_contents(self):
if self.split_content: