Context manager to ensure that a file opened by xarray is closed if an exception is raised before the user sees the file object.
(f)
| 713 | |
| 714 | @contextlib.contextmanager |
| 715 | def close_on_error(f): |
| 716 | """Context manager to ensure that a file opened by xarray is closed if an |
| 717 | exception is raised before the user sees the file object. |
| 718 | """ |
| 719 | try: |
| 720 | yield |
| 721 | except Exception: |
| 722 | f.close() |
| 723 | raise |
| 724 | |
| 725 | |
| 726 | def is_remote_uri(path: str) -> bool: |
no test coverage detected
searching dependent graphs…