From: W. Trevor King Date: Fri, 16 Mar 2012 08:30:57 +0000 (-0400) Subject: Allow HDF5_Storage to be initialized without a filename. X-Git-Tag: v0.2~10 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f74b5a2d759cf9b7f73e2e8084b9c960e0b8e6c0;p=h5config.git 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. --- 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: