File: tempdir.py

package info (click to toggle)
python-spur 0.3.23-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 216 kB
  • sloc: python: 1,188; makefile: 39
file content (11 lines) | stat: -rw-r--r-- 200 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
import contextlib
import tempfile
import shutil

@contextlib.contextmanager
def create_temporary_dir():
    dir = tempfile.mkdtemp()
    try:
        yield dir
    finally:
        shutil.rmtree(dir)