From: Zac Medico Date: Wed, 21 Jun 2006 04:14:34 +0000 (-0000) Subject: Implement get() as part of the standard mapping interface. This patch is from trunk... X-Git-Tag: v2.1-r1~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ba5212b0841e088a69e9de6680cc468be3a94452;p=portage.git Implement get() as part of the standard mapping interface. This patch is from trunk r3545. svn path=/main/branches/2.1/; revision=3580 --- diff --git a/pym/cache/template.py b/pym/cache/template.py index 097ebed8d..43f3c8a14 100644 --- a/pym/cache/template.py +++ b/pym/cache/template.py @@ -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