Conditions | 1 |
Total Lines | 18 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | # Copyright Pincer 2021-Present |
||
14 | @contextmanager |
||
15 | def chdir(path: str) -> Generator[str, Any, None]: |
||
16 | """Change the cwd to the given path as a context manager. |
||
17 | |||
18 | Parameters |
||
19 | ---------- |
||
20 | path: |
||
21 | Path to change to. |
||
22 | |||
23 | Yields |
||
24 | ------ |
||
25 | Generator[:class:`str`, Any, None] |
||
26 | """ |
||
27 | current_path = getcwd() |
||
28 | os_chdir(path) |
||
29 | |||
30 | yield current_path |
||
31 | os_chdir(current_path) |
||
32 |