Implement portage.config.setdefault() in order to provide more of the standard mappin...
authorZac Medico <zmedico@gentoo.org>
Tue, 18 Apr 2006 04:17:14 +0000 (04:17 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 18 Apr 2006 04:17:14 +0000 (04:17 -0000)
svn path=/main/trunk/; revision=3172

pym/portage.py

index 7a8258547b6b9adc763b7e62b3a8f59eadc3218a..3c026ebc62c9e6ed88cd860782e1c0a639b7b2d2 100644 (file)
@@ -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]))