def version_from_file(self, path, filename): regex = self.file_regex(filename) versions = [] for f in sorted(storage.listdir(path)[1], reverse=True): version = regex.match(f) if version and version.groups(): versions.append(version.group(1)) versions.sort() return versions[-1]
def version_from_file(self, path, filename): filename = settings.COMPRESS_VERSION_PLACEHOLDER.join([re.escape(part) for part in filename.split(settings.COMPRESS_VERSION_PLACEHOLDER)]) regex = re.compile(r'^%s$' % self.output_filename(filename, r'([A-Za-z0-9]+)')) versions = [] for f in sorted(storage.listdir(path), reverse=True): version = regex.match(f) if version and version.groups(): versions.append(version.group(1)) versions.sort() return versions[-1]
def cleanup(self, filename): if not settings.COMPRESS_VERSION_REMOVE_OLD: return # Nothing to delete here path = os.path.dirname(filename) regex = self.file_regex(os.path.basename(filename)) 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 cleanup(self, filename): if not settings.COMPRESS_VERSION and not settings.COMPRESS_VERSION_REMOVE_OLD: return # Nothing to delete here path = os.path.dirname(filename) filename = settings.COMPRESS_VERSION_PLACEHOLDER.join([re.escape(part) for part in filename.split(settings.COMPRESS_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))