9
9
ExistingDirPath ,
10
10
ExistingFilePath ,
11
11
RegularExpression ,
12
- PythonModule )
12
+ PythonModule ,
13
+ grouper )
13
14
14
15
15
16
# declare the CLI group
@@ -111,7 +112,7 @@ def run(ctx, module, interface, list, help):
111
112
if not module_given :
112
113
click .echo (ctx .command .get_help (ctx ))
113
114
114
- # print the list available interfaces for the given module
115
+ # print the list of available interfaces for the given module
115
116
elif (module_given and list ) or (module_given and not interface ):
116
117
iface_names = list_interfaces (module )
117
118
click .echo ('Available Interfaces:' )
@@ -120,11 +121,11 @@ def run(ctx, module, interface, list, help):
120
121
121
122
# check the interface
122
123
elif (module_given and interface ):
124
+ # create the argument parser
123
125
description = "Run {}" .format (interface )
124
126
prog = " " .join ([ctx .command_path ,
125
127
module .__name__ ,
126
- interface ] +
127
- ctx .args )
128
+ interface ] + ctx .args )
128
129
iface_parser = argparse .ArgumentParser (description = description ,
129
130
prog = prog )
130
131
@@ -141,54 +142,54 @@ def run(ctx, module, interface, list, help):
141
142
run_instance (node , args )
142
143
143
144
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.' )
147
148
# @click.argument('format_args', nargs=-1, type=click.UNPROCESSED)
148
149
# @click.pass_context
149
- # def convert(ctx, format):
150
+ # def convert(ctx, format, format_args ):
150
151
# """Export nipype interfaces to other formats."""
151
152
# if format == 'boutiques':
153
+ # ctx.params.pop('format')
154
+ # ctx.params = dict(grouper(ctx.params['format_args'], 2))
152
155
# 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