Commit da8e5fd1 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

No commit message

No commit message
parent 45f7834e
......@@ -129,10 +129,15 @@ if __name__ == '__main__':
# create the subparser for each applications
sub_parser = subparsers.add_parser(instance.name, help=instance.description, fromfile_prefix_chars='@')
sub_parser.convert_arg_line_to_args = instance.__class__.config_parser
for param in instance.parameters:
parameters_groups = instance.get_parameters_per_groups()
for group in parameters_groups:
if group == "default":
for param in parameters_groups[group]:
sub_parser.add_argument(param.flag, **param.export_to_argparse())
sub_parser.set_defaults(cmd_object=instance.__class__.__name__)
else:
pgroup = sub_parser.add_argument_group(group)
for param in parameters_groups[group]:
pgroup.add_argument(param.flag, **param.export_to_argparse())
args = vars(parser.parse_args())
if args["cmd_object"] in wf_classes:
......
......@@ -72,7 +72,7 @@ class Parameter(object):
"""
def __init__(self, name, help, flag, default=None, type=types.StringType, choices=None,
required=False, action="store", sub_parameters=[]):
required=False, action="store", sub_parameters=[], group="default"):
self.name = name
self.flag = flag
......@@ -80,6 +80,8 @@ class Parameter(object):
self.action = action
self.nargs = None
self.sub_parameters = sub_parameters
self.group = group
if len(self.sub_parameters) > 0:
self.nargs = "+"
if type == "date":
......
......@@ -168,6 +168,15 @@ class Workflow(threading.Thread):
del odict['_Thread__stderr']
return odict
def get_parameters_per_groups(self):
parameters = {}
for param in self.parameters:
if parameters.has_key(param.group):
parameters[param.group].append(param)
else:
parameters[param.group] = [param]
return parameters
def add_component(self, component_name, args=[], kwargs={}, component_prefix="default"):
# first build and check if this component is OK
if self.comp_pckg.has_key(component_name):
......
Markdown is supported
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