From: Zac Medico Date: Tue, 18 Apr 2006 04:17:14 +0000 (-0000) Subject: Implement portage.config.setdefault() in order to provide more of the standard mappin... X-Git-Tag: v2.1_pre10~101 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=115ceeab65078ada26e49220faa7e6c5e6addbbc;p=portage.git Implement portage.config.setdefault() in order to provide more of the standard mapping interface. svn path=/main/trunk/; revision=3172 --- diff --git a/pym/portage.py b/pym/portage.py index 7a8258547..3c026ebc6 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -1615,6 +1615,14 @@ class config: """Called to implement membership test operators (in and not in).""" return bool(self.has_key(mykey)) + def setdefault(self, k, x=None): + if k in self: + return self[k] + else: + myvalue = x + self[k] = x + return myvalue + def keys(self): return unique_array(flatten([x.keys() for x in self.lookuplist]))