File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 7575 ESMF_NETCDF : nc-config
7676 ESMF_INSTALL_PREFIX : $HOME/ESMF
7777 with :
78- version : latest
78+ version : v8.8.1
7979 esmpy : true
8080 - name : Show ESMF info
8181 run : |
Original file line number Diff line number Diff line change 77`cmor_dataset.json` living under `cmip7_prep/data/`.
88"""
99
10- from contextlib import AbstractContextManager
10+ from contextlib import AbstractContextManager , contextmanager
1111from pathlib import Path
1212import re
1313from importlib .resources import files as ir_files , as_file
2323_UUID_RE = re .compile (r"^[0-9a-f\-]{36}$" , re .IGNORECASE )
2424
2525
26+ @contextmanager
27+ def _as_path_cm (obj ):
28+ """
29+ Yield a Path whether `obj` is already a path-like or a context manager
30+ (e.g., importlib.resources.as_file(...)).
31+ """
32+ # already a path-like → no-op context
33+ if isinstance (obj , (str , Path )):
34+ yield Path (obj )
35+ return
36+
37+ # context manager that yields a path-like
38+ if hasattr (obj , "__enter__" ) and hasattr (obj , "__exit__" ):
39+ with obj as p :
40+ yield Path (p )
41+ return
42+
43+ raise TypeError (f"Unsupported dataset_json object type: { type (obj )!r} " )
44+
45+
2646# ---------------------------------------------------------------------
2747# Packaged resource helpers
2848# ---------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments