MCPcopy Index your code
hub / github.com/RustPython/RustPython / temp_cwd

Function temp_cwd

Lib/test/support/os_helper.py:582–598  ·  view source on GitHub ↗

Context manager that temporarily creates and changes the CWD. The function temporarily changes the current working directory after creating a temporary directory in the current directory with name *name*. If *name* is None, the temporary directory is created using tempfile.mkd

(name='tempcwd', quiet=False)

Source from the content-addressed store, hash-verified

580
581@contextlib.contextmanager
582def temp_cwd(name='tempcwd', quiet=False):
583 """
584 Context manager that temporarily creates and changes the CWD.
585
586 The function temporarily changes the current working directory
587 after creating a temporary directory in the current directory with
588 name *name*. If *name* is None, the temporary directory is
589 created using tempfile.mkdtemp.
590
591 If *quiet* is False (default) and it is not possible to
592 create or change the CWD, an error is raised. If *quiet* is True,
593 only a warning is raised and the original CWD is used.
594
595 """
596 with temp_dir(path=name, quiet=quiet) as temp_path:
597 with change_cwd(temp_path, quiet=quiet) as cwd_dir:
598 yield cwd_dir
599
600
601def create_empty_file(filename):

Calls 2

temp_dirFunction · 0.85
change_cwdFunction · 0.85