File: tempdir.py

package info (click to toggle)
locket 1.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 136 kB
  • sloc: python: 449; makefile: 30; sh: 8
file content (13 lines) | stat: -rw-r--r-- 221 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
import contextlib
import tempfile
import shutil


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