Implement get() as part of the standard mapping interface. This patch is from trunk...
authorZac Medico <zmedico@gentoo.org>
Wed, 21 Jun 2006 04:14:34 +0000 (04:14 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 21 Jun 2006 04:14:34 +0000 (04:14 -0000)
svn path=/main/branches/2.1/; revision=3580

pym/cache/template.py

index 097ebed8d623fbe3303f36a1a5c180b86035a8fc..43f3c8a14ae60c1a726edc6ea31b577e1ba824c9 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