diff --git a/nipype/pipeline/engine/utils.py b/nipype/pipeline/engine/utils.py index 0e27bdcd2b..3601290cd9 100644 --- a/nipype/pipeline/engine/utils.py +++ b/nipype/pipeline/engine/utils.py @@ -1489,10 +1489,9 @@ def clean_working_directory( files2remove.append(f) else: if not str2bool(config["execution"]["keep_inputs"]): - input_files = [] - inputdict = inputs.trait_get() - input_files.extend(walk_outputs(inputdict)) - input_files = [path for path, type in input_files if type == "f"] + input_files = { + path for path, type in walk_outputs(inputs.trait_get()) if type == "f" + } files2remove.extend( f for f in walk_files(cwd) if f in input_files and f not in needed_files ) diff --git a/nipype/utils/filemanip.py b/nipype/utils/filemanip.py index adde6f75a5..e97b93c3f9 100644 --- a/nipype/utils/filemanip.py +++ b/nipype/utils/filemanip.py @@ -444,16 +444,15 @@ def get_related_files(filename, include_this_file=True): include_this_file : bool If true, output includes the input filename. """ - related_files = [] path, name, this_type = split_filename(filename) - for type_set in related_filetype_sets: - if this_type in type_set: - related_files.extend( - op.join(path, name + related_type) - for related_type in type_set - if include_this_file or related_type != this_type - ) - if not len(related_files): + related_files = [ + op.join(path, f"{name}{related_type}") + for type_set in related_filetype_sets + if this_type in type_set + for related_type in type_set + if include_this_file or related_type != this_type + ] + if not related_files: related_files = [filename] return related_files @@ -715,13 +714,11 @@ def write_rst_header(header, level=0): def write_rst_list(items, prefix=""): - out = [f"{prefix} {item}" for item in ensure_list(items)] - return "\n".join(out) + "\n\n" + return "\n".join(f"{prefix} {item}" for item in ensure_list(items)) + "\n\n" def write_rst_dict(info, prefix=""): - out = [f"{prefix}* {key} : {value}" for key, value in sorted(info.items())] - return "\n".join(out) + "\n\n" + return "\n".join(f"{prefix}* {k} : {v}" for k, v in sorted(info.items())) + "\n\n" def dist_is_editable(dist): diff --git a/nipype/utils/nipype2boutiques.py b/nipype/utils/nipype2boutiques.py index 0309263aa5..90785f447e 100644 --- a/nipype/utils/nipype2boutiques.py +++ b/nipype/utils/nipype2boutiques.py @@ -477,7 +477,7 @@ def get_boutiques_output(outputs, name, spec, interface, tool_inputs): # If extensions all the same, set path template as # wildcard + extension. Otherwise just use a wildcard if len(extensions) == 1: - output["path-template"] = "*" + extensions[0] + output["path-template"] = "*" + extensions.pop() else: output["path-template"] = "*" return output