Пример #1
0
 def mtimes(self):
     """Calculate mtimes taking all LESS dependencies into consideration."""
     result = []
     for kind, value, basename, elem in self.split_contents():
         if kind != SOURCE_FILE:
             continue
         result.append(str(get_mtime(value)))
         # If the file is LESS, extract mtimes of imports from it
         # recursively.
         if value.endswith('.less'):
            for value in sorted(get_lesscss_dependencies(value)):
                result.append(str(get_mtime(value)))
     return result
Пример #2
0
    def handle(self, **options):
        ignore_patterns = options["ignore_patterns"]
        if options["use_default_ignore_patterns"]:
            ignore_patterns += ["CVS", ".*", "*~"]
            options["ignore_patterns"] = ignore_patterns
        self.ignore_patterns = ignore_patterns

        if (options["add"] and options["clean"]) or (not options["add"]
                                                     and not options["clean"]):
            raise CommandError('Please specify either "--add" or "--clean"')

        if not settings.COMPRESS_MTIME_DELAY:
            raise CommandError(
                "mtime caching is currently disabled. Please "
                "set the COMPRESS_MTIME_DELAY setting to a number of seconds.")

        files_to_add = set()
        keys_to_delete = set()

        for root, dirs, files in os.walk(settings.COMPRESS_ROOT,
                                         followlinks=options["follow_links"]):
            for dir_ in dirs:
                if self.is_ignored(dir_):
                    dirs.remove(dir_)
            for filename in files:
                common = "".join(root.split(settings.COMPRESS_ROOT))
                if common.startswith(os.sep):
                    common = common[len(os.sep):]
                if self.is_ignored(os.path.join(common, filename)):
                    continue
                filename = os.path.join(root, filename)
                keys_to_delete.add(get_mtime_cachekey(filename))
                if options["add"]:
                    files_to_add.add(filename)

        if keys_to_delete:
            cache.delete_many(list(keys_to_delete))
            self.stdout.write("Deleted mtimes of %d files from the cache." %
                              len(keys_to_delete))

        if files_to_add:
            for filename in files_to_add:
                get_mtime(filename)
            self.stdout.write("Added mtimes of %d files to cache." %
                              len(files_to_add))
Пример #3
0
    def handle(self, **options):
        ignore_patterns = options['ignore_patterns']
        if options['use_default_ignore_patterns']:
            ignore_patterns += ['CVS', '.*', '*~']
            options['ignore_patterns'] = ignore_patterns
        self.ignore_patterns = ignore_patterns

        if ((options['add'] and options['clean']) or
                (not options['add'] and not options['clean'])):
            raise CommandError('Please specify either "--add" or "--clean"')

        if not settings.COMPRESS_MTIME_DELAY:
            raise CommandError(
                'mtime caching is currently disabled. Please '
                'set the COMPRESS_MTIME_DELAY setting to a number of seconds.')

        files_to_add = set()
        keys_to_delete = set()

        for root, dirs, files in os.walk(settings.COMPRESS_ROOT,
                                         followlinks=options['follow_links']):
            for dir_ in dirs:
                if self.is_ignored(dir_):
                    dirs.remove(dir_)
            for filename in files:
                common = "".join(root.split(settings.COMPRESS_ROOT))
                if common.startswith(os.sep):
                    common = common[len(os.sep):]
                if self.is_ignored(os.path.join(common, filename)):
                    continue
                filename = os.path.join(root, filename)
                keys_to_delete.add(get_mtime_cachekey(filename))
                if options['add']:
                    files_to_add.add(filename)

        if keys_to_delete:
            cache.delete_many(list(keys_to_delete))
            self.stdout.write("Deleted mtimes of %d files from the cache."
                              % len(keys_to_delete))

        if files_to_add:
            for filename in files_to_add:
                get_mtime(filename)
            self.stdout.write("Added mtimes of %d files to cache."
                              % len(files_to_add))
Пример #4
0
    def handle_noargs(self, **options):
        ignore_patterns = options['ignore_patterns']
        if options['use_default_ignore_patterns']:
            ignore_patterns += ['CVS', '.*', '*~']
            options['ignore_patterns'] = ignore_patterns
        self.ignore_patterns = ignore_patterns

        if (options['add'] and options['clean']) or (not options['add']
                                                     and not options['clean']):
            raise CommandError('Please specify either "--add" or "--clean"')

        if not settings.COMPRESS_MTIME_DELAY:
            raise CommandError(
                'mtime caching is currently disabled. Please '
                'set the COMPRESS_MTIME_DELAY setting to a number of seconds.')

        files_to_add = set()
        keys_to_delete = set()

        for root, dirs, files in walk(settings.COMPRESS_ROOT,
                                      followlinks=options['follow_links']):
            for dir_ in dirs:
                if self.is_ignored(dir_):
                    dirs.remove(dir_)
            for filename in files:
                common = "".join(root.split(settings.COMPRESS_ROOT))
                if common.startswith(os.sep):
                    common = common[len(os.sep):]
                if self.is_ignored(os.path.join(common, filename)):
                    continue
                filename = os.path.join(root, filename)
                keys_to_delete.add(get_mtime_cachekey(filename))
                if options['add']:
                    files_to_add.add(filename)

        if keys_to_delete:
            cache.delete_many(list(keys_to_delete))
            print "Deleted mtimes of %d files from the cache." % len(
                keys_to_delete)

        if files_to_add:
            for filename in files_to_add:
                get_mtime(filename)
            print "Added mtimes of %d files to cache." % len(files_to_add)
Пример #5
0
 def mtimes(self):
     return [
         str(get_mtime(value))
         for kind, value, basename, elem in self.split_contents()
         if kind == SOURCE_FILE
     ]
Пример #6
0
 def mtimes(self):
     return [str(get_mtime(value)) for kind, value, basename, elem in self.split_contents() if kind == SOURCE_FILE]
Пример #7
0
 def mtimes(self):
     for kind, value, elem in self.split_contents():
         if kind == 'file':
             yield str(get_mtime(value))
Пример #8
0
 def mtimes(self):
     return [
         str(get_mtime(value)) for kind, value, _ in self.split_contents()
         if kind == 'file'
     ]
Пример #9
0
 def get_hash(self, filename, length=12):
     mtime = str(cache.get_mtime(filename))
     return cache.get_hexdigest(mtime + filename, length=length)
Пример #10
0
 def mtimes(self):
     for kind, value, elem in self.split_contents():
         if kind == 'file':
             yield str(get_mtime(value))
Пример #11
0
 def mtimes(self):
     return [str(get_mtime(value))
             for kind, value, _ in self.split_contents() if kind == 'file']