1 |
Author: zmedico |
2 |
Date: 2008-11-21 02:46:56 +0000 (Fri, 21 Nov 2008) |
3 |
New Revision: 12012 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/_emerge/__init__.py |
7 |
Log: |
8 |
When given an ambiguous ebuild name to install, format the list of choices |
9 |
in emerge --search format if --quiet mode is not enabled, otherwise just show |
10 |
a brief list. Thanks to Markus Meier <maekke@g.o> for the suggestion. |
11 |
|
12 |
|
13 |
Modified: main/trunk/pym/_emerge/__init__.py |
14 |
=================================================================== |
15 |
--- main/trunk/pym/_emerge/__init__.py 2008-11-20 22:43:07 UTC (rev 12011) |
16 |
+++ main/trunk/pym/_emerge/__init__.py 2008-11-21 02:46:56 UTC (rev 12012) |
17 |
@@ -426,6 +426,8 @@ |
18 |
self.searchdesc = searchdesc |
19 |
self.root_config = root_config |
20 |
self.setconfig = root_config.setconfig |
21 |
+ self.matches = {"pkg" : []} |
22 |
+ self.mlen = 0 |
23 |
|
24 |
def fake_portdb(): |
25 |
pass |
26 |
@@ -542,7 +544,7 @@ |
27 |
if not result or cpv == portage.best([cpv, result]): |
28 |
result = cpv |
29 |
else: |
30 |
- db_keys = list(db._aux_cache_keys) |
31 |
+ db_keys = Package.metadata_keys |
32 |
# break out of this loop with highest visible |
33 |
# match, checked in descending order |
34 |
for cpv in reversed(db.match(atom)): |
35 |
@@ -635,6 +637,15 @@ |
36 |
self.matches[mtype].sort() |
37 |
self.mlen += len(self.matches[mtype]) |
38 |
|
39 |
+ def addCP(self, cp): |
40 |
+ if not self.portdb.xmatch("match-all", cp): |
41 |
+ return |
42 |
+ masked = 0 |
43 |
+ if not self.portdb.xmatch("bestmatch-visible", cp): |
44 |
+ masked = 1 |
45 |
+ self.matches["pkg"].append([cp, masked]) |
46 |
+ self.mlen += 1 |
47 |
+ |
48 |
def output(self): |
49 |
"""Outputs the results of the search.""" |
50 |
print "\b\b \n[ Results for search key : "+white(self.searchkey)+" ]" |
51 |
@@ -729,7 +740,6 @@ |
52 |
print " ", darkgreen("Description:")+" ",desc |
53 |
print " ", darkgreen("License:")+" ",license |
54 |
print |
55 |
- print |
56 |
# |
57 |
# private interface |
58 |
# |
59 |
@@ -5023,13 +5033,10 @@ |
60 |
if portage.dep_getkey(atom) == installed_cp] |
61 |
|
62 |
if len(expanded_atoms) > 1: |
63 |
- print "\n\n!!! The short ebuild name \"" + x + "\" is ambiguous. Please specify" |
64 |
- print "!!! one of the following fully-qualified ebuild names instead:\n" |
65 |
- expanded_atoms = set(portage.dep_getkey(atom) \ |
66 |
- for atom in expanded_atoms) |
67 |
- for i in sorted(expanded_atoms): |
68 |
- print " " + green(i) |
69 |
print |
70 |
+ print |
71 |
+ ambiguous_package_name(x, expanded_atoms, root_config, |
72 |
+ self.spinner, self.myopts) |
73 |
return False, myfavorites |
74 |
if expanded_atoms: |
75 |
atom = expanded_atoms[0] |
76 |
@@ -13871,6 +13878,28 @@ |
77 |
|
78 |
return bool(missing_repo_names) |
79 |
|
80 |
+def ambiguous_package_name(arg, atoms, root_config, spinner, myopts): |
81 |
+ |
82 |
+ if "--quiet" in myopts: |
83 |
+ print "!!! The short ebuild name \"%s\" is ambiguous. Please specify" % arg |
84 |
+ print "!!! one of the following fully-qualified ebuild names instead:\n" |
85 |
+ for cp in sorted(set(portage.dep_getkey(atom) for atom in atoms)): |
86 |
+ print " " + colorize("INFORM", cp) |
87 |
+ return |
88 |
+ |
89 |
+ s = search(root_config, spinner, "--searchdesc" in myopts, |
90 |
+ "--quiet" not in myopts, "--usepkg" in myopts, |
91 |
+ "--usepkgonly" in myopts) |
92 |
+ null_cp = portage.dep_getkey(insert_category_into_atom( |
93 |
+ arg, "null")) |
94 |
+ cat, atom_pn = portage.catsplit(null_cp) |
95 |
+ s.searchkey = atom_pn |
96 |
+ for cp in sorted(set(portage.dep_getkey(atom) for atom in atoms)): |
97 |
+ s.addCP(cp) |
98 |
+ s.output() |
99 |
+ print "!!! The short ebuild name \"%s\" is ambiguous. Please specify" % arg |
100 |
+ print "!!! one of the above fully-qualified ebuild names instead.\n" |
101 |
+ |
102 |
def emerge_main(): |
103 |
global portage # NFC why this is necessary now - genone |
104 |
portage._disable_legacy_globals() |