Skip to content

Commit 37f3781

Browse files
authored
Merge pull request #2688 from effigies/rf/rename
RF: Use runtime.cwd in Rename
2 parents 4b4187c + 7aab323 commit 37f3781

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

nipype/interfaces/utility/base.py

+5-11
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from ..base import (traits, TraitedSpec, DynamicTraitedSpec, File, Undefined,
2222
isdefined, OutputMultiPath, InputMultiPath, BaseInterface,
23-
BaseInterfaceInputSpec, Str)
23+
BaseInterfaceInputSpec, Str, SimpleInterface)
2424
from ..io import IOBase, add_traits
2525
from ...utils.filemanip import ensure_list, copyfile, split_filename
2626

@@ -204,7 +204,6 @@ def _list_outputs(self):
204204

205205

206206
class RenameInputSpec(DynamicTraitedSpec):
207-
208207
in_file = File(exists=True, mandatory=True, desc="file to rename")
209208
keep_ext = traits.Bool(
210209
desc=("Keep in_file extension, replace "
@@ -218,12 +217,11 @@ class RenameInputSpec(DynamicTraitedSpec):
218217

219218

220219
class RenameOutputSpec(TraitedSpec):
221-
222220
out_file = traits.File(
223221
exists=True, desc="softlink to original file with new name")
224222

225223

226-
class Rename(IOBase):
224+
class Rename(SimpleInterface, IOBase):
227225
"""Change the name of a file based on a mapped format string.
228226
229227
To use additional inputs that will be defined at run-time, the class
@@ -303,15 +301,11 @@ def _rename(self):
303301

304302
def _run_interface(self, runtime):
305303
runtime.returncode = 0
306-
_ = copyfile(self.inputs.in_file,
307-
os.path.join(os.getcwd(), self._rename()))
304+
out_file = os.path.join(runtime.cwd, self._rename())
305+
_ = copyfile(self.inputs.in_file, out_file)
306+
self._results['out_file'] = out_file
308307
return runtime
309308

310-
def _list_outputs(self):
311-
outputs = self._outputs().get()
312-
outputs["out_file"] = os.path.join(os.getcwd(), self._rename())
313-
return outputs
314-
315309

316310
class SplitInputSpec(BaseInterfaceInputSpec):
317311
inlist = traits.List(

0 commit comments

Comments
 (0)