zulip_tools: Change `purge_unused_caches()` API.

Instead of accepting individual arguments, accept `argparse.Namespace`
object as an argument.
This commit is contained in:
Harshit Bansal 2017-09-23 18:25:26 +00:00 committed by Tim Abbott
parent 8a4c1164b2
commit 4e6b68d02f
4 changed files with 7 additions and 8 deletions

View File

@ -51,7 +51,7 @@ def main():
args = parse_args()
caches_in_use = get_caches_in_use(args.threshold_days)
purge_unused_caches(
EMOJI_CACHE_PATH, caches_in_use, args.threshold_days, args.dry_run, "emoji cache")
EMOJI_CACHE_PATH, caches_in_use, args, "emoji cache")
if __name__ == "__main__":
main()

View File

@ -61,8 +61,7 @@ def main():
args = parse_args()
caches_in_use = get_caches_in_use(args.threshold_days)
purge_unused_caches(
NODE_MODULES_CACHE_PATH, caches_in_use, args.threshold_days,
args.dry_run, "node modules cache")
NODE_MODULES_CACHE_PATH, caches_in_use, args, "node modules cache")
if __name__ == "__main__":
main()

View File

@ -51,7 +51,7 @@ def main():
args = parse_args()
caches_in_use = get_caches_in_use(args.threshold_days)
purge_unused_caches(
VENV_CACHE_DIR, caches_in_use, args.threshold_days, args.dry_run, "venv cache")
VENV_CACHE_DIR, caches_in_use, args, "venv cache")
if __name__ == "__main__":
main()

View File

@ -221,13 +221,13 @@ def get_caches_to_be_purged(caches_dir, caches_in_use, threshold_days):
caches_to_purge.add(cache_dir)
return caches_to_purge
def purge_unused_caches(caches_dir, caches_in_use, threshold_days, dry_run, cache_type):
# type: (Text, Set[Text], int, bool, Text) -> None
def purge_unused_caches(caches_dir, caches_in_use, args, cache_type):
# type: (Text, Set[Text], argparse.Namespace, Text) -> None
all_caches = set([os.path.join(caches_dir, cache) for cache in os.listdir(caches_dir)])
caches_to_purge = get_caches_to_be_purged(caches_dir, caches_in_use, threshold_days)
caches_to_purge = get_caches_to_be_purged(caches_dir, caches_in_use, args.threshold_days)
caches_to_keep = all_caches - caches_to_purge
may_be_perform_purging(caches_to_purge, caches_to_keep, cache_type, dry_run)
may_be_perform_purging(caches_to_purge, caches_to_keep, cache_type, args.dry_run)
print("Done!\n")
def generate_sha1sum_emoji(zulip_path):