Skip to content

Commit

Permalink
Change Compressor.read_bytes to open local files found via static fil…
Browse files Browse the repository at this point in the history
…es finders
  • Loading branch information
skirsdeda committed Jun 30, 2015
1 parent a12407e commit edbfb33
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pipeline/compressors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from itertools import takewhile

from django.contrib.staticfiles import finders
from django.contrib.staticfiles.storage import staticfiles_storage
from django.utils.encoding import smart_bytes, force_text

Expand Down Expand Up @@ -207,7 +208,12 @@ def relative_path(self, absolute_path, output_filename):

def read_bytes(self, path):
"""Read file content in binary mode"""
file = staticfiles_storage.open(path)
finder_path = finders.find(path)
if finder_path is not None:
file = open(finder_path)
else:
raise Exception("File '%s' not found via "
"static files finders", path)
content = file.read()
file.close()
return content
Expand Down

0 comments on commit edbfb33

Please sign in to comment.