Skip to content

Instantly share code, notes, and snippets.

@richleland
Created October 11, 2011 16:05
Show Gist options
  • Select an option

  • Save richleland/1278516 to your computer and use it in GitHub Desktop.

Select an option

Save richleland/1278516 to your computer and use it in GitHub Desktop.
def get_filename(self, basename):
# first try to find it with staticfiles (in debug mode)
filename = None
if self.storage.exists(basename):
try:
filename = self.storage.path(basename)
except NotImplementedError:
local_storage = get_storage_class('compressor.storage.CompressorFileStorage')()
filename = local_storage.path(basename)
# secondly try finding the file in the root
elif self.finders:
filename = self.finders.find(basename)
if filename:
return filename
# or just raise an exception as the last resort
raise UncompressableFileError(
"'%s' could not be found in the COMPRESS_ROOT '%s'%s" %
(basename, settings.COMPRESS_ROOT,
self.finders and " or with staticfiles." or "."))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment