Fix some PEP8 warnings in mtime_cache.py
This commit is contained in:
@@ -11,22 +11,27 @@ from compressor.cache import cache, get_mtime, get_mtime_cachekey
|
|||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = "Add or remove all mtime values from the cache"
|
help = "Add or remove all mtime values from the cache"
|
||||||
option_list = BaseCommand.option_list + (
|
option_list = BaseCommand.option_list + (
|
||||||
make_option('-i', '--ignore', action='append', default=[],
|
make_option(
|
||||||
|
'-i', '--ignore', action='append', default=[],
|
||||||
dest='ignore_patterns', metavar='PATTERN',
|
dest='ignore_patterns', metavar='PATTERN',
|
||||||
help="Ignore files or directories matching this glob-style "
|
help="Ignore files or directories matching this glob-style "
|
||||||
"pattern. Use multiple times to ignore more."),
|
"pattern. Use multiple times to ignore more."),
|
||||||
make_option('--no-default-ignore', action='store_false',
|
make_option(
|
||||||
|
'--no-default-ignore', action='store_false',
|
||||||
dest='use_default_ignore_patterns', default=True,
|
dest='use_default_ignore_patterns', default=True,
|
||||||
help="Don't ignore the common private glob-style patterns 'CVS', "
|
help="Don't ignore the common private glob-style patterns 'CVS', "
|
||||||
"'.*' and '*~'."),
|
"'.*' and '*~'."),
|
||||||
make_option('--follow-links', dest='follow_links', action='store_true',
|
make_option(
|
||||||
|
'--follow-links', dest='follow_links', action='store_true',
|
||||||
help="Follow symlinks when traversing the COMPRESS_ROOT "
|
help="Follow symlinks when traversing the COMPRESS_ROOT "
|
||||||
"(which defaults to STATIC_ROOT). Be aware that using this "
|
"(which defaults to STATIC_ROOT). Be aware that using this "
|
||||||
"can lead to infinite recursion if a link points to a parent "
|
"can lead to infinite recursion if a link points to a parent "
|
||||||
"directory of itself."),
|
"directory of itself."),
|
||||||
make_option('-c', '--clean', dest='clean', action='store_true',
|
make_option(
|
||||||
|
'-c', '--clean', dest='clean', action='store_true',
|
||||||
help="Remove all items"),
|
help="Remove all items"),
|
||||||
make_option('-a', '--add', dest='add', action='store_true',
|
make_option(
|
||||||
|
'-a', '--add', dest='add', action='store_true',
|
||||||
help="Add all items"),
|
help="Add all items"),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -47,17 +52,20 @@ class Command(BaseCommand):
|
|||||||
options['ignore_patterns'] = ignore_patterns
|
options['ignore_patterns'] = ignore_patterns
|
||||||
self.ignore_patterns = ignore_patterns
|
self.ignore_patterns = ignore_patterns
|
||||||
|
|
||||||
if (options['add'] and options['clean']) or (not options['add'] and not options['clean']):
|
if ((options['add'] and options['clean']) or
|
||||||
|
(not options['add'] and not options['clean'])):
|
||||||
raise CommandError('Please specify either "--add" or "--clean"')
|
raise CommandError('Please specify either "--add" or "--clean"')
|
||||||
|
|
||||||
if not settings.COMPRESS_MTIME_DELAY:
|
if not settings.COMPRESS_MTIME_DELAY:
|
||||||
raise CommandError('mtime caching is currently disabled. Please '
|
raise CommandError(
|
||||||
|
'mtime caching is currently disabled. Please '
|
||||||
'set the COMPRESS_MTIME_DELAY setting to a number of seconds.')
|
'set the COMPRESS_MTIME_DELAY setting to a number of seconds.')
|
||||||
|
|
||||||
files_to_add = set()
|
files_to_add = set()
|
||||||
keys_to_delete = set()
|
keys_to_delete = set()
|
||||||
|
|
||||||
for root, dirs, files in os.walk(settings.COMPRESS_ROOT, followlinks=options['follow_links']):
|
for root, dirs, files in os.walk(settings.COMPRESS_ROOT,
|
||||||
|
followlinks=options['follow_links']):
|
||||||
for dir_ in dirs:
|
for dir_ in dirs:
|
||||||
if self.is_ignored(dir_):
|
if self.is_ignored(dir_):
|
||||||
dirs.remove(dir_)
|
dirs.remove(dir_)
|
||||||
@@ -74,7 +82,8 @@ class Command(BaseCommand):
|
|||||||
|
|
||||||
if keys_to_delete:
|
if keys_to_delete:
|
||||||
cache.delete_many(list(keys_to_delete))
|
cache.delete_many(list(keys_to_delete))
|
||||||
print("Deleted mtimes of %d files from the cache." % len(keys_to_delete))
|
print("Deleted mtimes of %d files from the cache."
|
||||||
|
% len(keys_to_delete))
|
||||||
|
|
||||||
if files_to_add:
|
if files_to_add:
|
||||||
for filename in files_to_add:
|
for filename in files_to_add:
|
||||||
|
Reference in New Issue
Block a user