How to use the signac.core.h5store._ensure_open function in signac

To help you get started, we’ve selected a few signac examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glotzerlab / signac / signac / core / h5store.py View on Github external
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)
github glotzerlab / signac / signac / core / h5store.py View on Github external
def __getitem__(self, key):
        with _ensure_open(self._store):
            return _h5get(self._store, self._group, key, self._path)
github glotzerlab / signac / signac / core / h5store.py View on Github external
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
github glotzerlab / signac / signac / core / h5store.py View on Github external
def __delitem__(self, key):
        with _ensure_open(self):
            del self._file[key]
github glotzerlab / signac / signac / core / h5store.py View on Github external
def __setitem__(self, key, value):
        with _ensure_open(self):
            _h5set(self, self._file, self._validate_key(key), value)
            return value
github glotzerlab / signac / signac / core / h5store.py View on Github external
def __iter__(self):
        with _ensure_open(self._store):
            yield from self._group.keys()
github glotzerlab / signac / signac / core / h5store.py View on Github external
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
github glotzerlab / signac / signac / core / h5store.py View on Github external
def __iter__(self):
        with _ensure_open(self):
            yield from self._file.keys()
github glotzerlab / signac / signac / core / h5store.py View on Github external
def __getitem__(self, key):
        key = key if key.startswith('/') else '/' + key
        with _ensure_open(self):
            return _h5get(self, self._file, key)