mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-26 00:41:25 -06:00
289: Command.convert(), normalize(), and validate() now use self.params instead of self.options
This commit is contained in:
parent
23e251a605
commit
c1ef2d05e8
@ -282,8 +282,8 @@ class Command(plugable.Plugin):
|
||||
|
||||
def __convert_iter(self, kw):
|
||||
for (key, value) in kw.iteritems():
|
||||
if key in self.options:
|
||||
yield (key, self.options[key].convert(value))
|
||||
if key in self.params:
|
||||
yield (key, self.params[key].convert(value))
|
||||
else:
|
||||
yield (key, value)
|
||||
|
||||
@ -292,8 +292,8 @@ class Command(plugable.Plugin):
|
||||
|
||||
def __normalize_iter(self, kw):
|
||||
for (key, value) in kw.iteritems():
|
||||
if key in self.options:
|
||||
yield (key, self.options[key].normalize(value))
|
||||
if key in self.params:
|
||||
yield (key, self.params[key].normalize(value))
|
||||
else:
|
||||
yield (key, value)
|
||||
|
||||
@ -301,11 +301,11 @@ class Command(plugable.Plugin):
|
||||
return dict(self.__normalize_iter(kw))
|
||||
|
||||
def __get_default_iter(self, kw):
|
||||
for option in self.options():
|
||||
if option.name not in kw:
|
||||
value = option.get_default(**kw)
|
||||
for param in self.params():
|
||||
if param.name not in kw:
|
||||
value = param.get_default(**kw)
|
||||
if value is not None:
|
||||
yield(option.name, value)
|
||||
yield(param.name, value)
|
||||
|
||||
def get_default(self, **kw):
|
||||
self.print_call('default', kw, 1)
|
||||
@ -313,12 +313,12 @@ class Command(plugable.Plugin):
|
||||
|
||||
def validate(self, **kw):
|
||||
self.print_call('validate', kw, 1)
|
||||
for option in self.options():
|
||||
value = kw.get(option.name, None)
|
||||
for param in self.params():
|
||||
value = kw.get(param.name, None)
|
||||
if value is not None:
|
||||
option.validate(value)
|
||||
elif option.required:
|
||||
raise errors.RequirementError(option.name)
|
||||
param.validate(value)
|
||||
elif param.required:
|
||||
raise errors.RequirementError(param.name)
|
||||
|
||||
def execute(self, **kw):
|
||||
self.print_call('execute', kw, 1)
|
||||
|
Loading…
Reference in New Issue
Block a user