| Conditions | 3 |
| Total Lines | 13 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | """ |
||
| 26 | @contextlib.contextmanager |
||
| 27 | def pushd_popd(newcwd=None): |
||
| 28 | try: |
||
| 29 | oldcwd = getcwd() |
||
| 30 | except FileNotFoundError as e: # pylint: disable=unused-variable |
||
| 31 | # This happens when a directory is deleted before the context is exited |
||
| 32 | oldcwd = '/tmp' |
||
| 33 | try: |
||
| 34 | if newcwd: |
||
| 35 | chdir(newcwd) |
||
| 36 | yield |
||
| 37 | finally: |
||
| 38 | chdir(oldcwd) |
||
| 39 | |||
| 49 |