Debian Codegraph @

js/src/tests/lib/tempfile.py

raw
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 try:
5 # Python 3.2
6 from tempfile import TemporaryDirectory
7 except ImportError:
8 import shutil
9 import tempfile
10 from contextlib import contextmanager
11
12 @contextmanager
13 def TemporaryDirectory(*args, **kwds):
14 d = tempfile.mkdtemp(*args, **kwds)
15 try:
16 yield d
17 finally:
18 shutil.rmtree(d)