Skip to content

Commit dd19244

Browse files
committed
added custom filename support for workflow saving
1 parent a0427fc commit dd19244

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

nipype/pipeline/engine.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,11 +543,13 @@ def write_hierarchical_dotfile(self, dotfilename=None, colored=True,
543543
else:
544544
logger.info(dotstr)
545545

546-
def export(self, prefix="output", format="python", include_config=False):
546+
def export(self, filename=None, prefix="output", format="python", include_config=False):
547547
"""Export object into a different format
548548
549549
Parameters
550550
----------
551+
filename: string
552+
file to save the code to; overrides prefix
551553
552554
prefix: string
553555
prefix to use for output file
@@ -609,7 +611,10 @@ def export(self, prefix="output", format="python", include_config=False):
609611
for function in functions:
610612
functionlines.append(cPickle.loads(function).rstrip())
611613
all_lines = importlines + functionlines + lines
612-
with open('%s%s.py' % (prefix, self.name), 'wt') as fp:
614+
615+
if not filename:
616+
filename = '%s%s.py' % (prefix, self.name)
617+
with open(filename, 'wt') as fp:
613618
#fp.writelines('\n'.join([line.replace('\n', '\\n') for line in all_lines]))
614619
fp.writelines('\n'.join(all_lines))
615620
return all_lines

0 commit comments

Comments
 (0)