99 ExistingDirPath ,
1010 ExistingFilePath ,
1111 RegularExpression ,
12- PythonModule )
12+ PythonModule ,
13+ grouper )
1314
1415
1516# declare the CLI group
@@ -111,7 +112,7 @@ def run(ctx, module, interface, list, help):
111112 if not module_given :
112113 click .echo (ctx .command .get_help (ctx ))
113114
114- # print the list available interfaces for the given module
115+ # print the list of available interfaces for the given module
115116 elif (module_given and list ) or (module_given and not interface ):
116117 iface_names = list_interfaces (module )
117118 click .echo ('Available Interfaces:' )
@@ -120,11 +121,11 @@ def run(ctx, module, interface, list, help):
120121
121122 # check the interface
122123 elif (module_given and interface ):
124+ # create the argument parser
123125 description = "Run {}" .format (interface )
124126 prog = " " .join ([ctx .command_path ,
125127 module .__name__ ,
126- interface ] +
127- ctx .args )
128+ interface ] + ctx .args )
128129 iface_parser = argparse .ArgumentParser (description = description ,
129130 prog = prog )
130131
@@ -141,54 +142,54 @@ def run(ctx, module, interface, list, help):
141142 run_instance (node , args )
142143
143144
144- #
145- # @cli.command(context_settings=CONTEXT_SETTINGS.update(dict(ignore_unknown_options=True,)))
146- # @click.argument('-f', '-- format', type=click.Choice(['boutiques']) )
145+ # @cli.command(context_settings=UNKNOWN_OPTIONS)
146+ # @click.option('-f', '--format', type=click.Choice(['boutiques']),
147+ # help='Output format type.' )
147148# @click.argument('format_args', nargs=-1, type=click.UNPROCESSED)
148149# @click.pass_context
149- # def convert(ctx, format):
150+ # def convert(ctx, format, format_args ):
150151# """Export nipype interfaces to other formats."""
151152# if format == 'boutiques':
153+ # ctx.params.pop('format')
154+ # ctx.params = dict(grouper(ctx.params['format_args'], 2))
152155# ctx.forward(to_boutiques)
153- # import pdb; pdb.set_trace()
154- # ctx.invoke(to_boutiques, **format_args)
155- #
156- #
157- # @cli.command(context_settings=CONTEXT_SETTINGS)
158- # @click.option("-i", "--interface", type=str, required=True,
159- # help="Name of the Nipype interface to export.")
160- # @click.option("-m", "--module", type=PythonModule(), required=True,
161- # help="Module where the interface is defined.")
162- # @click.option("-o", "--output", type=str, required=True,
163- # help="JSON file name where the Boutiques descriptor will be written.")
164- # @click.option("-t", "--ignored-template-inputs", type=str, multiple=True,
165- # help="Interface inputs ignored in path template creations.")
166- # @click.option("-d", "--docker-image", type=str,
167- # help="Name of the Docker image where the Nipype interface is available.")
168- # @click.option("-r", "--docker-index", type=str,
169- # help="Docker index where the Docker image is stored (e.g. http://index.docker.io).")
170- # @click.option("-n", "--ignore-template-numbers", is_flag=True, flag_value=True,
171- # help="Ignore all numbers in path template creations.")
172- # @click.option("-v", "--verbose", is_flag=True, flag_value=True,
173- # help="Enable verbose output.")
174- # def to_boutiques(interface, module, output, ignored_template_inputs,
175- # docker_image, docker_index, ignore_template_numbers,
176- # verbose):
177- # """Nipype Boutiques exporter.
178- #
179- # See Boutiques specification at https://github.com/boutiques/schema.
180- # """
181- # from nipype.utils.nipype2boutiques import generate_boutiques_descriptor
182- #
183- # # Generates JSON string
184- # json_string = generate_boutiques_descriptor(module,
185- # interface,
186- # ignored_template_inputs,
187- # docker_image,
188- # docker_index,
189- # verbose,
190- # ignore_template_numbers)
191- #
192- # # Writes JSON string to file
193- # with open(output, 'w') as f:
194- # f.write(json_string)
156+
157+
158+ @cli .command (context_settings = CONTEXT_SETTINGS )
159+ @click .option ("-i" , "--interface" , type = str , required = True ,
160+ help = "Name of the Nipype interface to export." )
161+ @click .option ("-m" , "--module" , type = PythonModule (), required = True ,
162+ help = "Module where the interface is defined." )
163+ @click .option ("-o" , "--output" , type = str , required = True ,
164+ help = "JSON file name where the Boutiques descriptor will be written." )
165+ @click .option ("-t" , "--ignored-template-inputs" , type = str , multiple = True ,
166+ help = "Interface inputs ignored in path template creations." )
167+ @click .option ("-d" , "--docker-image" , type = str ,
168+ help = "Name of the Docker image where the Nipype interface is available." )
169+ @click .option ("-r" , "--docker-index" , type = str ,
170+ help = "Docker index where the Docker image is stored (e.g. http://index.docker.io)." )
171+ @click .option ("-n" , "--ignore-template-numbers" , is_flag = True , flag_value = True ,
172+ help = "Ignore all numbers in path template creations." )
173+ @click .option ("-v" , "--verbose" , is_flag = True , flag_value = True ,
174+ help = "Enable verbose output." )
175+ def to_boutiques (interface , module , output , ignored_template_inputs ,
176+ docker_image , docker_index , ignore_template_numbers ,
177+ verbose ):
178+ """Nipype Boutiques exporter.
179+
180+ See Boutiques specification at https://github.com/boutiques/schema.
181+ """
182+ from nipype .utils .nipype2boutiques import generate_boutiques_descriptor
183+
184+ # Generates JSON string
185+ json_string = generate_boutiques_descriptor (module ,
186+ interface ,
187+ ignored_template_inputs ,
188+ docker_image ,
189+ docker_index ,
190+ verbose ,
191+ ignore_template_numbers )
192+
193+ # Writes JSON string to file
194+ with open (output , 'w' ) as f :
195+ f .write (json_string )
0 commit comments