summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-11-24 14:08:23 -0800
committerZac Medico <zmedico@gentoo.org>2012-11-24 14:08:23 -0800
commit372d0e0dced3f94ba619e722e8a87f0256d52aea (patch)
tree76c0bb76ae59934248014db55bb94ed1bda2b53f
parentabd18694835b9f8a5a515f9c6333a754703a0462 (diff)
downloadportage-372d0e0dced3f94ba619e722e8a87f0256d52aea.tar.gz
portage-372d0e0dced3f94ba619e722e8a87f0256d52aea.tar.bz2
portage-372d0e0dced3f94ba619e722e8a87f0256d52aea.zip
emerge --info: search similar names, bug #444596
-rw-r--r--pym/_emerge/actions.py35
1 files changed, 33 insertions, 2 deletions
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index b1feba65d..cd52ddb1b 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -22,6 +22,7 @@ from itertools import chain
import portage
portage.proxy.lazyimport.lazyimport(globals(),
+ 'portage.dbapi._similar_name_search:similar_name_search',
'portage.debug',
'portage.news:count_unread_news,display_news_notifications',
'_emerge.chk_updated_cfg_files:chk_updated_cfg_files',
@@ -1366,6 +1367,7 @@ def action_info(settings, trees, myopts, myfiles):
bindb = trees[eroot]["bintree"].dbapi
for x in myfiles:
match_found = False
+ cp_exists = False
installed_match = vardb.match(x)
for installed in installed_match:
mypkgs.append((installed, "installed"))
@@ -1378,6 +1380,9 @@ def action_info(settings, trees, myopts, myfiles):
if pkg_type == "binary" and "--usepkg" not in myopts:
continue
+ if not cp_exists and db.cp_list(x.cp):
+ cp_exists = True
+
matches = db.match(x)
matches.reverse()
for match in matches:
@@ -1400,8 +1405,34 @@ def action_info(settings, trees, myopts, myfiles):
xinfo = "%s for %s" % (xinfo, eroot)
writemsg("\nemerge: there are no ebuilds to satisfy %s.\n" %
colorize("INFORM", xinfo), noiselevel=-1)
- # TODO: Split out --misspell-suggestions code from depgraph
- # and call it here.
+
+ if not cp_exists and myopts.get(
+ "--misspell-suggestions", "y") != "n":
+
+ writemsg("\nemerge: searching for similar names..."
+ , noiselevel=-1)
+
+ dbs = [vardb]
+ #if "--usepkgonly" not in myopts:
+ dbs.append(portdb)
+ if "--usepkg" in myopts:
+ dbs.append(bindb)
+
+ matches = similar_name_search(dbs, x)
+
+ if len(matches) == 1:
+ writemsg("\nemerge: Maybe you meant " + matches[0] + "?\n"
+ , noiselevel=-1)
+ elif len(matches) > 1:
+ writemsg(
+ "\nemerge: Maybe you meant any of these: %s?\n" % \
+ (", ".join(matches),), noiselevel=-1)
+ else:
+ # Generally, this would only happen if
+ # all dbapis are empty.
+ writemsg(" nothing similar found.\n"
+ , noiselevel=-1)
+
return 1
output_buffer = []