Skip to content

Commit 6fa0879

Browse files
committed
RF: apply changes from @oesteban review
1 parent a5bb61c commit 6fa0879

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

niworkflows/reports/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def __init__(self, layout, out_dir, config=None):
138138
raise RuntimeError("Reportlet must have a config object")
139139

140140
self.name = config.get(
141-
"name", "_".join("%s-%s" % i for i in config["bids"].items())
141+
"name", "_".join("%s-%s" % i for i in sorted(config["bids"].items()))
142142
)
143143
self.title = config.get("title")
144144
self.subtitle = config.get("subtitle")

niworkflows/utils/misc.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
33
"""Miscellaneous utilities."""
4-
import os
5-
import shutil
64

75

86
__all__ = [
@@ -253,18 +251,17 @@ def clean_directory(path):
253251
This function is not guaranteed to work across multiple threads or processes.
254252
255253
"""
256-
with os.scandir(path) as sd:
257-
for f in sd:
254+
from pathlib import Path
255+
import shutil
256+
257+
try:
258+
for f in Path(path).iterdir():
258259
if f.is_file() or f.is_symlink():
259-
try:
260-
os.unlink(f.path)
261-
except OSError:
262-
return False
260+
f.unlink()
263261
elif f.is_dir():
264-
try:
265-
shutil.rmtree(f.path)
266-
except OSError:
267-
return False
262+
shutil.rmtree(str(f))
263+
except OSError:
264+
return False
268265
return True
269266

270267

0 commit comments

Comments
 (0)