MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / pushd

Function pushd

src/commoncode/command.py:251–262  ·  view source on GitHub ↗

Context manager to change the current working directory to `path`.

(path)

Source from the content-addressed store, hash-verified

249
250@contextlib.contextmanager
251def pushd(path):
252 """
253 Context manager to change the current working directory to `path`.
254 """
255 original_cwd = os.getcwd()
256 if not path:
257 path = original_cwd
258 try:
259 os.chdir(path)
260 yield os.getcwd()
261 finally:
262 os.chdir(original_cwd)
263
264
265def update_path_var(existing_path_var, new_path):

Callers 2

executeFunction · 0.85
load_shared_libraryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected