Commit 1d801441 by Timothée Peignier

use django tempfile implementation to provide windows support

parent 27216d38
import os
import tempfile
from django.core.files import temp as tempfile
from pipeline.conf import settings
from pipeline.compressors import SubProcessCompressor
......@@ -7,18 +6,15 @@ from pipeline.compressors import SubProcessCompressor
class CSSTidyCompressor(SubProcessCompressor):
def compress_css(self, css):
out_file, out_filename = tempfile.mkstemp()
out_file = os.fdopen(out_file, 'rb')
output_file = tempfile.NamedTemporaryFile(suffix='.pipeline')
command = '%s - %s %s' % (
settings.PIPELINE_CSSTIDY_BINARY,
settings.PIPELINE_CSSTIDY_ARGUMENTS,
out_filename
output_file.name
)
self.execute_command(command, css)
filtered_css = out_file.read()
out_file.close()
os.remove(out_filename)
filtered_css = output_file.read()
output_file.close()
return filtered_css
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment