@@ -75,28 +75,28 @@ def generate_boutiques_descriptor(
75
75
76
76
# Generates tool inputs
77
77
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 )
79
79
# Handle compound inputs (inputs that can be of multiple types and are mutually exclusive)
80
- if input is None :
80
+ if inp is None :
81
81
continue
82
- if isinstance (input , list ):
82
+ if isinstance (inp , list ):
83
83
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 :
86
86
tool_desc ['inputs' ].append (i )
87
87
mutex_group_members .append (i ['id' ])
88
88
if verbose :
89
89
print ("-> Adding input " + i ['name' ])
90
90
# 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" ,
93
93
'members' : mutex_group_members ,
94
94
'mutually-exclusive' : True })
95
95
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' ] + " "
98
98
if verbose :
99
- print ("-> Adding input " + input ['name' ])
99
+ print ("-> Adding input " + inp ['name' ])
100
100
101
101
# Generates input groups
102
102
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
183
183
if spec .name_source or ignore_inputs is not None and input_name in ignore_inputs :
184
184
return None
185
185
186
- input = {}
186
+ inp = {}
187
187
188
188
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 )
190
190
else :
191
- input ['id' ] = input_name
191
+ inp ['id' ] = input_name
192
192
193
- input ['name' ] = input_name .replace ('_' , ' ' ).capitalize ()
193
+ inp ['name' ] = input_name .replace ('_' , ' ' ).capitalize ()
194
194
195
195
if handler is None :
196
196
trait_handler = spec .handler
@@ -212,70 +212,70 @@ def get_boutiques_input(inputs, interface, input_name, spec, verbose, handler=No
212
212
return input_list
213
213
214
214
if handler_type == "File" or handler_type == "Directory" :
215
- input ['type' ] = "File"
215
+ inp ['type' ] = "File"
216
216
elif handler_type == "Int" :
217
- input ['type' ] = "Number"
218
- input ['integer' ] = True
217
+ inp ['type' ] = "Number"
218
+ inp ['integer' ] = True
219
219
elif handler_type == "Float" :
220
- input ['type' ] = "Number"
220
+ inp ['type' ] = "Number"
221
221
elif handler_type == "Bool" :
222
- input ['type' ] = "Flag"
222
+ inp ['type' ] = "Flag"
223
223
else :
224
- input ['type' ] = "String"
224
+ inp ['type' ] = "String"
225
225
226
226
# Deal with range inputs
227
227
if handler_type == "Range" :
228
- input ['type' ] = "Number"
228
+ inp ['type' ] = "Number"
229
229
if trait_handler ._low is not None :
230
- input ['minimum' ] = trait_handler ._low
230
+ inp ['minimum' ] = trait_handler ._low
231
231
if trait_handler ._high is not None :
232
- input ['maximum' ] = trait_handler ._high
232
+ inp ['maximum' ] = trait_handler ._high
233
233
if trait_handler ._exclude_low :
234
- input ['exclusive-minimum' ] = True
234
+ inp ['exclusive-minimum' ] = True
235
235
if trait_handler ._exclude_high :
236
- input ['exclusive-maximum' ] = True
236
+ inp ['exclusive-maximum' ] = True
237
237
238
238
# Deal with list inputs
239
239
# TODO handle lists of lists (e.g. FSL ProbTrackX seed input)
240
240
if handler_type == "List" :
241
- input ['list' ] = True
241
+ inp ['list' ] = True
242
242
trait_type = type (trait_handler .item_trait .trait_type ).__name__
243
243
if trait_type == "Int" :
244
- input ['integer' ] = True
245
- input ['type' ] = "Number"
244
+ inp ['integer' ] = True
245
+ inp ['type' ] = "Number"
246
246
elif trait_type == "Float" :
247
- input ['type' ] = "Number"
247
+ inp ['type' ] = "Number"
248
248
elif trait_type == "File" :
249
- input ['type' ] = "File"
249
+ inp ['type' ] = "File"
250
250
else :
251
- input ['type' ] = "String"
251
+ inp ['type' ] = "String"
252
252
if trait_handler .minlen != 0 :
253
- input ['min-list-entries' ] = trait_handler .minlen
253
+ inp ['min-list-entries' ] = trait_handler .minlen
254
254
if trait_handler .maxlen != six .MAXSIZE :
255
- input ['max-list-entries' ] = trait_handler .maxlen
255
+ inp ['max-list-entries' ] = trait_handler .maxlen
256
256
257
257
# Deal with multi-input
258
258
if handler_type == "InputMultiObject" :
259
- input ['type' ] = "File"
260
- input ['list' ] = True
259
+ inp ['type' ] = "File"
260
+ inp ['list' ] = True
261
261
262
- input ['value-key' ] = "[" + input_name .upper (
262
+ inp ['value-key' ] = "[" + input_name .upper (
263
263
) + "]" # assumes that input names are unique
264
264
265
265
# Add the command line flag specified by argstr
266
266
# If no argstr is provided and input type is Flag, create a flag from the name
267
267
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 ()
271
271
272
- input ['description' ] = get_description_from_spec (inputs , input_name , spec )
272
+ inp ['description' ] = get_description_from_spec (inputs , input_name , spec )
273
273
if not (hasattr (spec , "mandatory" ) and spec .mandatory ):
274
- input ['optional' ] = True
274
+ inp ['optional' ] = True
275
275
else :
276
- input ['optional' ] = False
276
+ inp ['optional' ] = False
277
277
if spec .usedefault :
278
- input ['default-value' ] = spec .default_value ()[1 ]
278
+ inp ['default-value' ] = spec .default_value ()[1 ]
279
279
280
280
try :
281
281
value_choices = trait_handler .values
@@ -284,17 +284,17 @@ def get_boutiques_input(inputs, interface, input_name, spec, verbose, handler=No
284
284
else :
285
285
if value_choices is not None :
286
286
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
289
289
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
292
292
293
293
# 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"
296
296
297
- return input
297
+ return inp
298
298
299
299
300
300
def get_boutiques_output (outputs , name , spec , interface , tool_inputs ):
@@ -400,28 +400,28 @@ def get_boutiques_groups(input_traits):
400
400
mutex_input_sets .append (group_members )
401
401
402
402
# 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 ),
407
407
'all-or-none' : True })
408
408
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 ),
413
413
'mutually-exclusive' : True })
414
414
415
415
return desc_groups
416
416
417
417
418
- def get_description_from_spec (object , name , spec ):
418
+ def get_description_from_spec (obj , name , spec ):
419
419
'''
420
420
Generates a description based on the input or output spec.
421
421
'''
422
422
if not spec .desc :
423
423
spec .desc = "No description provided."
424
- spec_info = spec .full_info (object , name , None )
424
+ spec_info = spec .full_info (obj , name , None )
425
425
426
426
boutiques_description = (spec_info .capitalize (
427
427
) + ". " + spec .desc .capitalize ()).replace ("\n " , '' )
0 commit comments