예제 #1
0
 def cleanup(self, filename):
     if not settings.PIPELINE_VERSION and not settings.PIPELINE_VERSION_REMOVE_OLD:
         return  # Nothing to delete here
     path = os.path.dirname(filename)
     filename = settings.PIPELINE_VERSION_PLACEHOLDER.join([re.escape(part) for part in filename.split(settings.PIPELINE_VERSION_PLACEHOLDER)])
     regex = re.compile(r'^%s$' % os.path.basename(self.output_filename(filename, r'([A-Za-z0-9]+)')))
     if storage.exists(path):
         for f in storage.listdir(path)[1]:
             if regex.match(f):
                 if self.verbose:
                     print "Removing outdated file %s" % f
                 storage.delete(os.path.join(path, f))
예제 #2
0
 def embeddable(self, path, variant):
     """Is the asset embeddable ?"""
     name, ext = os.path.splitext(path)
     font = ext in FONT_EXTS
     if not variant:
         return False
     if not (re.search(EMBEDDABLE, path) and storage.exists(path)):
         return False
     if not ext in EMBED_EXTS:
         return False
     if not (font or len(self.encoded_content(path)) < MAX_IMAGE_SIZE):
         return False
     return True
예제 #3
0
 def embeddable(self, path, variant):
     """Is the asset embeddable ?"""
     name, ext = os.path.splitext(path)
     font = ext in FONT_EXTS
     if not variant:
         return False
     if not (re.search(EMBEDDABLE, path) and storage.exists(path)):
         return False
     if not ext in EMBED_EXTS:
         return False
     if not (font or len(self.encoded_content(path)) < MAX_IMAGE_SIZE):
         return False
     return True
예제 #4
0
 def compile(self, paths):
     for index, path in enumerate(paths):
         for compiler in self.compilers:
             compiler = compiler(self.verbose)
             if compiler.match_file(path):
                 new_path = self.output_path(path, compiler.output_extension)
                 content = self.read_file(path)
                 try:
                     compiled_content = compiler.compile_file(content)
                     self.save_file(new_path, compiled_content)
                 except CompilerError:
                     if not storage.exists(new_path) or not settings.PIPELINE:
                         raise
                 paths[index] = new_path
     return paths
예제 #5
0
 def compile(self, paths):
     for index, path in enumerate(paths):
         for compiler in self.compilers:
             compiler = compiler(self.verbose)
             if compiler.match_file(path):
                 new_path = self.output_path(path, compiler.output_extension)
                 content = self.read_file(path)
                 try:
                     compiled_content = compiler.compile_file(content, storage.path(path))
                     self.save_file(new_path, compiled_content)
                 except CompilerError:
                     if not storage.exists(new_path) or not settings.PIPELINE:
                         raise
                 paths[index] = new_path
     return paths
예제 #6
0
def glob0(dirname, basename):
    if storage.exists(os.path.join(dirname, basename)):
        return [basename]
    return []
예제 #7
0
 def need_update(self, output_file, paths):
     version = self.version(paths)
     output_file = self.output_filename(output_file, version)
     if not storage.exists(output_file):
         return True, version
     return getattr(self.versionner, 'need_update')(output_file, paths, version)
예제 #8
0
def glob0(dirname, basename):
    if storage.exists(os.path.join(dirname, basename)):
        return [basename]
    return []