MCPcopy Index your code
hub / github.com/pydata/xarray / _nc4_require_group

Function _nc4_require_group

xarray/backends/netCDF4_.py:194–213  ·  view source on GitHub ↗
(ds, group, mode, create_group=_netcdf4_create_group)

Source from the content-addressed store, hash-verified

192
193
194def _nc4_require_group(ds, group, mode, create_group=_netcdf4_create_group):
195 if group in {None, "", "/"}:
196 # use the root group
197 return ds
198 else:
199 # make sure it's a string
200 if not isinstance(group, str):
201 raise ValueError("group must be a string or None")
202 # support path-like syntax
203 path = group.strip("/").split("/")
204 for key in path:
205 try:
206 ds = ds.groups[key]
207 except KeyError as e:
208 if mode != "r":
209 ds = create_group(ds, key)
210 else:
211 # wrap error to provide slightly more helpful message
212 raise OSError(f"group not found: {key}", e) from e
213 return ds
214
215
216def _ensure_no_forward_slash_in_name(name):

Callers 2

_acquireMethod · 0.90
_acquireMethod · 0.85

Calls 2

splitMethod · 0.80
stripMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…