← Back
Editing: _tmpdirs.cpython-311.pyc
� d�cF � �z � d Z ddlZddlmZ ddlmZ ddlmZ ed� � � Zed� � � Z ed d�� � Z dS ) z? Contexts for *with* statement providing temporary directories � N)�contextmanager)�rmtree)�mkdtempc # �L K � t � � } | V � t | � � dS )a� Create and return a temporary directory. This has the same behavior as mkdtemp but can be used as a context manager. Upon exiting the context, the directory and everything contained in it are removed. Examples -------- >>> import os >>> with tempdir() as tmpdir: ... fname = os.path.join(tmpdir, 'example_file.txt') ... with open(fname, 'wt') as fobj: ... _ = fobj.write('a string\n') >>> os.path.exists(tmpdir) False N)r r )�ds �5/usr/lib/python3/dist-packages/scipy/_lib/_tmpdirs.py�tempdirr s) � � � �$ � � �A� �G�G�G� �1�I�I�I�I�I� c # �� K � t j � � } t � � }t j |� � |V � t j | � � t |� � dS )a� Create, return, and change directory to a temporary directory Examples -------- >>> import os >>> my_cwd = os.getcwd() >>> with in_tempdir() as tmpdir: ... _ = open('test.txt', 'wt').write('some text') ... assert os.path.isfile('test.txt') ... assert os.path.isfile(os.path.join(tmpdir, 'test.txt')) >>> os.path.exists(tmpdir) False >>> os.getcwd() == my_cwd True N)�os�getcwdr �chdirr )�pwdr s r � in_tempdirr sN � � � �"