summaryrefslogtreecommitdiff
path: root/context.py
blob: 39c32a48d8589ffcc9652d105c46ed1bfd3a842a (plain)
1
2
3
4
5
6
7
8
9
10
11
from contextlib import contextmanager
import tempfile
import shutil

@contextmanager
def tempdir(ignore_error=False, onerror=None):
    try:
        path = tempfile.mkdtemp()
        yield path
    finally:
        shutil.rmtree(path, ignore_error, onerror)