@@ -138,12 +138,48 @@ def get_boutiques_input(inputs, interface, input_name, spec,
138
138
input ['name' ] = input_name .replace ('_' , ' ' ).capitalize ()
139
139
140
140
# Figure out the input type from its handler type
141
- input_type = get_type_from_handler_type (spec .handler )
142
- input ['type' ] = input_type [0 ]
143
- if input_type [1 ]:
141
+ handler_type = type (spec .handler ).__name__
142
+
143
+ if handler_type == "File" or handler_type == "Directory" :
144
+ input ['type' ] = "File"
145
+ elif handler_type == "Int" :
146
+ input ['type' ] = "Number"
144
147
input ['integer' ] = True
148
+ elif handler_type == "Float" :
149
+ input ['type' ] = "Number"
150
+ elif handler_type == "Bool" :
151
+ input ['type' ] = "Flag"
152
+ else :
153
+ input ['type' ] = "String"
154
+
155
+ # Deal with range inputs
156
+ if handler_type == "Range" :
157
+ input ['type' ] = "Number"
158
+ if spec .handler .low is not None :
159
+ input ['minimum' ] = spec .handler .low
160
+ if spec .handler .high is not None :
161
+ input ['maximum' ] = spec .handler .high
162
+ if spec .handler .exclude_low is not None :
163
+ input ['exclusive-minimum' ] = spec .handler .exclude_low
164
+ if spec .handler .exclude_high is not None :
165
+ input ['exclusive-maximum' ] = spec .handler .exclude_high
166
+
167
+ # Deal with list inputs
168
+ if handler_type == "List" :
169
+ input ['list' ] = True
170
+ trait_type = type (spec .handler .item_trait .trait_type ).__name__
171
+ if trait_type == "Int" :
172
+ input ['integer' ] = True
173
+ input ['type' ] = "Number"
174
+ elif trait_type == "Float" :
175
+ input ['type' ] = "Number"
176
+ else :
177
+ input ['type' ] = "String"
178
+ if spec .handler .minlen is not None :
179
+ input ['min-list-entries' ] = spec .handler .minlen
180
+ if spec .handler .maxlen is not None :
181
+ input ['max-list-entries' ] = spec .handler .maxlen
145
182
146
- input ['list' ] = is_list (spec_info )
147
183
input ['value-key' ] = "[" + input_name .upper (
148
184
) + "]" # assumes that input names are unique
149
185
@@ -234,7 +270,10 @@ def get_boutiques_output(outputs, name, spec, interface, tool_inputs, verbose=Fa
234
270
235
271
# Path template creation.
236
272
237
- output_value = interface ._list_outputs ()[name ]
273
+ try :
274
+ output_value = interface ._list_outputs ()[name ]
275
+ except TypeError :
276
+ output_value = None
238
277
239
278
# If output value is defined, use its basename
240
279
if output_value != "" and isinstance (
@@ -273,7 +312,7 @@ def get_boutiques_output(outputs, name, spec, interface, tool_inputs, verbose=Fa
273
312
return output
274
313
275
314
276
- # TODO remove this once we know get_type_from_handler_type works well
315
+ # TODO remove this
277
316
def get_type_from_spec_info (spec_info ):
278
317
'''
279
318
Returns an input type from the spec info. There must be a better
@@ -289,22 +328,7 @@ def get_type_from_spec_info(spec_info):
289
328
return "String"
290
329
291
330
292
- def get_type_from_handler_type (handler ):
293
- '''
294
- Gets the input type from the spec handler type.
295
- Returns a tuple containing the type and a boolean to specify
296
- if the type is an integer.
297
- '''
298
- handler_type = type (handler ).__name__
299
- if handler_type == "File" or handler_type == "Directory" :
300
- return "File" , False
301
- elif handler_type == "Int" or handler_type == "Float" :
302
- return "Number" , handler_type == "Int"
303
- elif handler_type == "Bool" :
304
- return "Flag" , False
305
- else :
306
- return "String" , False
307
-
331
+ # TODO remove this
308
332
def is_list (spec_info ):
309
333
'''
310
334
Returns True if the spec info looks like it describes a list
0 commit comments