Skip to content

Commit

Permalink
STY: Further simplification
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Markiewicz <[email protected]>
  • Loading branch information
DimitriPapadopoulos and effigies committed Oct 6, 2024
1 parent df2b0b7 commit 60aa048
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
7 changes: 3 additions & 4 deletions nipype/pipeline/engine/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
23 changes: 10 additions & 13 deletions nipype/utils/filemanip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion nipype/utils/nipype2boutiques.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Check warning on line 480 in nipype/utils/nipype2boutiques.py

View check run for this annotation

Codecov / codecov/patch

nipype/utils/nipype2boutiques.py#L480

Added line #L480 was not covered by tests
else:
output["path-template"] = "*"
return output
Expand Down

0 comments on commit 60aa048

Please sign in to comment.