public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/equery/
Date: Thu,  7 Mar 2024 18:49:16 +0000 (UTC)	[thread overview]
Message-ID: <1709837346.b2dbcb184063104f750a407e0dbe3a4e0d3bfd9b.sam@gentoo> (raw)

commit:     b2dbcb184063104f750a407e0dbe3a4e0d3bfd9b
Author:     John Turner <jturner.usa <AT> gmail <DOT> com>
AuthorDate: Fri Feb 23 01:38:29 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> 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 <jturner.usa <AT> gmail.com>
Signed-off-by: Sam James <sam <AT> 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)
 
 


             reply	other threads:[~2024-03-07 18:49 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-07 18:49 Sam James [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-03-07 18:49 [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/equery/ Sam James
2023-09-19 19:13 Sam James
2023-08-05  5:38 Sam James
2023-07-18 22:30 Sam James
2023-07-18 22:26 Sam James
2022-07-28 15:29 Brian Dolbec
2022-07-28 15:29 Brian Dolbec
2022-07-10 18:41 Brian Dolbec
2022-07-10 18:01 Brian Dolbec
2022-07-10 16:23 Brian Dolbec
2022-07-10 16:23 Brian Dolbec
2022-07-10  1:24 Brian Dolbec
2022-07-09  5:17 Sam James
2018-05-01 12:32 Mike Pagano
2017-09-05 15:32 Mike Gilbert
2016-06-30 23:36 Paul Varner
2016-06-30 20:44 Paul Varner
2016-06-06 19:29 Brian Dolbec
2015-11-09 20:52 Brian Dolbec
2015-11-09  2:42 Brian Dolbec
2015-11-08 17:37 Brian Dolbec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1709837346.b2dbcb184063104f750a407e0dbe3a4e0d3bfd9b.sam@gentoo \
    --to=sam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox