Implement get() as part of the standard mapping interface.
authorZac Medico <zmedico@gentoo.org>
Tue, 20 Jun 2006 22:23:10 +0000 (22:23 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 20 Jun 2006 22:23:10 +0000 (22:23 -0000)
svn path=/main/trunk/; revision=3545

pym/cache/template.py

index 419ec08a403dfbfe5d6a0c76d1dbe9ddad959895..7389a142e6a9621d270da8db98b3d4dd77b78f39 100644 (file)
@@ -115,6 +115,12 @@ class database(object):
        def __contains__(self, cpv):
                return self.has_key(cpv)
 
+       def get(self, k, x=None):
+               try:
+                       return self[k]
+               except KeyError:
+                       return x
+
        def get_matches(self, match_dict):
                """generic function for walking the entire cache db, matching restrictions to
                filter what cpv's are returned.  Derived classes should override this if they