summaryrefslogtreecommitdiffstats
path: root/ipalib/public.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-08-11 17:57:07 +0000
committerJason Gerard DeRose <jderose@redhat.com>2008-08-11 17:57:07 +0000
commit8a6ece2ffbfc142beb1d08e09809c388b3ede160 (patch)
tree1f8837b5d9c93562560061a44acb95151abe1eba /ipalib/public.py
parentfd6c215d596912493fa582079a7ec6de45466446 (diff)
downloadfreeipa.git-8a6ece2ffbfc142beb1d08e09809c388b3ede160.tar.gz
freeipa.git-8a6ece2ffbfc142beb1d08e09809c388b3ede160.tar.xz
freeipa.git-8a6ece2ffbfc142beb1d08e09809c388b3ede160.zip
108: Changed cmd.default() so that it now only return dictionary of values for which defaults were generated; updated unit tests
Diffstat (limited to 'ipalib/public.py')
-rw-r--r--ipalib/public.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/ipalib/public.py b/ipalib/public.py
index 17d00f04..d1c4fa2a 100644
--- a/ipalib/public.py
+++ b/ipalib/public.py
@@ -183,16 +183,15 @@ class cmd(plugable.Plugin):
def normalize(self, **kw):
return dict(self.normalize_iter(kw))
- def default(self, **kw):
- d = {}
- for opt in self.options:
- if opt.name not in kw:
- value = opt.default(**kw)
+ def default_iter(self, kw):
+ for option in self.options:
+ if option.name not in kw:
+ value = option.default(**kw)
if value is not None:
- d[opt.name] = value
- assert not set(kw).intersection(d)
- kw.update(d)
- return kw
+ yield(option.name, value)
+
+ def default(self, **kw):
+ return dict(self.default_iter(kw))
def validate(self, **kw):
for (key, value) in kw.items():
@@ -201,7 +200,7 @@ class cmd(plugable.Plugin):
def __call__(self, **kw):
kw = self.normalize(**kw)
- kw = self.default(**kw)
+ kw.update(self.default(**kw))
self.validate(**kw)
self.execute(**kw)