(path)
| 7 | |
| 8 | @contextmanager |
| 9 | def setdir(path): |
| 10 | try: |
| 11 | os.makedirs(path, exist_ok=True) |
| 12 | cwd = os.getcwd() |
| 13 | logging.info("Changing directory to %s" % path) |
| 14 | logging.info("Previously: %s" % cwd) |
| 15 | os.chdir(path) |
| 16 | yield |
| 17 | finally: |
| 18 | logging.info("Restoring directory to %s" % cwd) |
| 19 | os.chdir(cwd) |