diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-04 08:33:41 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-04 08:33:41 +0000 |
commit | 6f95249d5274258d0935a439407f38030205bf65 (patch) | |
tree | fa4373a38ad5360b0c5989c993c80fb50d9d852b | |
parent | 915486dadc476df4915cefdfeb8d61c43664ca60 (diff) | |
download | freeipa.git-6f95249d5274258d0935a439407f38030205bf65.tar.gz freeipa.git-6f95249d5274258d0935a439407f38030205bf65.tar.xz freeipa.git-6f95249d5274258d0935a439407f38030205bf65.zip |
261: More work on demo using Option.__call__() for interactive input
-rw-r--r-- | ipalib/cli.py | 2 | ||||
-rw-r--r-- | ipalib/public.py | 11 |
2 files changed, 9 insertions, 4 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py index d199f721..abaef030 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -164,7 +164,7 @@ class CLI(object): print '>>> %s: %s' % (option.name, error) raw = raw_input(prompt) try: - value = option(raw) + value = option(raw, **kw) if value is not None: kw[option.name] = value break diff --git a/ipalib/public.py b/ipalib/public.py index d1f2ff35..7734bf7a 100644 --- a/ipalib/public.py +++ b/ipalib/public.py @@ -164,7 +164,10 @@ class Option(plugable.ReadOnly): if self.default_from is not None: default = self.default_from(**kw) if default is not None: - return self.convert(default) + try: + return self.convert(self.normalize(default)) + except errors.ValidationError: + return None return self.default def get_values(self): @@ -179,10 +182,12 @@ class Option(plugable.ReadOnly): value = self.get_default(**kw) if value is None: if self.required: - raise RequirementError(option.name) + raise errors.RequirementError(self.name) return None else: - pass + value = self.convert(self.normalize(value)) + self.validate(value) + return value class Command(plugable.Plugin): |