From f74b5a2d759cf9b7f73e2e8084b9c960e0b8e6c0 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 16 Mar 2012 04:30:57 -0400 Subject: [PATCH] Allow HDF5_Storage to be initialized without a filename. If you use an `h5py.Group` instance for the group, you don't need to open any files. --- h5config/storage/hdf5.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/h5config/storage/hdf5.py b/h5config/storage/hdf5.py index 65b2ba7..2f1d660 100644 --- a/h5config/storage/hdf5.py +++ b/h5config/storage/hdf5.py @@ -133,11 +133,14 @@ class HDF5_Storage (_FileStorage): def __init__(self, group='/', **kwargs): super(HDF5_Storage, self).__init__(**kwargs) - assert group.startswith('/'), group - if not group.endswith('/'): - group += '/' + if isinstance(group, _h5py.Group): + self._file_checked = True + else: + assert group.startswith('/'), group + if not group.endswith('/'): + group += '/' + self._file_checked = False self.group = group - self._file_checked = False def _check_file(self): if self._file_checked: -- 2.26.2