From 115ceeab65078ada26e49220faa7e6c5e6addbbc Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 18 Apr 2006 04:17:14 +0000 Subject: [PATCH] Implement portage.config.setdefault() in order to provide more of the standard mapping interface. svn path=/main/trunk/; revision=3172 --- pym/portage.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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])) -- 2.26.2