(
suffix: str = ".nc", allow_cleanup_failure: bool = False
)
| 1716 | |
| 1717 | @contextlib.contextmanager |
| 1718 | def create_tmp_file( |
| 1719 | suffix: str = ".nc", allow_cleanup_failure: bool = False |
| 1720 | ) -> Iterator[str]: |
| 1721 | temp_dir = tempfile.mkdtemp() |
| 1722 | path = os.path.join(temp_dir, f"temp-{next(_counter)}{suffix}") |
| 1723 | try: |
| 1724 | yield path |
| 1725 | finally: |
| 1726 | try: |
| 1727 | shutil.rmtree(temp_dir) |
| 1728 | except OSError: |
| 1729 | if not allow_cleanup_failure: |
| 1730 | raise |
| 1731 | |
| 1732 | |
| 1733 | @contextlib.contextmanager |
no test coverage detected
searching dependent graphs…