diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-08 19:53:45 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-08 19:53:45 +0000 |
commit | d171dc90111cad91884c3a1b3afdb8b16b7c289e (patch) | |
tree | d23cd4b163c99ec1cfa57934f6426632c3d9c8ec /ipalib/public.py | |
parent | 8e468248155947075689e6d01c3ab90fbd9f1643 (diff) | |
download | freeipa.git-d171dc90111cad91884c3a1b3afdb8b16b7c289e.tar.gz freeipa.git-d171dc90111cad91884c3a1b3afdb8b16b7c289e.tar.xz freeipa.git-d171dc90111cad91884c3a1b3afdb8b16b7c289e.zip |
82: Cleaned up unit tests for public.option; added some doodles in plugable.Base
Diffstat (limited to 'ipalib/public.py')
-rw-r--r-- | ipalib/public.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/ipalib/public.py b/ipalib/public.py index 6f7f2154..1c6f9e7f 100644 --- a/ipalib/public.py +++ b/ipalib/public.py @@ -102,7 +102,7 @@ class option(object): def __rules_iter(self): """ Iterates through the attributes in this instance to retrieve the - methods implemented validation rules. + methods implementing validation rules. """ for name in dir(self.__class__): if name.startswith('_'): @@ -117,6 +117,10 @@ class option(object): """ Returns a default or auto-completed value for this option. If no default is available, this method should return None. + + All the keywords are passed so it's possible to build an + auto-completed value from other options values, e.g., build 'initials' + from 'givenname' + 'sn'. """ return None @@ -177,11 +181,15 @@ class cmd(plugable.Plugin): self.options.validate(value) def default(self, **kw): + d = {} for opt in self.options: if opt.name not in kw: value = opt.default(**kw) if value is not None: - kw[opt.name] = value + d[opt.name] = value + assert not set(kw).intersection(d) + kw.update(d) + return kw def __call__(self, **kw): (args, kw) = self.normalize(*args, **kw) |