2020
2121from ..base import (traits , TraitedSpec , DynamicTraitedSpec , File , Undefined ,
2222 isdefined , OutputMultiPath , InputMultiPath , BaseInterface ,
23- BaseInterfaceInputSpec , Str )
23+ BaseInterfaceInputSpec , Str , SimpleInterface )
2424from ..io import IOBase , add_traits
2525from ...utils .filemanip import ensure_list , copyfile , split_filename
2626
@@ -204,7 +204,6 @@ def _list_outputs(self):
204204
205205
206206class 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
220219class 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
316310class SplitInputSpec (BaseInterfaceInputSpec ):
317311 inlist = traits .List (
0 commit comments