Cleans up the directory on an exceptional failure.
(path: str)
| 26 | |
| 27 | @contextlib.contextmanager |
| 28 | def clean_path_on_failure(path: str) -> Generator[None]: |
| 29 | """Cleans up the directory on an exceptional failure.""" |
| 30 | try: |
| 31 | yield |
| 32 | except BaseException: |
| 33 | if os.path.exists(path): |
| 34 | rmtree(path) |
| 35 | raise |
| 36 | |
| 37 | |
| 38 | def resource_text(filename: str) -> str: |