From 51e825910f64e24c7427f7ea4d9414da93673a6d Mon Sep 17 00:00:00 2001 From: Max Rees Date: Sat, 11 Apr 2020 18:02:24 -0500 Subject: Add option to show only missing packages --- depver_test.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'depver_test.py') diff --git a/depver_test.py b/depver_test.py index 3dcf596..5e25c39 100644 --- a/depver_test.py +++ b/depver_test.py @@ -31,7 +31,7 @@ def atomize(spec): # Not reached assert False -def analyze(url, repos, arch): +def analyze(opts, arch): pkgs = collections.defaultdict(dict) newest = {} providers = collections.defaultdict(list) @@ -39,8 +39,9 @@ def analyze(url, repos, arch): print("Loading " + arch + "...", file=sys.stderr) index = [] - for repo in repos: - index.extend(Index(url=url + f"/{repo}/{arch}/APKINDEX.tar.gz").packages) + for repo in opts.repos: + url = f"{opts.url}/{repo}/{arch}/APKINDEX.tar.gz" + index.extend(Index(url=url).packages) for pkg in index: new = pkg.version @@ -69,7 +70,6 @@ def analyze(url, repos, arch): providers[i].append((pkg.name, pver)) yield ["arch", "package", "version", "issue"] - for name in sorted(pkgs.keys()): # DON'T use newest[] here. It is possible that a package # provides= another package's name with a newer version @@ -96,6 +96,9 @@ def analyze(url, repos, arch): else: yield [arch, name, ver, No(f"Missing {spec}")] + if opts.only_missing: + continue + for _, pver in providers[dep]: if is_same(pver, newest[dep]): break @@ -118,6 +121,10 @@ if __name__ == "__main__": default="pretty" if os.isatty(sys.stdout.fileno()) else "tab", help="display format", ) + opts.add_argument( + "-m", "--only-missing", action="store_true", + help="show only missing dependencies", + ) opts.add_argument( "url", metavar="URL", help="base URL (no repository or arch)", @@ -138,5 +145,5 @@ if __name__ == "__main__": # FIXME: with html, wrapping will repeat for > 1 arch FORMATTERS[opts.format]( opts, - analyze(opts.url, opts.repos, arch), + analyze(opts, arch), ) -- cgit v1.2.3-70-g09d2