public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] portage r12013 - main/branches/2.1.6/pym/_emerge
@ 2008-11-21  2:49 Zac Medico (zmedico)
  0 siblings, 0 replies; only message in thread
From: Zac Medico (zmedico) @ 2008-11-21  2:49 UTC (permalink / raw
  To: gentoo-commits

Author: zmedico
Date: 2008-11-21 02:49:10 +0000 (Fri, 21 Nov 2008)
New Revision: 12013

Modified:
   main/branches/2.1.6/pym/_emerge/__init__.py
Log:
When given an ambiguous ebuild name to install, format the list of choices
in emerge --search format if --quiet mode is not enabled, otherwise just show
a brief list. Thanks to Markus Meier <maekke@g.o> for the suggestion. (trunk
r12012)


Modified: main/branches/2.1.6/pym/_emerge/__init__.py
===================================================================
--- main/branches/2.1.6/pym/_emerge/__init__.py	2008-11-21 02:46:56 UTC (rev 12012)
+++ main/branches/2.1.6/pym/_emerge/__init__.py	2008-11-21 02:49:10 UTC (rev 12013)
@@ -426,6 +426,8 @@
 		self.searchdesc = searchdesc
 		self.root_config = root_config
 		self.setconfig = root_config.setconfig
+		self.matches = {"pkg" : []}
+		self.mlen = 0
 
 		def fake_portdb():
 			pass
@@ -542,7 +544,7 @@
 					if not result or cpv == portage.best([cpv, result]):
 						result = cpv
 				else:
-					db_keys = list(db._aux_cache_keys)
+					db_keys = Package.metadata_keys
 					# break out of this loop with highest visible
 					# match, checked in descending order
 					for cpv in reversed(db.match(atom)):
@@ -620,6 +622,15 @@
 			self.matches[mtype].sort()
 			self.mlen += len(self.matches[mtype])
 
+	def addCP(self, cp):
+		if not self.portdb.xmatch("match-all", cp):
+			return
+		masked = 0
+		if not self.portdb.xmatch("bestmatch-visible", cp):
+			masked = 1
+		self.matches["pkg"].append([cp, masked])
+		self.mlen += 1
+
 	def output(self):
 		"""Outputs the results of the search."""
 		print "\b\b  \n[ Results for search key : "+white(self.searchkey)+" ]"
@@ -710,7 +721,6 @@
 						print "     ", darkgreen("Description:")+"  ",desc
 						print "     ", darkgreen("License:")+"      ",license
 						print
-		print
 	#
 	# private interface
 	#
@@ -5007,13 +5017,10 @@
 						if portage.dep_getkey(atom) == installed_cp]
 
 				if len(expanded_atoms) > 1:
-					print "\n\n!!! The short ebuild name \"" + x + "\" is ambiguous.  Please specify"
-					print "!!! one of the following fully-qualified ebuild names instead:\n"
-					expanded_atoms = set(portage.dep_getkey(atom) \
-						for atom in expanded_atoms)
-					for i in sorted(expanded_atoms):
-						print "    " + green(i)
 					print
+					print
+					ambiguous_package_name(x, expanded_atoms, root_config,
+						self.spinner, self.myopts)
 					return False, myfavorites
 				if expanded_atoms:
 					atom = expanded_atoms[0]
@@ -13408,6 +13415,28 @@
 
 	return bool(missing_repo_names)
 
+def ambiguous_package_name(arg, atoms, root_config, spinner, myopts):
+
+	if "--quiet" in myopts:
+		print "!!! The short ebuild name \"%s\" is ambiguous. Please specify" % arg
+		print "!!! one of the following fully-qualified ebuild names instead:\n"
+		for cp in sorted(set(portage.dep_getkey(atom) for atom in atoms)):
+			print "    " + colorize("INFORM", cp)
+		return
+
+	s = search(root_config, spinner, "--searchdesc" in myopts,
+		"--quiet" not in myopts, "--usepkg" in myopts,
+		"--usepkgonly" in myopts)
+	null_cp = portage.dep_getkey(insert_category_into_atom(
+		arg, "null"))
+	cat, atom_pn = portage.catsplit(null_cp)
+	s.searchkey = atom_pn
+	for cp in sorted(set(portage.dep_getkey(atom) for atom in atoms)):
+		s.addCP(cp)
+	s.output()
+	print "!!! The short ebuild name \"%s\" is ambiguous. Please specify" % arg
+	print "!!! one of the above fully-qualified ebuild names instead.\n"
+
 def emerge_main():
 	global portage	# NFC why this is necessary now - genone
 	portage._disable_legacy_globals()




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-11-21  2:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-21  2:49 [gentoo-commits] portage r12013 - main/branches/2.1.6/pym/_emerge Zac Medico (zmedico)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox