mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-22 06:55:35 -04:00
15 lines
336 B
Python
15 lines
336 B
Python
from contextlib import contextmanager
|
|
import os
|
|
import tempfile
|
|
|
|
|
|
@contextmanager
|
|
def cdtemp():
|
|
"""Context manager to change to/return from a tmpdir."""
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
cwd = os.getcwd()
|
|
try:
|
|
os.chdir(tmpdir)
|
|
yield
|
|
finally:
|
|
os.chdir(cwd)
|