summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-04-18 04:17:14 +0000
committerZac Medico <zmedico@gentoo.org>2006-04-18 04:17:14 +0000
commit115ceeab65078ada26e49220faa7e6c5e6addbbc (patch)
tree70f53af2b89175bfe055e1c50d7eb01661abbb83
parent7d914f78325182d6afadde535bf8c8d966c56729 (diff)
downloadportage-115ceeab65078ada26e49220faa7e6c5e6addbbc.tar.gz
portage-115ceeab65078ada26e49220faa7e6c5e6addbbc.tar.bz2
portage-115ceeab65078ada26e49220faa7e6c5e6addbbc.zip
Implement portage.config.setdefault() in order to provide more of the standard mapping interface.
svn path=/main/trunk/; revision=3172
-rw-r--r--pym/portage.py8
1 files changed, 8 insertions, 0 deletions
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]))