File: csstidy.py

package info (click to toggle)
django-pipeline 1.3.24-0.2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 544 kB
  • ctags: 349
  • sloc: python: 1,706; makefile: 114
file content (22 lines) | stat: -rw-r--r-- 642 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from __future__ import unicode_literals

from django.core.files import temp as tempfile

from pipeline.conf import settings
from pipeline.compressors import SubProcessCompressor


class CSSTidyCompressor(SubProcessCompressor):
    def compress_css(self, css):
        output_file = tempfile.NamedTemporaryFile(suffix='.pipeline')

        command = '%s - %s %s' % (
            settings.PIPELINE_CSSTIDY_BINARY,
            settings.PIPELINE_CSSTIDY_ARGUMENTS,
            output_file.name
        )
        self.execute_command(command, css)

        filtered_css = output_file.read()
        output_file.close()
        return filtered_css