|
33 | 33 | from .. import config, logging
|
34 | 34 | from ..utils.filemanip import (
|
35 | 35 | copyfile, simplify_list, ensure_list,
|
36 |
| - get_related_files) |
| 36 | + get_related_files, split_filename) |
37 | 37 | from ..utils.misc import human_order_sorted, str2bool
|
38 | 38 | from .base import (
|
39 | 39 | TraitedSpec, traits, Str, File, Directory, BaseInterface, InputMultiPath,
|
40 | 40 | isdefined, OutputMultiPath, DynamicTraitedSpec, Undefined, BaseInterfaceInputSpec,
|
41 |
| - LibraryBaseInterface) |
| 41 | + LibraryBaseInterface, SimpleInterface) |
42 | 42 |
|
43 | 43 | iflogger = logging.getLogger('nipype.interface')
|
44 | 44 |
|
@@ -2869,28 +2869,26 @@ def _add_output_traits(self, base):
|
2869 | 2869 | class ExportFileInputSpec(BaseInterfaceInputSpec):
|
2870 | 2870 | in_file = File(exists=True, mandatory=True, desc='Input file name')
|
2871 | 2871 | out_file = File(mandatory=True, desc='Output file name')
|
2872 |
| - check_extension = traits.Bool(False, desc='Ensure that the input and output file extensions match') |
| 2872 | + check_extension = traits.Bool(True, desc='Ensure that the input and output file extensions match') |
2873 | 2873 | clobber = traits.Bool(desc='Permit overwriting existing files')
|
2874 | 2874 |
|
2875 | 2875 |
|
2876 | 2876 | class ExportFileOutputSpec(TraitedSpec):
|
2877 | 2877 | out_file = File(exists=True, desc='Output file name')
|
2878 | 2878 |
|
2879 | 2879 |
|
2880 |
| -class ExportFile(BaseInterface): |
| 2880 | +class ExportFile(SimpleInterface): |
2881 | 2881 | input_spec = ExportFileInputSpec
|
2882 | 2882 | output_spec = ExportFileOutputSpec
|
2883 | 2883 |
|
2884 | 2884 | def _run_interface(self, runtime):
|
2885 | 2885 | if not self.inputs.clobber and op.exists(self.inputs.out_file):
|
2886 | 2886 | raise FileExistsError(errno.EEXIST, 'File %s exists' % self.inputs.out_file)
|
| 2887 | + if not op.isabs(self.inputs.out_file): |
| 2888 | + raise ValueError('Out_file must be an absolute path.') |
2887 | 2889 | if (self.inputs.check_extension and
|
2888 |
| - op.splitext(self.inputs.in_file)[1] != op.splitext(self.inputs.out_file)[1]): |
2889 |
| - raise RuntimeError(f'{self.inputs.in_file} and {self.inputs.out_file} have different extensions') |
| 2890 | + split_filename(self.inputs.in_file)[2] != split_filename(self.inputs.out_file)[2]): |
| 2891 | + raise RuntimeError('%s and %s have different extensions' % (self.inputs.in_file, self.inputs.out_file)) |
2890 | 2892 | shutil.copy(str(self.inputs.in_file), str(self.inputs.out_file))
|
| 2893 | + self._results['out_file'] = self.inputs.out_file |
2891 | 2894 | return runtime
|
2892 |
| - |
2893 |
| - def _list_outputs(self): |
2894 |
| - outputs = self.output_spec().get() |
2895 |
| - outputs['out_file'] = self.inputs.out_file |
2896 |
| - return outputs |
0 commit comments