Commit 86d4b205 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

ok for required option

parent 1562506c
......@@ -197,9 +197,6 @@ class AbstractParameter(object):
else: self.display_name = display_name
self.required = required
self.choices = choices
if len(self.sub_parameters) > 0:
self.nargs = "+"
if type == "date":
self.type = date
......@@ -241,7 +238,9 @@ class AbstractParameter(object):
def add_sub_parameter(self, param):
param_flag = param.flag[2:]
if self.type == "multiple":
self.type = MultipleParameters({param_flag: param.type}, [param.required],
if param.required: req = [param_flag]
else: req = []
self.type = MultipleParameters({param_flag: param.type}, req,
{param_flag: param.choices}, {}, {param_flag: param.default},
{param_flag: param.action})
if self.action == "append":
......@@ -250,13 +249,17 @@ class AbstractParameter(object):
self.action = MiltipleAction
self.global_help = self.help
self.help = self.global_help + " (" + param_flag + "=<" + param.type.__name__.upper() + ">)"
self.default = {param_flag: param.default}
self.nargs = "+"
elif self.type.__class__ == MultipleParameters:
self.type.types[param_flag] = param.type
self.type.choices[param_flag] = param.choices
self.type.default[param_flag] = param.default
self.type.actions[param_flag] = param.action
self.type.required.append(param.required)
if param.required:
self.type.required.append(param_flag)
self.help = self.global_help + self.type.get_help()
self.default[param_flag] = param.default
self.sub_parameters.append(param)
......@@ -280,7 +283,7 @@ class MultiParameterList(list, AbstractParameter):
AbstractParameter.__init__(self, name, help, required=required, type="multiple", flag=flag,
action="append", group=group, display_name=display_name)
return list.__init__(self, [])
class Parameter(str, AbstractParameter):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment