From 126f5f21184478073f0efa73cf37aca12cd39d59 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauldmccarthy@gmail.com> Date: Tue, 27 Feb 2018 09:46:38 +0000 Subject: [PATCH] tempdir function allows a destination --- fsl/utils/tempdir.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fsl/utils/tempdir.py b/fsl/utils/tempdir.py index f17aa4482..c5931454c 100644 --- a/fsl/utils/tempdir.py +++ b/fsl/utils/tempdir.py @@ -21,12 +21,16 @@ import contextlib @contextlib.contextmanager -def tempdir(): +def tempdir(root=None): """Returns a context manager which creates and returns a temporary directory, and then deletes it on exit. + + :arg root: If provided, specifies a directroy in which to create the + new temporary directory. Otherwise the system default is used + (see the ``tempfile.mkdtemp`` documentation). """ - testdir = tempfile.mkdtemp() + testdir = tempfile.mkdtemp(dir=root) prevdir = os.getcwd() try: -- GitLab