Skip to content

Commit a5bb61c

Browse files
committed
RF: update to py36+
1 parent da23392 commit a5bb61c

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

niworkflows/reports/core.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,8 @@ def __init__(self, layout, out_dir, config=None):
137137
if not config:
138138
raise RuntimeError("Reportlet must have a config object")
139139

140-
# PY35: Sorted config dict for consistent behavior
141140
self.name = config.get(
142-
"name", "_".join("%s-%s" % i for i in sorted(config["bids"].items()))
141+
"name", "_".join("%s-%s" % i for i in config["bids"].items())
143142
)
144143
self.title = config.get("title")
145144
self.subtitle = config.get("subtitle")

niworkflows/utils/misc.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -253,17 +253,18 @@ def clean_directory(path):
253253
This function is not guaranteed to work across multiple threads or processes.
254254
255255
"""
256-
for f in os.scandir(path): # switch to context manager when py35 dropped
257-
if f.is_file() or f.is_symlink():
258-
try:
259-
os.unlink(f.path)
260-
except OSError:
261-
return False
262-
elif f.is_dir():
263-
try:
264-
shutil.rmtree(f.path)
265-
except OSError:
266-
return False
256+
with os.scandir(path) as sd:
257+
for f in sd:
258+
if f.is_file() or f.is_symlink():
259+
try:
260+
os.unlink(f.path)
261+
except OSError:
262+
return False
263+
elif f.is_dir():
264+
try:
265+
shutil.rmtree(f.path)
266+
except OSError:
267+
return False
267268
return True
268269

269270

0 commit comments

Comments
 (0)