diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-07 03:38:49 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-08-07 03:38:49 +0000 |
commit | fadbae642053565be1d10bc5d6b40b151a97ff16 (patch) | |
tree | 1ae0cd72ef0b97ca5ffc6419545efd510256782b /ipalib/public.py | |
parent | f904cb0422194dc55cf74366145b2cf20299b657 (diff) | |
download | freeipa.git-fadbae642053565be1d10bc5d6b40b151a97ff16.tar.gz freeipa.git-fadbae642053565be1d10bc5d6b40b151a97ff16.tar.xz freeipa.git-fadbae642053565be1d10bc5d6b40b151a97ff16.zip |
72: Started work on public.opt class; added corresponding unit tests
Diffstat (limited to 'ipalib/public.py')
-rw-r--r-- | ipalib/public.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/ipalib/public.py b/ipalib/public.py index e6cd278a..5806d0eb 100644 --- a/ipalib/public.py +++ b/ipalib/public.py @@ -24,10 +24,35 @@ and UI all use. import re import plugable +import errors + + +class opt(plugable.ReadOnly): + __public__ = frozenset(( + 'normalize', + 'validate', + 'default', + 'required', + 'type', + )) + + def normalize(self, value): + try: + return self.type(value) + except (TypeError, ValueError): + raise errors.NormalizationError( + self.__class__.__name__, value, self.type + ) + + + + class cmd(plugable.Plugin): __public__ = frozenset(( + 'normalize', + 'autofill', '__call__', 'get_doc', 'opt', @@ -63,7 +88,10 @@ class cmd(plugable.Plugin): opt = property(__get_opt) def __call__(self, *args, **kw): - print repr(self) + (args, kw) = self.normalize(*args, **kw) + (args, kw) = self.autofill(*args, **kw) + self.validate(*args, **kw) + class obj(plugable.Plugin): |