Skip to content

Commit 992a81b

Browse files
committed
bf: ensure template can end with os separator
1 parent 57b03db commit 992a81b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

nipype/interfaces/io.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,8 +1197,6 @@ class SelectFilesInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec):
11971197
"matches the template. Either a boolean that applies to all "
11981198
"output fields or a list of output field names to coerce to "
11991199
" a list"))
1200-
directory_mode = traits.Bool(False, usedefault=True,
1201-
desc="Return only directories.")
12021200

12031201

12041202
class SelectFiles(IOBase):
@@ -1298,15 +1296,19 @@ def _list_outputs(self):
12981296

12991297
for field, template in list(self._templates.items()):
13001298

1299+
find_dirs = False
1300+
if template[-1] == os.sep:
1301+
find_dirs = True
1302+
13011303
# Build the full template path
13021304
if isdefined(self.inputs.base_directory):
13031305
template = op.abspath(op.join(
13041306
self.inputs.base_directory, template))
13051307
else:
13061308
template = op.abspath(template)
13071309

1308-
if self.inputs.directory_mode:
1309-
# return only directories
1310+
# re-add separator if searching exclusively for directories
1311+
if find_dirs:
13101312
template += os.sep
13111313

13121314
# Fill in the template and glob for files

nipype/interfaces/tests/test_auto_SelectFiles.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
def test_SelectFiles_inputs():
77
input_map = dict(base_directory=dict(),
8-
directory_mode=dict(usedefault=True,
9-
),
108
force_lists=dict(usedefault=True,
119
),
1210
ignore_exception=dict(nohash=True,

0 commit comments

Comments
 (0)