diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-04 02:30:40 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-04 02:30:40 +0000 |
commit | cf7e4c1038a5240f00342d284cf7a6be812322b4 (patch) | |
tree | c15b3ad44d6766fc2abbf8419074396ebbacc0f7 /ipalib/public.py | |
parent | 5cdb182ae8e87f4d3e84bbf7875357c101ca605e (diff) | |
download | freeipa.git-cf7e4c1038a5240f00342d284cf7a6be812322b4.tar.gz freeipa.git-cf7e4c1038a5240f00342d284cf7a6be812322b4.tar.xz freeipa.git-cf7e4c1038a5240f00342d284cf7a6be812322b4.zip |
252: Added Command.convert() method; added corresponding unit tests
Diffstat (limited to 'ipalib/public.py')
-rw-r--r-- | ipalib/public.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/ipalib/public.py b/ipalib/public.py index c64e29d5..045f1012 100644 --- a/ipalib/public.py +++ b/ipalib/public.py @@ -173,6 +173,7 @@ class Option(plugable.ReadOnly): class Command(plugable.Plugin): __public__ = frozenset(( 'get_default', + 'convert', 'normalize', 'validate', 'execute', @@ -196,6 +197,16 @@ class Command(plugable.Plugin): return self.__Option Option = property(__get_Option) + def __convert_iter(self, kw): + for (key, value) in kw.iteritems(): + if key in self.Option: + yield (key, self.Option[key].convert(value)) + else: + yield (key, value) + + def convert(self, **kw): + return dict(self.__convert_iter(kw)) + def __normalize_iter(self, kw): for (key, value) in kw.items(): if key in self.Option: |