public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Thomas Sachau" <tommy@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:multilib commit in: pym/_emerge/
Date: Sun,  6 Feb 2011 13:09:57 +0000 (UTC)	[thread overview]
Message-ID: <aa78cc8da18015b7d1e4eec277b5a7f940fe357c.tommy@gentoo> (raw)

commit:     aa78cc8da18015b7d1e4eec277b5a7f940fe357c
Author:     Sebastian Luther <SebastianLuther <AT> gmx <DOT> de>
AuthorDate: Mon Jan 31 22:35:40 2011 +0000
Commit:     Thomas Sachau <tommy <AT> gentoo <DOT> org>
CommitDate: Mon Jan 31 22:43:06 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=aa78cc8d

Print near matches for cmd line atoms without matching ebuild

---
 pym/_emerge/depgraph.py |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 4f60a3a..39c6395 100644
--- a/pym/_emerge/depgraph.py
+++ b/pym/_emerge/depgraph.py
@@ -3,6 +3,7 @@
 
 from __future__ import print_function
 
+import difflib
 import gc
 import logging
 import re
@@ -2336,6 +2337,8 @@ class depgraph(object):
 		pkgsettings = self._frozen_config.pkgsettings[root]
 		root_config = self._frozen_config.roots[root]
 		portdb = self._frozen_config.roots[root].trees["porttree"].dbapi
+		vardb = self._frozen_config.roots[root].trees["vartree"].dbapi
+		bindb = self._frozen_config.roots[root].trees["bintree"].dbapi
 		dbs = self._dynamic_config._filtered_trees[root]["dbs"]
 		for db, pkg_type, built, installed, db_keys in dbs:
 			if installed:
@@ -2610,6 +2613,36 @@ class depgraph(object):
 			mask_docs = True
 		else:
 			writemsg_stdout("\nemerge: there are no ebuilds to satisfy "+green(xinfo)+".\n", noiselevel=-1)
+			if isinstance(myparent, AtomArg):
+				cp = myparent.atom.cp
+				cat, pkg = cp.split("/")
+				if cat == "null":
+					cat = None
+
+				all_cp = set()
+				all_cp.update(vardb.cp_all())
+				all_cp.update(portdb.cp_all())
+				if "--usepkg" in self._frozen_config.myopts:
+					all_cp.update(bindb.cp_all())
+
+				if cat:
+					matches = difflib.get_close_matches(cp, all_cp)
+				else:
+					pkg_to_cp = {}
+					for other_cp in all_cp:
+						other_pkg = other_cp.split("/")[1]
+						pkg_to_cp.setdefault(other_pkg, set()).add(other_cp)
+					pkg_matches = difflib.get_close_matches(pkg, pkg_to_cp)
+					matches = []
+					for pkg_match in pkg_matches:
+						matches.extend(pkg_to_cp[pkg_match])
+
+				if len(matches) == 1:
+					writemsg_stdout("emerge: Maybe you meant " + matches[0] + "?\n"
+						, noiselevel=-1)
+				elif len(matches) > 1:
+					writemsg_stdout("emerge: Maybe you meant any of these: " + ", ".join(matches) + "?\n"
+						, noiselevel=-1)
 
 		msg = []
 		if not isinstance(myparent, AtomArg):



             reply	other threads:[~2011-02-06 13:16 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-06 13:09 Thomas Sachau [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-05-23 12:46 [gentoo-commits] proj/portage:multilib commit in: pym/_emerge/ Thomas Sachau
2013-08-04 22:08 Thomas Sachau
2013-08-04 20:23 Thomas Sachau
2012-11-30 16:58 Thomas Sachau
2012-11-30 16:49 Thomas Sachau
2012-10-22  9:43 Thomas Sachau
2012-10-22  9:24 Thomas Sachau
2012-09-17 20:15 Thomas Sachau
2012-07-19 21:03 Zac Medico
2012-02-26 16:27 Thomas Sachau
2012-02-26 16:27 Thomas Sachau
2012-02-26 16:27 Thomas Sachau
2012-02-26 16:27 Thomas Sachau
2012-02-26 16:27 Thomas Sachau
2012-02-18 16:14 Thomas Sachau
2011-11-15 20:20 Thomas Sachau
2011-10-23 11:42 Thomas Sachau
2011-10-23 11:05 Thomas Sachau
2011-02-06 13:10 Thomas Sachau
2011-02-06 13:10 Thomas Sachau
2011-02-06 13:10 Thomas Sachau
2011-02-06 13:10 Thomas Sachau
2011-02-06 13:10 Thomas Sachau
2011-02-06 13:10 Thomas Sachau
2011-02-06 13:10 Thomas Sachau
2011-02-06 13:10 Thomas Sachau
2011-02-06 13:10 Thomas Sachau
2011-02-06 13:10 Thomas Sachau
2011-02-06 13:10 Thomas Sachau
2011-02-06 13:10 Thomas Sachau
2011-02-06 13:10 Thomas Sachau
2011-02-06 13:10 Thomas Sachau
2011-02-06 13:10 Thomas Sachau
2011-02-06 13:09 Thomas Sachau
2011-02-06 13:09 Thomas Sachau
2011-02-06 13:09 Thomas Sachau
2011-02-06 13:09 Thomas Sachau
2011-02-06 13:09 Thomas Sachau
2011-02-06 13:09 Thomas Sachau
2011-02-06 13:09 Thomas Sachau
2011-02-06 13:09 Thomas Sachau
2011-02-06 13:09 Thomas Sachau
2011-02-06 13:09 Thomas Sachau
2011-02-06 13:09 Thomas Sachau

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=aa78cc8da18015b7d1e4eec277b5a7f940fe357c.tommy@gentoo \
    --to=tommy@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