Allow HDF5_Storage to be initialized without a filename.
authorW. Trevor King <wking@drexel.edu>
Fri, 16 Mar 2012 08:30:57 +0000 (04:30 -0400)
committerW. Trevor King <wking@drexel.edu>
Fri, 16 Mar 2012 08:30:57 +0000 (04:30 -0400)
If you use an `h5py.Group` instance for the group, you don't need to
open any files.

h5config/storage/hdf5.py

index 65b2ba7996b83fe8a70811d5a2b521ea8f45f71c..2f1d6608f4fa7c11da7036b6d23d962127cb571b 100644 (file)
@@ -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: