Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
except KeyError:
elem = super(type(self), self)
levels = path.strip('/').split('/')
for level in levels:
if elem.__contains__(level):
elem = elem.__getitem__(level)
else:
try:
elem = _follow_reftarget(elem)
elem = elem.__getitem__(level)
except Exception:
raise KeyError('Entry not found: ' + path)
if isinstance(elem, h5py.Group):
return Group(elem.id)
elif isinstance(elem, h5py.Dataset):
return Dataset(elem.id)
elif isinstance(elem, h5py.File):
return File(elem.id)
except KeyError:
elem = super(type(self), self)
levels = path.strip('/').split('/')
for level in levels:
if elem.__contains__(level):
elem = elem.__getitem__(level)
else:
try:
elem = _follow_reftarget(elem)
elem = elem.__getitem__(level)
except Exception:
raise KeyError('Entry not found: ' + path)
if isinstance(elem, h5py.Group):
return Group(elem.id)
elif isinstance(elem, h5py.Dataset):
return Dataset(elem.id)
elif isinstance(elem, h5py.File):
return File(elem.id)
def parent(self): # noqa
id = super(Dataset, self).parent.id
return Group(id)