|
2 | 2 | from __future__ import (print_function, division, unicode_literals,
|
3 | 3 | absolute_import)
|
4 | 4 |
|
5 |
| -from builtins import str, open |
| 5 | +from builtins import str, open, bytes |
6 | 6 | # This tool exports a Nipype interface in the Boutiques (https://github.com/boutiques) JSON format.
|
7 | 7 | # Boutiques tools can be imported in CBRAIN (https://github.com/aces/cbrain) among other platforms.
|
8 | 8 | #
|
@@ -40,10 +40,12 @@ def generate_boutiques_descriptor(
|
40 | 40 | raise Exception("Undefined module.")
|
41 | 41 |
|
42 | 42 | # Retrieves Nipype interface
|
43 |
| - if isinstance(module, str): |
| 43 | + if isinstance(module, (str, bytes)): |
44 | 44 | import_module(module)
|
45 | 45 | module_name = str(module)
|
46 | 46 | module = sys.modules[module]
|
| 47 | + else: |
| 48 | + module_name = str(module.__name__) |
47 | 49 |
|
48 | 50 | interface = getattr(module, interface_name)()
|
49 | 51 | inputs = interface.input_spec()
|
@@ -249,7 +251,7 @@ def create_tempfile():
|
249 | 251 | Creates a temp file and returns its name.
|
250 | 252 | '''
|
251 | 253 | fileTemp = tempfile.NamedTemporaryFile(delete=False)
|
252 |
| - fileTemp.write("hello") |
| 254 | + fileTemp.write(b"hello") |
253 | 255 | fileTemp.close()
|
254 | 256 | return fileTemp.name
|
255 | 257 |
|
@@ -283,6 +285,8 @@ def must_generate_value(name, type, ignored_template_inputs, spec_info, spec,
|
283 | 285 | # Best guess to detect string restrictions...
|
284 | 286 | if "' or '" in spec_info:
|
285 | 287 | return False
|
| 288 | + if spec.default or spec.default_value(): |
| 289 | + return False |
286 | 290 | if not ignored_template_inputs:
|
287 | 291 | return True
|
288 | 292 | return not (name in ignored_template_inputs)
|
0 commit comments