Skip to content

Commit

Permalink
mrtrix3.file.delTemporary: Compatibility with list input
Browse files Browse the repository at this point in the history
  • Loading branch information
Lestropie committed Jul 4, 2018
1 parent b3d98e3 commit 64dc8e8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/mrtrix3/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ def delTemporary(path): #pylint: disable=unused-variable
from mrtrix3 import app
if not app.cleanup:
return
if isinstance(path, list):
if len(path) == 1:
delTemporary(path[0])
return
if app.verbosity > 2:
app.console('Deleting ' + str(len(path)) + ' temporary items: ' + str(path))
for entry in path:
if os.path.isfile(entry):
func = os.remove
elif os.path.isdir(entry):
func = shutil.rmtree
else:
continue
try:
func(entry)
except OSError:
pass
return
if os.path.isfile(path):
temporary_type = 'file'
func = os.remove
Expand Down

0 comments on commit 64dc8e8

Please sign in to comment.