summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-06-06 00:22:35 +0000
committerZac Medico <zmedico@gentoo.org>2008-06-06 00:22:35 +0000
commit741db623a079e3a0b767fb1c8f0b9fae6789285e (patch)
treef9ba7ea06848a579d50c90657abc521308fabd6e
parentcdf64ca00c31ee0370ffa71ef74b53624b660678 (diff)
downloadportage-741db623a079e3a0b767fb1c8f0b9fae6789285e.tar.gz
portage-741db623a079e3a0b767fb1c8f0b9fae6789285e.tar.bz2
portage-741db623a079e3a0b767fb1c8f0b9fae6789285e.zip
Add a PackageVirtualDbapi.__getitem__() method.
svn path=/main/trunk/; revision=10588
-rw-r--r--pym/_emerge/__init__.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index 913c0d35e..1b5de6641 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -1788,6 +1788,21 @@ class PackageVirtualDbapi(portage.dbapi):
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)]