Commit 919f7b46 by Timothée Peignier

use commonprefix rather than our custom function

parent 6b850444
......@@ -73,7 +73,7 @@ class Compressor(object):
if not paths:
return compiled
namespace = settings.PIPELINE_TEMPLATE_NAMESPACE
base_path = self.base_path(paths)
base_path = os.path.commonprefix(paths)
for path in paths:
contents = self.read_file(path)
contents = re.sub(r"\r?\n", "", contents)
......@@ -94,27 +94,13 @@ class Compressor(object):
def template_name(self, path, base):
name = os.path.basename(path)
base = os.path.abspath(base)
if base:
name = re.sub(r"^%s\/(.*)%s$" % (
re.escape(base), re.escape(settings.PIPELINE_TEMPLATE_EXT)
), r"\1", path)
return re.sub(r"[\/\\]", "_", name)
def base_path(self, paths):
if len(paths) <= 1:
return None
paths.sort()
first = paths[0].split('/')
last = paths[-1].split('/')
i = 0
while first[i] == last[i] and i <= len(first):
i += 1
base = '/'.join(first[0:i])
if not base:
return None
else:
return base
def concatenate_and_rewrite(self, paths, variant=None):
"""Concatenate together files and rewrite urls"""
stylesheets = []
......
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