Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions nipype/interfaces/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,15 +1188,18 @@ class SelectFilesInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec):
base_directory = Directory(exists=True,
desc="Root path common to templates.")
sort_filelist = traits.Bool(True, usedefault=True,
desc="When matching mutliple files, return them in sorted order.")
desc="When matching mutliple files, return them"
" in sorted order.")
raise_on_empty = traits.Bool(True, usedefault=True,
desc="Raise an exception if a template pattern matches no files.")
desc="Raise an exception if a template pattern "
"matches no files.")
force_lists = traits.Either(traits.Bool(), traits.List(Str()),
default=False, usedefault=True,
desc=("Whether to return outputs as a list even when only one file "
"matches the template. Either a boolean that applies to all "
"output fields or a list of output field names to coerce to "
" a list"))
desc=("Whether to return outputs as a list even"
" when only one file matches the template. "
"Either a boolean that applies to all output "
"fields or a list of output field names to "
"coerce to a list"))


class SelectFiles(IOBase):
Expand Down Expand Up @@ -1296,13 +1299,19 @@ def _list_outputs(self):

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

find_dirs = template[-1] == os.sep

# Build the full template path
if isdefined(self.inputs.base_directory):
template = op.abspath(op.join(
self.inputs.base_directory, template))
else:
template = op.abspath(template)

# re-add separator if searching exclusively for directories
if find_dirs:
template += os.sep

# Fill in the template and glob for files
filled_template = template.format(**info)
filelist = glob.glob(filled_template)
Expand Down