Gentoo Archives: gentoo-commits

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