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)
14 class CSSTidyFilter(FilterBase):
15 def filter_css(self, css):
16 tmp_file = tempfile.NamedTemporaryFile(mode='w+b')
20 output_file = tempfile.NamedTemporaryFile(mode='w+b')
22 command = '%s %s %s %s' % (BINARY, tmp_file.name, ARGUMENTS, output_file.name)
24 command_output = os.popen(command).read()
26 filtered_css = output_file.read()