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))
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
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
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
def glob0(dirname, basename): if storage.exists(os.path.join(dirname, basename)): return [basename] return []
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)