Changes current directory to target. Args: target: target directory.
(target: str)
| 30 | |
| 31 | @contextmanager |
| 32 | def cd(target: str) -> Iterator[None]: |
| 33 | """Changes current directory to target. |
| 34 | |
| 35 | Args: |
| 36 | target: target directory. |
| 37 | """ |
| 38 | prev = os.getcwd() |
| 39 | os.chdir(os.path.expanduser(target)) |
| 40 | try: |
| 41 | yield |
| 42 | finally: |
| 43 | os.chdir(prev) |