From 7aab323972f1896cc26b73b273819d4031c4df49 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Wed, 29 Aug 2018 11:15:38 -0400 Subject: [PATCH] RF: Use runtime.cwd in Rename --- nipype/interfaces/utility/base.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/nipype/interfaces/utility/base.py b/nipype/interfaces/utility/base.py index f2da6cf2a6..80a7089be8 100644 --- a/nipype/interfaces/utility/base.py +++ b/nipype/interfaces/utility/base.py @@ -20,7 +20,7 @@ from ..base import (traits, TraitedSpec, DynamicTraitedSpec, File, Undefined, isdefined, OutputMultiPath, InputMultiPath, BaseInterface, - BaseInterfaceInputSpec, Str) + BaseInterfaceInputSpec, Str, SimpleInterface) from ..io import IOBase, add_traits from ...utils.filemanip import ensure_list, copyfile, split_filename @@ -204,7 +204,6 @@ def _list_outputs(self): class RenameInputSpec(DynamicTraitedSpec): - in_file = File(exists=True, mandatory=True, desc="file to rename") keep_ext = traits.Bool( desc=("Keep in_file extension, replace " @@ -218,12 +217,11 @@ class RenameInputSpec(DynamicTraitedSpec): class RenameOutputSpec(TraitedSpec): - out_file = traits.File( exists=True, desc="softlink to original file with new name") -class Rename(IOBase): +class Rename(SimpleInterface, IOBase): """Change the name of a file based on a mapped format string. To use additional inputs that will be defined at run-time, the class @@ -303,15 +301,11 @@ def _rename(self): def _run_interface(self, runtime): runtime.returncode = 0 - _ = copyfile(self.inputs.in_file, - os.path.join(os.getcwd(), self._rename())) + out_file = os.path.join(runtime.cwd, self._rename()) + _ = copyfile(self.inputs.in_file, out_file) + self._results['out_file'] = out_file return runtime - def _list_outputs(self): - outputs = self._outputs().get() - outputs["out_file"] = os.path.join(os.getcwd(), self._rename()) - return outputs - class SplitInputSpec(BaseInterfaceInputSpec): inlist = traits.List(