Further cleanup of the filter settings (moved all of them to the settings module).

This commit is contained in:
Jannis Leidel
2010-08-11 22:45:11 +02:00
parent 9c6a371aaa
commit 512ecfb2f2
5 changed files with 26 additions and 23 deletions

View File

@@ -11,7 +11,20 @@ COMPRESS = getattr(settings, 'COMPRESS', not settings.DEBUG)
COMPRESS_CSS_FILTERS = getattr(settings, 'COMPRESS_CSS_FILTERS', ['compressor.filters.css_default.CssAbsoluteFilter'])
COMPRESS_JS_FILTERS = getattr(settings, 'COMPRESS_JS_FILTERS', ['compressor.filters.jsmin.JSMinFilter'])
COMPRESS_LESSC_BINARY = getattr(settings, 'COMPRESS_LESSC_BINARY', 'lessc')
COMPRESS_LESSC_BINARY = LESSC_BINARY = getattr(settings, 'COMPRESS_LESSC_BINARY', 'lessc')
CLOSURE_COMPILER_BINARY = getattr(settings, 'COMPRESS_CLOSURE_COMPILER_BINARY', 'java -jar compiler.jar')
CLOSURE_COMPILER_ARGUMENTS = getattr(settings, 'COMPRESS_CLOSURE_COMPILER_ARGUMENTS', '')
CSSTIDY_BINARY = getattr(settings, 'CSSTIDY_BINARY',
getattr(settings, 'COMPRESS_CSSTIDY_BINARY', 'csstidy'))
CSSTIDY_ARGUMENTS = getattr(settings, 'CSSTIDY_ARGUMENTS',
getattr(settings, 'COMPRESS_CSSTIDY_ARGUMENTS', '--template=highest'))
YUI_BINARY = getattr(settings, 'COMPRESS_YUI_BINARY', 'java -jar yuicompressor.jar')
YUI_CSS_ARGUMENTS = getattr(settings, 'COMPRESS_YUI_CSS_ARGUMENTS', '')
YUI_JS_ARGUMENTS = getattr(settings, 'COMPRESS_YUI_JS_ARGUMENTS', '')
if COMPRESS_CSS_FILTERS is None:
COMPRESS_CSS_FILTERS = []

View File

@@ -1,18 +1,15 @@
import subprocess
from django.conf import settings
from compressor.conf import settings
from compressor.filters import FilterBase, FilterError
BINARY = getattr(settings, 'COMPRESS_CLOSURE_COMPILER_BINARY', 'java -jar compiler.jar')
ARGUMENTS = getattr(settings, 'COMPRESS_CLOSURE_COMPILER_ARGUMENTS', '')
class ClosureCompilerFilter(FilterBase):
def output(self, **kwargs):
arguments = ARGUMENTS
arguments = settings.CLOSURE_COMPILER_ARGUMENTS
command = '%s %s' % (BINARY, arguments)
command = '%s %s' % (settings.CLOSURE_COMPILER_BINARY, arguments)
try:
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)

View File

@@ -2,16 +2,13 @@ from subprocess import Popen, PIPE
import tempfile
import warnings
from django.conf import settings
from compressor.conf import settings
from compressor.filters import FilterBase
BINARY = getattr(settings, 'CSSTIDY_BINARY', 'csstidy')
ARGUMENTS = getattr(settings, 'CSSTIDY_ARGUMENTS', '--template=highest')
warnings.simplefilter('ignore', RuntimeWarning)
class CSSTidyFilter(FilterBase):
def output(self, **kwargs):
tmp_file = tempfile.NamedTemporaryFile(mode='w+b')
tmp_file.write(self.content)
@@ -19,7 +16,7 @@ class CSSTidyFilter(FilterBase):
output_file = tempfile.NamedTemporaryFile(mode='w+b')
command = '%s %s %s %s' % (BINARY, tmp_file.name, ARGUMENTS, output_file.name)
command = '%s %s %s %s' % (settings.CSSTIDY_BINARY, tmp_file.name, settings.CSSTIDY_ARGUMENTS, output_file.name)
command_output = Popen(command, shell=True,
stdout=PIPE, stdin=PIPE, stderr=PIPE).communicate()

View File

@@ -17,7 +17,7 @@ class LessFilter(FilterBase):
output_file = tempfile.NamedTemporaryFile(mode='w+b')
command = '%s %s %s' % (settings.COMPRESS_LESSC_BINARY, tmp_file.name, output_file.name)
command = '%s %s %s' % (settings.LESSC_BINARY, tmp_file.name, output_file.name)
command_output = os.popen(command).read()

View File

@@ -1,23 +1,19 @@
import subprocess
from django.conf import settings
from compressor.conf import settings
from compressor.filters import FilterBase, FilterError
BINARY = getattr(settings, 'COMPRESS_YUI_BINARY', 'java -jar yuicompressor.jar')
CSS_ARGUMENTS = getattr(settings, 'COMPRESS_YUI_CSS_ARGUMENTS', '')
JS_ARGUMENTS = getattr(settings, 'COMPRESS_YUI_JS_ARGUMENTS', '')
class YUICompressorFilter(FilterBase):
def output(self, **kwargs):
arguments = ''
if self.type == 'js':
arguments = JS_ARGUMENTS
arguments = settings.YUI_JS_ARGUMENTS
if self.type == 'css':
arguments = CSS_ARGUMENTS
command = '%s --type=%s %s' % (BINARY, self.type, arguments)
arguments = settings.YUI_CSS_ARGUMENTS
command = '%s --type=%s %s' % (settings.YUI_BINARY, self.type, arguments)
if self.verbose:
command += ' --verbose'