1 |
commit: aa78cc8da18015b7d1e4eec277b5a7f940fe357c |
2 |
Author: Sebastian Luther <SebastianLuther <AT> gmx <DOT> de> |
3 |
AuthorDate: Mon Jan 31 22:35:40 2011 +0000 |
4 |
Commit: Thomas Sachau <tommy <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Jan 31 22:43:06 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=aa78cc8d |
7 |
|
8 |
Print near matches for cmd line atoms without matching ebuild |
9 |
|
10 |
--- |
11 |
pym/_emerge/depgraph.py | 33 +++++++++++++++++++++++++++++++++ |
12 |
1 files changed, 33 insertions(+), 0 deletions(-) |
13 |
|
14 |
diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py |
15 |
index 4f60a3a..39c6395 100644 |
16 |
--- a/pym/_emerge/depgraph.py |
17 |
+++ b/pym/_emerge/depgraph.py |
18 |
@@ -3,6 +3,7 @@ |
19 |
|
20 |
from __future__ import print_function |
21 |
|
22 |
+import difflib |
23 |
import gc |
24 |
import logging |
25 |
import re |
26 |
@@ -2336,6 +2337,8 @@ class depgraph(object): |
27 |
pkgsettings = self._frozen_config.pkgsettings[root] |
28 |
root_config = self._frozen_config.roots[root] |
29 |
portdb = self._frozen_config.roots[root].trees["porttree"].dbapi |
30 |
+ vardb = self._frozen_config.roots[root].trees["vartree"].dbapi |
31 |
+ bindb = self._frozen_config.roots[root].trees["bintree"].dbapi |
32 |
dbs = self._dynamic_config._filtered_trees[root]["dbs"] |
33 |
for db, pkg_type, built, installed, db_keys in dbs: |
34 |
if installed: |
35 |
@@ -2610,6 +2613,36 @@ class depgraph(object): |
36 |
mask_docs = True |
37 |
else: |
38 |
writemsg_stdout("\nemerge: there are no ebuilds to satisfy "+green(xinfo)+".\n", noiselevel=-1) |
39 |
+ if isinstance(myparent, AtomArg): |
40 |
+ cp = myparent.atom.cp |
41 |
+ cat, pkg = cp.split("/") |
42 |
+ if cat == "null": |
43 |
+ cat = None |
44 |
+ |
45 |
+ all_cp = set() |
46 |
+ all_cp.update(vardb.cp_all()) |
47 |
+ all_cp.update(portdb.cp_all()) |
48 |
+ if "--usepkg" in self._frozen_config.myopts: |
49 |
+ all_cp.update(bindb.cp_all()) |
50 |
+ |
51 |
+ if cat: |
52 |
+ matches = difflib.get_close_matches(cp, all_cp) |
53 |
+ else: |
54 |
+ pkg_to_cp = {} |
55 |
+ for other_cp in all_cp: |
56 |
+ other_pkg = other_cp.split("/")[1] |
57 |
+ pkg_to_cp.setdefault(other_pkg, set()).add(other_cp) |
58 |
+ pkg_matches = difflib.get_close_matches(pkg, pkg_to_cp) |
59 |
+ matches = [] |
60 |
+ for pkg_match in pkg_matches: |
61 |
+ matches.extend(pkg_to_cp[pkg_match]) |
62 |
+ |
63 |
+ if len(matches) == 1: |
64 |
+ writemsg_stdout("emerge: Maybe you meant " + matches[0] + "?\n" |
65 |
+ , noiselevel=-1) |
66 |
+ elif len(matches) > 1: |
67 |
+ writemsg_stdout("emerge: Maybe you meant any of these: " + ", ".join(matches) + "?\n" |
68 |
+ , noiselevel=-1) |
69 |
|
70 |
msg = [] |
71 |
if not isinstance(myparent, AtomArg): |