5 from django.conf import settings
7 from compress.filter_base import FilterBase
9 BINARY = getattr(settings, 'CSSTIDY_BINARY', 'csstidy')
10 ARGUMENTS = getattr(settings, 'CSSTIDY_ARGUMENTS', '--template=highest')
12 warnings.simplefilter('ignore', RuntimeWarning)
15 class CSSTidyFilter(FilterBase):
17 def filter_css(self, css):
18 tmp_file = tempfile.NamedTemporaryFile(mode='w+b')
22 output_file = tempfile.NamedTemporaryFile(mode='w+b')
24 command = '%s %s %s %s' % (BINARY, tmp_file.name, ARGUMENTS, output_file.name)
26 command_output = os.popen(command).read()
28 filtered_css = output_file.read()