Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __eq__(self, other):
with _ensure_open(self._store):
if isinstance(self, Mapping) and isinstance(other, Mapping):
return super(H5Group, self).__eq__(other)
elif type(other) == type(self):
return self._group == other._group
else:
return super(H5Group, self).__eq__(other)
def __getitem__(self, key):
with _ensure_open(self._store):
return _h5get(self._store, self._group, key, self._path)
def __len__(self):
try:
with _ensure_open(self, mode='r'):
return len(self._file)
except (OSError, IOError) as error:
if 'errno = {}'.format(errno.ENOENT) in str(error):
return 0 # file does not exist
else:
raise
def __delitem__(self, key):
with _ensure_open(self):
del self._file[key]
def __setitem__(self, key, value):
with _ensure_open(self):
_h5set(self, self._file, self._validate_key(key), value)
return value
def __iter__(self):
with _ensure_open(self._store):
yield from self._group.keys()
def __setitem__(self, key, value):
with _ensure_open(self._store):
_h5set(self._store, self._group, self._store._validate_key(key), value, self._path)
return value
def __iter__(self):
with _ensure_open(self):
yield from self._file.keys()
def __getitem__(self, key):
key = key if key.startswith('/') else '/' + key
with _ensure_open(self):
return _h5get(self, self._file, key)