diff options
Diffstat (limited to 'src/pkgcheck/scripts/pkgcheck_cache.py')
-rw-r--r-- | src/pkgcheck/scripts/pkgcheck_cache.py | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/src/pkgcheck/scripts/pkgcheck_cache.py b/src/pkgcheck/scripts/pkgcheck_cache.py index a986bb2d..5787c65e 100644 --- a/src/pkgcheck/scripts/pkgcheck_cache.py +++ b/src/pkgcheck/scripts/pkgcheck_cache.py @@ -10,34 +10,37 @@ from .argparse_actions import CacheNegations from .argparsers import repo_argparser cache = arghparse.ArgumentParser( - prog='pkgcheck cache', description='perform cache operations', + prog="pkgcheck cache", + description="perform cache operations", parents=(repo_argparser,), docs=""" Various types of caches are used by pkgcheck. This command supports running operations on them including updates and removals. - """) + """, +) cache.add_argument( - '--cache-dir', type=arghparse.create_dir, default=const.USER_CACHE_DIR, - help='directory to use for storing cache files') + "--cache-dir", + type=arghparse.create_dir, + default=const.USER_CACHE_DIR, + help="directory to use for storing cache files", +) cache_actions = cache.add_mutually_exclusive_group() cache_actions.add_argument( - '-l', '--list', dest='list_cache', action='store_true', - help='list available caches') + "-l", "--list", dest="list_cache", action="store_true", help="list available caches" +) cache_actions.add_argument( - '-u', '--update', dest='update_cache', action='store_true', - help='update caches') + "-u", "--update", dest="update_cache", action="store_true", help="update caches" +) cache_actions.add_argument( - '-R', '--remove', dest='remove_cache', action='store_true', - help='forcibly remove caches') + "-R", "--remove", dest="remove_cache", action="store_true", help="forcibly remove caches" +) cache.add_argument( - '-f', '--force', dest='force_cache', action='store_true', - help='forcibly update/remove caches') + "-f", "--force", dest="force_cache", action="store_true", help="forcibly update/remove caches" +) cache.add_argument( - '-n', '--dry-run', action='store_true', - help='dry run without performing any changes') -cache.add_argument( - '-t', '--type', dest='cache', action=CacheNegations, - help='target cache types') + "-n", "--dry-run", action="store_true", help="dry run without performing any changes" +) +cache.add_argument("-t", "--type", dest="cache", action=CacheNegations, help="target cache types") @cache.bind_pre_parse @@ -50,16 +53,14 @@ def _setup_cache_addons(parser, namespace): @cache.bind_early_parse def _setup_cache(parser, namespace, args): if namespace.target_repo is None: - namespace.target_repo = namespace.config.get_default('repo') + namespace.target_repo = namespace.config.get_default("repo") return namespace, args @cache.bind_final_check def _validate_cache_args(parser, namespace): enabled_caches = {k for k, v in namespace.cache.items() if v} - cache_addons = ( - addon for addon in CachedAddon.caches - if addon.cache.type in enabled_caches) + cache_addons = (addon for addon in CachedAddon.caches if addon.cache.type in enabled_caches) # sort caches by type namespace.cache_addons = sorted(cache_addons, key=lambda x: x.cache.type) @@ -72,18 +73,18 @@ def _cache(options, out, err): cache_obj = CachedAddon(options) cache_obj.remove_caches() elif options.update_cache: - for addon_cls in options.pop('cache_addons'): + for addon_cls in options.pop("cache_addons"): init_addon(addon_cls, options) else: # list existing caches cache_obj = CachedAddon(options) - repos_dir = pjoin(options.cache_dir, 'repos') + repos_dir = pjoin(options.cache_dir, "repos") for cache_type in sorted(options.enabled_caches): paths = cache_obj.existing_caches[cache_type] if paths: - out.write(out.fg('yellow'), f'{cache_type} caches: ', out.reset) + out.write(out.fg("yellow"), f"{cache_type} caches: ", out.reset) for path in paths: - repo = str(path.parent)[len(repos_dir):] + repo = str(path.parent)[len(repos_dir) :] # non-path repo ids get path separator stripped if repo.count(os.sep) == 1: repo = repo.lstrip(os.sep) |