@@ -1188,15 +1188,18 @@ class SelectFilesInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec):
1188
1188
base_directory = Directory (exists = True ,
1189
1189
desc = "Root path common to templates." )
1190
1190
sort_filelist = traits .Bool (True , usedefault = True ,
1191
- desc = "When matching mutliple files, return them in sorted order." )
1191
+ desc = "When matching mutliple files, return them"
1192
+ " in sorted order." )
1192
1193
raise_on_empty = traits .Bool (True , usedefault = True ,
1193
- desc = "Raise an exception if a template pattern matches no files." )
1194
+ desc = "Raise an exception if a template pattern "
1195
+ "matches no files." )
1194
1196
force_lists = traits .Either (traits .Bool (), traits .List (Str ()),
1195
1197
default = False , usedefault = True ,
1196
- desc = ("Whether to return outputs as a list even when only one file "
1197
- "matches the template. Either a boolean that applies to all "
1198
- "output fields or a list of output field names to coerce to "
1199
- " a list" ))
1198
+ desc = ("Whether to return outputs as a list even"
1199
+ " when only one file matches the template. "
1200
+ "Either a boolean that applies to all output "
1201
+ "fields or a list of output field names to "
1202
+ "coerce to a list" ))
1200
1203
1201
1204
1202
1205
class SelectFiles (IOBase ):
@@ -1296,13 +1299,19 @@ def _list_outputs(self):
1296
1299
1297
1300
for field , template in list (self ._templates .items ()):
1298
1301
1302
+ find_dirs = template [- 1 ] == os .sep
1303
+
1299
1304
# Build the full template path
1300
1305
if isdefined (self .inputs .base_directory ):
1301
1306
template = op .abspath (op .join (
1302
1307
self .inputs .base_directory , template ))
1303
1308
else :
1304
1309
template = op .abspath (template )
1305
1310
1311
+ # re-add separator if searching exclusively for directories
1312
+ if find_dirs :
1313
+ template += os .sep
1314
+
1306
1315
# Fill in the template and glob for files
1307
1316
filled_template = template .format (** info )
1308
1317
filelist = glob .glob (filled_template )
0 commit comments