Skip to content

Commit b7f01bb

Browse files
authored
Merge pull request nipreps#541 from mgxd/rf/py36
RF: update to py36+
2 parents da23392 + 6fa0879 commit b7f01bb

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

niworkflows/reports/core.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ 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(
142141
"name", "_".join("%s-%s" % i for i in sorted(config["bids"].items()))
143142
)

niworkflows/utils/misc.py

Lines changed: 11 additions & 13 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,17 +251,17 @@ def clean_directory(path):
253251
This function is not guaranteed to work across multiple threads or processes.
254252
255253
"""
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
254+
from pathlib import Path
255+
import shutil
256+
257+
try:
258+
for f in Path(path).iterdir():
259+
if f.is_file() or f.is_symlink():
260+
f.unlink()
261+
elif f.is_dir():
262+
shutil.rmtree(str(f))
263+
except OSError:
264+
return False
267265
return True
268266

269267

0 commit comments

Comments
 (0)