@@ -75,28 +75,28 @@ def generate_boutiques_descriptor(
7575
7676 # Generates tool inputs
7777 for name , spec in sorted (interface .inputs .traits (transient = None ).items ()):
78- input = get_boutiques_input (inputs , interface , name , spec , verbose , ignore_inputs = ignore_inputs )
78+ inp = get_boutiques_input (inputs , interface , name , spec , verbose , ignore_inputs = ignore_inputs )
7979 # Handle compound inputs (inputs that can be of multiple types and are mutually exclusive)
80- if input is None :
80+ if inp is None :
8181 continue
82- if isinstance (input , list ):
82+ if isinstance (inp , list ):
8383 mutex_group_members = []
84- tool_desc ['command-line' ] += input [0 ]['value-key' ] + " "
85- for i in input :
84+ tool_desc ['command-line' ] += inp [0 ]['value-key' ] + " "
85+ for i in inp :
8686 tool_desc ['inputs' ].append (i )
8787 mutex_group_members .append (i ['id' ])
8888 if verbose :
8989 print ("-> Adding input " + i ['name' ])
9090 # Put inputs into a mutually exclusive group
91- tool_desc ['groups' ].append ({'id' : input [0 ]['id' ] + "_group" ,
92- 'name' : input [0 ]['name' ] + " group" ,
91+ tool_desc ['groups' ].append ({'id' : inp [0 ]['id' ] + "_group" ,
92+ 'name' : inp [0 ]['name' ] + " group" ,
9393 'members' : mutex_group_members ,
9494 'mutually-exclusive' : True })
9595 else :
96- tool_desc ['inputs' ].append (input )
97- tool_desc ['command-line' ] += input ['value-key' ] + " "
96+ tool_desc ['inputs' ].append (inp )
97+ tool_desc ['command-line' ] += inp ['value-key' ] + " "
9898 if verbose :
99- print ("-> Adding input " + input ['name' ])
99+ print ("-> Adding input " + inp ['name' ])
100100
101101 # Generates input groups
102102 tool_desc ['groups' ] += get_boutiques_groups (interface .inputs .traits (transient = None ).items ())
@@ -183,14 +183,14 @@ def get_boutiques_input(inputs, interface, input_name, spec, verbose, handler=No
183183 if spec .name_source or ignore_inputs is not None and input_name in ignore_inputs :
184184 return None
185185
186- input = {}
186+ inp = {}
187187
188188 if input_number is not None and input_number != 0 : # No need to append a number to the first of a list of compound inputs
189- input ['id' ] = input_name + "_" + str (input_number + 1 )
189+ inp ['id' ] = input_name + "_" + str (input_number + 1 )
190190 else :
191- input ['id' ] = input_name
191+ inp ['id' ] = input_name
192192
193- input ['name' ] = input_name .replace ('_' , ' ' ).capitalize ()
193+ inp ['name' ] = input_name .replace ('_' , ' ' ).capitalize ()
194194
195195 if handler is None :
196196 trait_handler = spec .handler
@@ -212,70 +212,70 @@ def get_boutiques_input(inputs, interface, input_name, spec, verbose, handler=No
212212 return input_list
213213
214214 if handler_type == "File" or handler_type == "Directory" :
215- input ['type' ] = "File"
215+ inp ['type' ] = "File"
216216 elif handler_type == "Int" :
217- input ['type' ] = "Number"
218- input ['integer' ] = True
217+ inp ['type' ] = "Number"
218+ inp ['integer' ] = True
219219 elif handler_type == "Float" :
220- input ['type' ] = "Number"
220+ inp ['type' ] = "Number"
221221 elif handler_type == "Bool" :
222- input ['type' ] = "Flag"
222+ inp ['type' ] = "Flag"
223223 else :
224- input ['type' ] = "String"
224+ inp ['type' ] = "String"
225225
226226 # Deal with range inputs
227227 if handler_type == "Range" :
228- input ['type' ] = "Number"
228+ inp ['type' ] = "Number"
229229 if trait_handler ._low is not None :
230- input ['minimum' ] = trait_handler ._low
230+ inp ['minimum' ] = trait_handler ._low
231231 if trait_handler ._high is not None :
232- input ['maximum' ] = trait_handler ._high
232+ inp ['maximum' ] = trait_handler ._high
233233 if trait_handler ._exclude_low :
234- input ['exclusive-minimum' ] = True
234+ inp ['exclusive-minimum' ] = True
235235 if trait_handler ._exclude_high :
236- input ['exclusive-maximum' ] = True
236+ inp ['exclusive-maximum' ] = True
237237
238238 # Deal with list inputs
239239 # TODO handle lists of lists (e.g. FSL ProbTrackX seed input)
240240 if handler_type == "List" :
241- input ['list' ] = True
241+ inp ['list' ] = True
242242 trait_type = type (trait_handler .item_trait .trait_type ).__name__
243243 if trait_type == "Int" :
244- input ['integer' ] = True
245- input ['type' ] = "Number"
244+ inp ['integer' ] = True
245+ inp ['type' ] = "Number"
246246 elif trait_type == "Float" :
247- input ['type' ] = "Number"
247+ inp ['type' ] = "Number"
248248 elif trait_type == "File" :
249- input ['type' ] = "File"
249+ inp ['type' ] = "File"
250250 else :
251- input ['type' ] = "String"
251+ inp ['type' ] = "String"
252252 if trait_handler .minlen != 0 :
253- input ['min-list-entries' ] = trait_handler .minlen
253+ inp ['min-list-entries' ] = trait_handler .minlen
254254 if trait_handler .maxlen != six .MAXSIZE :
255- input ['max-list-entries' ] = trait_handler .maxlen
255+ inp ['max-list-entries' ] = trait_handler .maxlen
256256
257257 # Deal with multi-input
258258 if handler_type == "InputMultiObject" :
259- input ['type' ] = "File"
260- input ['list' ] = True
259+ inp ['type' ] = "File"
260+ inp ['list' ] = True
261261
262- input ['value-key' ] = "[" + input_name .upper (
262+ inp ['value-key' ] = "[" + input_name .upper (
263263 ) + "]" # assumes that input names are unique
264264
265265 # Add the command line flag specified by argstr
266266 # If no argstr is provided and input type is Flag, create a flag from the name
267267 if spec .argstr and spec .argstr .split ("%" )[0 ]:
268- input ['command-line-flag' ] = spec .argstr .split ("%" )[0 ].strip ()
269- elif input ['type' ] == "Flag" :
270- input ['command-line-flag' ] = ("--%s" % input_name + " " ).strip ()
268+ inp ['command-line-flag' ] = spec .argstr .split ("%" )[0 ].strip ()
269+ elif inp ['type' ] == "Flag" :
270+ inp ['command-line-flag' ] = ("--%s" % input_name + " " ).strip ()
271271
272- input ['description' ] = get_description_from_spec (inputs , input_name , spec )
272+ inp ['description' ] = get_description_from_spec (inputs , input_name , spec )
273273 if not (hasattr (spec , "mandatory" ) and spec .mandatory ):
274- input ['optional' ] = True
274+ inp ['optional' ] = True
275275 else :
276- input ['optional' ] = False
276+ inp ['optional' ] = False
277277 if spec .usedefault :
278- input ['default-value' ] = spec .default_value ()[1 ]
278+ inp ['default-value' ] = spec .default_value ()[1 ]
279279
280280 try :
281281 value_choices = trait_handler .values
@@ -284,17 +284,17 @@ def get_boutiques_input(inputs, interface, input_name, spec, verbose, handler=No
284284 else :
285285 if value_choices is not None :
286286 if all (isinstance (n , int ) for n in value_choices ):
287- input ['type' ] = "Number"
288- input ['integer' ] = True
287+ inp ['type' ] = "Number"
288+ inp ['integer' ] = True
289289 elif all (isinstance (n , float ) for n in value_choices ):
290- input ['type' ] = "Number"
291- input ['value-choices' ] = value_choices
290+ inp ['type' ] = "Number"
291+ inp ['value-choices' ] = value_choices
292292
293293 # Set Boolean types to Flag (there is no Boolean type in Boutiques)
294- if input ['type' ] == "Boolean" :
295- input ['type' ] = "Flag"
294+ if inp ['type' ] == "Boolean" :
295+ inp ['type' ] = "Flag"
296296
297- return input
297+ return inp
298298
299299
300300def get_boutiques_output (outputs , name , spec , interface , tool_inputs ):
@@ -400,28 +400,28 @@ def get_boutiques_groups(input_traits):
400400 mutex_input_sets .append (group_members )
401401
402402 # Create a dictionary for each one
403- for i in range ( 0 , len ( all_or_none_input_sets ) ):
404- desc_groups .append ({'id' : "all_or_none_group" + ("_" + str (i + 1 ) if i != 0 else "" ),
405- 'name' : "All or none group" + (" " + str (i + 1 ) if i != 0 else "" ),
406- 'members' : list (all_or_none_input_sets [ i ] ),
403+ for i , inp_set in enumerate ( all_or_none_input_sets , 1 ):
404+ desc_groups .append ({'id' : "all_or_none_group" + ("_" + str (i ) if i != 1 else "" ),
405+ 'name' : "All or none group" + (" " + str (i ) if i != 1 else "" ),
406+ 'members' : list (inp_set ),
407407 'all-or-none' : True })
408408
409- for i in range ( 0 , len ( mutex_input_sets ) ):
410- desc_groups .append ({'id' : "mutex_group" + ("_" + str (i + 1 ) if i != 0 else "" ),
411- 'name' : "Mutex group" + (" " + str (i + 1 ) if i != 0 else "" ),
412- 'members' : list (mutex_input_sets [ i ] ),
409+ for i , inp_set in enumerate ( mutex_input_sets , 1 ):
410+ desc_groups .append ({'id' : "mutex_group" + ("_" + str (i ) if i != 1 else "" ),
411+ 'name' : "Mutex group" + (" " + str (i ) if i != 1 else "" ),
412+ 'members' : list (inp_set ),
413413 'mutually-exclusive' : True })
414414
415415 return desc_groups
416416
417417
418- def get_description_from_spec (object , name , spec ):
418+ def get_description_from_spec (obj , name , spec ):
419419 '''
420420 Generates a description based on the input or output spec.
421421 '''
422422 if not spec .desc :
423423 spec .desc = "No description provided."
424- spec_info = spec .full_info (object , name , None )
424+ spec_info = spec .full_info (obj , name , None )
425425
426426 boutiques_description = (spec_info .capitalize (
427427 ) + ". " + spec .desc .capitalize ()).replace ("\n " , '' )
0 commit comments