summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Luther <SebastianLuther@gmx.de>2011-01-31 23:35:40 +0100
committerZac Medico <zmedico@gentoo.org>2011-02-02 15:25:37 -0800
commit6203db15eb4da02bb96c6fbfc998784adc5b6c4d (patch)
tree4fec736123fb9085fd1d3bd9fadbb98b8c867e14
parent2c82906d6f1a988721603e6418bd8438b29e5428 (diff)
downloadportage-6203db15eb4da02bb96c6fbfc998784adc5b6c4d.tar.gz
portage-6203db15eb4da02bb96c6fbfc998784adc5b6c4d.tar.bz2
portage-6203db15eb4da02bb96c6fbfc998784adc5b6c4d.zip
Print near matches for cmd line atoms without matching ebuild
-rw-r--r--pym/_emerge/depgraph.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py
index 37615a1ee..0c56e35ef 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
@@ -2348,6 +2349,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:
@@ -2614,6 +2617,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):