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

Author: zmedico
Date: 2008-06-06 00:22:35 +0000 (Fri, 06 Jun 2008)
New Revision: 10588

Modified:
   main/trunk/pym/_emerge/__init__.py
Log:
Add a PackageVirtualDbapi.__getitem__() method.


Modified: main/trunk/pym/_emerge/__init__.py
===================================================================
--- main/trunk/pym/_emerge/__init__.py	2008-06-05 23:35:23 UTC (rev 10587)
+++ main/trunk/pym/_emerge/__init__.py	2008-06-06 00:22:35 UTC (rev 10588)
@@ -1788,6 +1788,21 @@
 			return True
 		return False
 
+	def __getitem__(self, k):
+		cpv = getattr(k, "cpv", None)
+		if cpv is None:
+			try:
+				cpv = k[2]
+			except (TypeError, IndexError):
+				raise KeyError(k)
+		if cpv is None:
+			raise KeyError(k)
+		existing = self._cpv_map.get(cpv)
+		if existing is not None and \
+			existing == k:
+			return existing
+		raise KeyError(k)
+
 	def match_pkgs(self, atom):
 		return [self._cpv_map[cpv] for cpv in self.match(atom)]
 

-- 
gentoo-commits@lists.gentoo.org mailing list



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

only message in thread, other threads:[~2008-06-06  0:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-06  0:22 [gentoo-commits] portage r10588 - main/trunk/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