Skip to content

Commit 82cce93

Browse files
committed
Merge remote-tracking branch 'origin/pr/807'
2 parents 918da62 + a520650 commit 82cce93

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

nipype/interfaces/base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,11 @@ def _filename_from_source(self, name):
14871487
source = getattr(self.inputs, name_source)
14881488
while isinstance(source, list):
14891489
source = source[0]
1490-
_, base, _ = split_filename(source)
1490+
#special treatment for files
1491+
if isinstance(source, str) and os.path.exists(source):
1492+
_, base, _ = split_filename(source)
1493+
else:
1494+
base = source
14911495
retval = name_template % base
14921496
_, _, ext = split_filename(retval)
14931497
if trait_spec.keep_extension and ext:

nipype/interfaces/tests/test_base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from nipype.utils.filemanip import split_filename
1212
from nipype.interfaces.base import Undefined, config
1313
from traits.testing.nose_tools import skip
14-
14+
import traits.api as traits
1515
#test Bunch
1616
def test_bunch():
1717
b = nib.Bunch()
@@ -181,11 +181,15 @@ class spec2(nib.CommandLineInputSpec):
181181
moo = nib.File(name_source=['doo'], hash_files=False, argstr="%s",
182182
position=2)
183183
doo = nib.File(exists=True, argstr="%s", position=1)
184+
goo = traits.Int(argstr="%d", position=4)
185+
poo = nib.File(name_source=['goo'], hash_files=False, argstr="%s",position=3)
186+
184187
class TestName(nib.CommandLine):
185188
_cmd = "mycommand"
186189
input_spec = spec2
187190
testobj = TestName()
188191
testobj.inputs.doo = tmp_infile
192+
testobj.inputs.goo = 99
189193
yield assert_true, '%s_generated' % nme in testobj.cmdline
190194
testobj.inputs.moo = "my_%s_template"
191195
yield assert_true, 'my_%s_template' % nme in testobj.cmdline

0 commit comments

Comments
 (0)