Minor nitpicking..

This commit is contained in:
Jannis Leidel
2011-11-25 16:55:40 +01:00
parent 9074c9b5aa
commit 86f98db217

View File

@@ -64,13 +64,12 @@ class Compressor(object):
return basename.split("?", 1)[0] return basename.split("?", 1)[0]
def get_filepath(self, content, basename=None): def get_filepath(self, content, basename=None):
filename = "%s.%s" % (get_hexdigest(content, 12), self.type) parts = []
if basename is not None: if basename:
filename = '.'.join([ filename = os.path.split(basename)[1]
os.path.splitext(os.path.split(basename)[1])[0], parts.append(os.path.splitext(filename)[0])
filename parts.extend([get_hexdigest(content, 12), self.type])
]) return os.path.join(self.output_dir, self.output_prefix, '.'.join(parts))
return os.path.join(self.output_dir, self.output_prefix, filename)
def get_filename(self, basename): def get_filename(self, basename):
filename = None filename = None
@@ -88,7 +87,7 @@ class Compressor(object):
return filename return filename
# or just raise an exception as the last resort # or just raise an exception as the last resort
raise UncompressableFileError( raise UncompressableFileError(
"'%s' could not be found in the COMPRESS_ROOT '%s'%s" % "'%s' could not be found in the COMPRESS_ROOT '%s'%s" %
(basename, settings.COMPRESS_ROOT, (basename, settings.COMPRESS_ROOT,
self.finders and " or with staticfiles." or ".")) self.finders and " or with staticfiles." or "."))
@@ -102,7 +101,7 @@ class Compressor(object):
except UnicodeDecodeError, e: except UnicodeDecodeError, e:
raise UncompressableFileError("UnicodeDecodeError while " raise UncompressableFileError("UnicodeDecodeError while "
"processing '%s' with " "processing '%s' with "
"charset %s: %s" % "charset %s: %s" %
(filename, charset, e)) (filename, charset, e))
@cached_property @cached_property
@@ -274,5 +273,5 @@ class Compressor(object):
final_context = Context(self.context) final_context = Context(self.context)
post_compress.send(sender=self.__class__, type=self.type, post_compress.send(sender=self.__class__, type=self.type,
mode=mode, context=final_context) mode=mode, context=final_context)
return render_to_string("compressor/%s_%s.html" % return render_to_string("compressor/%s_%s.html" %
(self.type, mode), final_context) (self.type, mode), final_context)