From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 69201158041 for ; Thu, 7 Mar 2024 18:49:21 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 19FEEE29C0; Thu, 7 Mar 2024 18:49:20 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 47717E29BF for ; Thu, 7 Mar 2024 18:49:19 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 7D82634302A for ; Thu, 7 Mar 2024 18:49:18 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id D750014E8 for ; Thu, 7 Mar 2024 18:49:16 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1709837346.b2dbcb184063104f750a407e0dbe3a4e0d3bfd9b.sam@gentoo> Subject: [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/equery/ X-VCS-Repository: proj/gentoolkit X-VCS-Files: pym/gentoolkit/equery/depends.py X-VCS-Directories: pym/gentoolkit/equery/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: b2dbcb184063104f750a407e0dbe3a4e0d3bfd9b X-VCS-Branch: master Date: Thu, 7 Mar 2024 18:49:16 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 08d3cb60-593d-4d09-b64f-735f0c436e91 X-Archives-Hash: c9a7feb60fc82d68f5c64fddae785bd9 commit: b2dbcb184063104f750a407e0dbe3a4e0d3bfd9b Author: John Turner gmail com> AuthorDate: Fri Feb 23 01:38:29 2024 +0000 Commit: Sam James gentoo org> CommitDate: Thu Mar 7 18:49:06 2024 +0000 URL: https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=b2dbcb18 equery/depends: print output in module rather than with a callback The depends module can now iterate over the results of the graph_reverse_depends function and print the items as they are yielded. Before, it passed in a callback printer function, and expected the Dependencies class to call it correctly. This setup is nicer because it does not tie together this module and the Dependencies class, and the old setup most likely existed due to performance and interactivity concerns which are now fixed by turning graph_reverse_depends into an iterator. Signed-off-by: John Turner gmail.com> Signed-off-by: Sam James gentoo.org> pym/gentoolkit/equery/depends.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/pym/gentoolkit/equery/depends.py b/pym/gentoolkit/equery/depends.py index 8ec5f75..f92b7b9 100644 --- a/pym/gentoolkit/equery/depends.py +++ b/pym/gentoolkit/equery/depends.py @@ -17,7 +17,6 @@ import gentoolkit.pprinter as pp from gentoolkit.dependencies import Dependencies from gentoolkit.equery import format_options, mod_usage, CONFIG from gentoolkit.helpers import get_cpvs, get_installed_cpvs -from gentoolkit.cpv import CPV from gentoolkit.package import PackageFormatter, Package # ======= @@ -27,7 +26,7 @@ from gentoolkit.package import PackageFormatter, Package QUERY_OPTS = { "include_masked": False, "only_direct": True, - "max_depth": -1, + "max_depth": None, "package_format": None, } @@ -94,9 +93,9 @@ class DependPrinter: if dep_is_displayed and not self.verbose: return - depth = getattr(dep, "depth", 0) + depth = dep.depth indent = " " * depth - mdep = dep.matching_dep + mdep = dep.depatom use_conditional = "" if QUERY_OPTS["package_format"] != None: @@ -226,17 +225,25 @@ def main(input_args): if CONFIG["verbose"]: print(" * These packages depend on %s:" % pp.emph(pkg.cpv)) - if pkg.graph_reverse_depends( - pkgset=sorted(pkggetter(), key=CPV), - max_depth=QUERY_OPTS["max_depth"], + + first_run = False + + last_seen = None + for pkgdep in pkg.graph_reverse_depends( + pkgset=sorted(pkggetter()), only_direct=QUERY_OPTS["only_direct"], - printer_fn=dep_print, + max_depth=QUERY_OPTS["max_depth"], ): + if last_seen is None or last_seen != pkgdep: + seen = False + else: + seen = True + printer(pkgdep, dep_is_displayed=seen) + last_seen = pkgdep + if last_seen is not None: got_match = True - first_run = False - - if not got_match: + if got_match is None: sys.exit(1)