1 |
commit: 372d0e0dced3f94ba619e722e8a87f0256d52aea |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Nov 24 22:08:23 2012 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Nov 24 22:08:23 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=372d0e0d |
7 |
|
8 |
emerge --info: search similar names, bug #444596 |
9 |
|
10 |
--- |
11 |
pym/_emerge/actions.py | 35 +++++++++++++++++++++++++++++++++-- |
12 |
1 files changed, 33 insertions(+), 2 deletions(-) |
13 |
|
14 |
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py |
15 |
index b1feba6..cd52ddb 100644 |
16 |
--- a/pym/_emerge/actions.py |
17 |
+++ b/pym/_emerge/actions.py |
18 |
@@ -22,6 +22,7 @@ from itertools import chain |
19 |
|
20 |
import portage |
21 |
portage.proxy.lazyimport.lazyimport(globals(), |
22 |
+ 'portage.dbapi._similar_name_search:similar_name_search', |
23 |
'portage.debug', |
24 |
'portage.news:count_unread_news,display_news_notifications', |
25 |
'_emerge.chk_updated_cfg_files:chk_updated_cfg_files', |
26 |
@@ -1366,6 +1367,7 @@ def action_info(settings, trees, myopts, myfiles): |
27 |
bindb = trees[eroot]["bintree"].dbapi |
28 |
for x in myfiles: |
29 |
match_found = False |
30 |
+ cp_exists = False |
31 |
installed_match = vardb.match(x) |
32 |
for installed in installed_match: |
33 |
mypkgs.append((installed, "installed")) |
34 |
@@ -1378,6 +1380,9 @@ def action_info(settings, trees, myopts, myfiles): |
35 |
if pkg_type == "binary" and "--usepkg" not in myopts: |
36 |
continue |
37 |
|
38 |
+ if not cp_exists and db.cp_list(x.cp): |
39 |
+ cp_exists = True |
40 |
+ |
41 |
matches = db.match(x) |
42 |
matches.reverse() |
43 |
for match in matches: |
44 |
@@ -1400,8 +1405,34 @@ def action_info(settings, trees, myopts, myfiles): |
45 |
xinfo = "%s for %s" % (xinfo, eroot) |
46 |
writemsg("\nemerge: there are no ebuilds to satisfy %s.\n" % |
47 |
colorize("INFORM", xinfo), noiselevel=-1) |
48 |
- # TODO: Split out --misspell-suggestions code from depgraph |
49 |
- # and call it here. |
50 |
+ |
51 |
+ if not cp_exists and myopts.get( |
52 |
+ "--misspell-suggestions", "y") != "n": |
53 |
+ |
54 |
+ writemsg("\nemerge: searching for similar names..." |
55 |
+ , noiselevel=-1) |
56 |
+ |
57 |
+ dbs = [vardb] |
58 |
+ #if "--usepkgonly" not in myopts: |
59 |
+ dbs.append(portdb) |
60 |
+ if "--usepkg" in myopts: |
61 |
+ dbs.append(bindb) |
62 |
+ |
63 |
+ matches = similar_name_search(dbs, x) |
64 |
+ |
65 |
+ if len(matches) == 1: |
66 |
+ writemsg("\nemerge: Maybe you meant " + matches[0] + "?\n" |
67 |
+ , noiselevel=-1) |
68 |
+ elif len(matches) > 1: |
69 |
+ writemsg( |
70 |
+ "\nemerge: Maybe you meant any of these: %s?\n" % \ |
71 |
+ (", ".join(matches),), noiselevel=-1) |
72 |
+ else: |
73 |
+ # Generally, this would only happen if |
74 |
+ # all dbapis are empty. |
75 |
+ writemsg(" nothing similar found.\n" |
76 |
+ , noiselevel=-1) |
77 |
+ |
78 |
return 1 |
79 |
|
80 |
output_buffer = [] |