283: Renamed generate_argument() to generate_option()

This commit is contained in:
Jason Gerard DeRose 2008-09-10 15:16:17 +00:00
parent 7de450363b
commit bde377a2da
2 changed files with 7 additions and 7 deletions

View File

@ -198,9 +198,9 @@ class Option(plugable.ReadOnly):
) )
def generate_argument(name): def generate_option(name):
""" """
Returns an `Option` instance using argument ``name``. Returns an `Option` instance by parsing ``name``.
""" """
if name.endswith('?'): if name.endswith('?'):
kw = dict(required=False, multivalue=False) kw = dict(required=False, multivalue=False)
@ -248,7 +248,7 @@ class Command(plugable.Plugin):
multivalue = False multivalue = False
for arg in self.get_args(): for arg in self.get_args():
if type(arg) is str: if type(arg) is str:
arg = generate_argument(arg) arg = generate_option(arg)
elif not isinstance(arg, Option): elif not isinstance(arg, Option):
raise TypeError( raise TypeError(
'arg: need %r or %r; got %r' % (str, Option, arg) 'arg: need %r or %r; got %r' % (str, Option, arg)
@ -270,7 +270,7 @@ class Command(plugable.Plugin):
def __check_options(self): def __check_options(self):
for option in self.get_options(): for option in self.get_options():
if type(option) is str: if type(option) is str:
option = generate_argument(option) option = generate_option(option)
elif not isinstance(option, Option): elif not isinstance(option, Option):
raise TypeError( raise TypeError(
'option: need %r or %r; got %r' % (str, Option, option) 'option: need %r or %r; got %r' % (str, Option, option)

View File

@ -309,11 +309,11 @@ class test_Option(ClassChecker):
assert o.get_values() == values assert o.get_values() == values
def test_generate_argument(): def test_generate_option():
""" """
Tests the `public.generate_argument` function. Tests the `public.generate_option` function.
""" """
f = public.generate_argument f = public.generate_option
for name in ['arg', 'arg?', 'arg*', 'arg+']: for name in ['arg', 'arg?', 'arg*', 'arg+']:
o = f(name) o = f(name)
assert type(o) is public.Option assert type(o) is public.Option