diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-10 15:14:26 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-10 15:14:26 +0000 |
commit | 7de450363bc56a747a495803d56cc7c4d1323293 (patch) | |
tree | 4c56e2cebf46e761ec73705bf135d699754b6bc8 /ipalib/public.py | |
parent | 2d85a6daa3798ee5feda1b2bda33300b73bed615 (diff) | |
download | freeipa.git-7de450363bc56a747a495803d56cc7c4d1323293.tar.gz freeipa.git-7de450363bc56a747a495803d56cc7c4d1323293.tar.xz freeipa.git-7de450363bc56a747a495803d56cc7c4d1323293.zip |
282: Added Command.__check_options() method; added unit tests for Command.options instance attribute
Diffstat (limited to 'ipalib/public.py')
-rw-r--r-- | ipalib/public.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/ipalib/public.py b/ipalib/public.py index 7f1929f4..7dfcd176 100644 --- a/ipalib/public.py +++ b/ipalib/public.py @@ -227,6 +227,7 @@ class Command(plugable.Plugin): 'smart_option_order', 'Option', 'args', + 'options', )) __Option = None takes_options = tuple() @@ -234,6 +235,7 @@ class Command(plugable.Plugin): def __init__(self): self.args = plugable.NameSpace(self.__check_args(), sort=False) + self.options = plugable.NameSpace(self.__check_options(), sort=False) def get_args(self): return self.takes_args @@ -265,6 +267,16 @@ class Command(plugable.Plugin): multivalue = True yield arg + def __check_options(self): + for option in self.get_options(): + if type(option) is str: + option = generate_argument(option) + elif not isinstance(option, Option): + raise TypeError( + 'option: need %r or %r; got %r' % (str, Option, option) + ) + yield option + def __get_Option(self): """ Returns the NameSpace containing the Option instances. |