@@ -101,7 +101,7 @@ def configuration(parent_package='',top_path=None):
101
101
f .close ()
102
102
103
103
104
- def generate_all_classes (modules_list = [], launcher = [], redirect_x = False ):
104
+ def generate_all_classes (modules_list = [], launcher = [], redirect_x = False , mipav_hacks = False ):
105
105
""" modules_list contains all the SEM compliant tools that should have wrappers created for them.
106
106
launcher containtains the command line prefix wrapper arugments needed to prepare
107
107
a proper environment for each of the modules.
@@ -111,7 +111,7 @@ def generate_all_classes(modules_list=[], launcher=[], redirect_x = False):
111
111
print ("=" * 80 )
112
112
print ("Generating Definition for module {0}" .format (module ))
113
113
print ("^" * 80 )
114
- package , code , module = generate_class (module , launcher , redirect_x = redirect_x )
114
+ package , code , module = generate_class (module , launcher , redirect_x = redirect_x , mipav_hacks = mipav_hacks )
115
115
cur_package = all_code
116
116
module_name = package .strip ().split (" " )[0 ].split ("." )[- 1 ]
117
117
for package in package .strip ().split (" " )[0 ].split ("." )[:- 1 ]:
@@ -126,8 +126,8 @@ def generate_all_classes(modules_list=[], launcher=[], redirect_x = False):
126
126
crawl_code_struct (all_code , os .getcwd ())
127
127
128
128
129
- def generate_class (module , launcher , strip_module_name_prefix = True , redirect_x = False ):
130
- dom = grab_xml (module , launcher )
129
+ def generate_class (module , launcher , strip_module_name_prefix = True , redirect_x = False , mipav_hacks = False ):
130
+ dom = grab_xml (module , launcher , mipav_hacks = mipav_hacks )
131
131
if strip_module_name_prefix :
132
132
module_name = module .split ("." )[- 1 ]
133
133
else :
@@ -224,7 +224,10 @@ def generate_class(module, launcher, strip_module_name_prefix=True, redirect_x =
224
224
param .nodeName .replace ('-vector' , '' )]]
225
225
else :
226
226
values = [typesDict [param .nodeName .replace ('-vector' , '' )]]
227
- traitsParams ["sep" ] = ','
227
+ if mipav_hacks == True :
228
+ traitsParams ["sep" ] = ";"
229
+ else :
230
+ traitsParams ["sep" ] = ','
228
231
elif param .getAttribute ('multiple' ) == "true" :
229
232
type = "InputMultiPath"
230
233
if param .nodeName in ['file' , 'directory' , 'image' , 'geometry' , 'transform' , 'table' ]:
@@ -301,19 +304,35 @@ def generate_class(module, launcher, strip_module_name_prefix=True, redirect_x =
301
304
return category , input_spec_code + output_spec_code + main_class , module_name
302
305
303
306
304
- def grab_xml (module , launcher ):
307
+ def grab_xml (module , launcher , mipav_hacks = False ):
305
308
# cmd = CommandLine(command = "Slicer3", args="--launch %s --xml"%module)
306
309
# ret = cmd.run()
307
310
command_list = launcher [:] # force copy to preserve original
308
311
command_list .extend ([module , "--xml" ])
309
312
final_command = " " .join (command_list )
310
313
xmlReturnValue = subprocess .Popen (
311
314
final_command , stdout = subprocess .PIPE , shell = True ).communicate ()[0 ]
312
- #workaround for a JIST bug https://www.nitrc.org/tracker/index.php?func=detail&aid=7233&group_id=228&atid=942
313
- if xmlReturnValue .strip ().endswith ("XML" ):
314
- xmlReturnValue = xmlReturnValue .strip ()[:- 3 ]
315
- if xmlReturnValue .strip ().startswith ("Error: Unable to set default atlas" ):
316
- xmlReturnValue = xmlReturnValue .strip ()[len ("Error: Unable to set default atlas" ):]
315
+ if mipav_hacks :
316
+ #workaround for a jist bug https://www.nitrc.org/tracker/index.php?func=detail&aid=7234&group_id=228&atid=942
317
+ new_xml = ""
318
+ replace_closing_tag = False
319
+ for line in xmlReturnValue .splitlines ():
320
+ if line .strip () == "<file collection: semi-colon delimited list>" :
321
+ new_xml += "<file-vector>\n "
322
+ replace_closing_tag = True
323
+ elif replace_closing_tag and line .strip () == "</file>" :
324
+ new_xml += "</file-vector>\n "
325
+ replace_closing_tag = False
326
+ else :
327
+ new_xml += line + "\n "
328
+
329
+ xmlReturnValue = new_xml
330
+
331
+ #workaround for a JIST bug https://www.nitrc.org/tracker/index.php?func=detail&aid=7233&group_id=228&atid=942
332
+ if xmlReturnValue .strip ().endswith ("XML" ):
333
+ xmlReturnValue = xmlReturnValue .strip ()[:- 3 ]
334
+ if xmlReturnValue .strip ().startswith ("Error: Unable to set default atlas" ):
335
+ xmlReturnValue = xmlReturnValue .strip ()[len ("Error: Unable to set default atlas" ):]
317
336
return xml .dom .minidom .parseString (xmlReturnValue .strip ())
318
337
# if ret.runtime.returncode == 0:
319
338
# return xml.dom.minidom.parseString(ret.runtime.stdout)
0 commit comments