Also adjust HDF5_Storage._load and ._save to work with Group groups.
authorW. Trevor King <wking@drexel.edu>
Fri, 16 Mar 2012 08:38:31 +0000 (04:38 -0400)
committerW. Trevor King <wking@drexel.edu>
Fri, 16 Mar 2012 08:38:31 +0000 (04:38 -0400)
h5config/storage/hdf5.py

index 2f1d6608f4fa7c11da7036b6d23d962127cb571b..34f4faea4f55423ab0ccdad97aa2b85632d99762 100644 (file)
@@ -158,9 +158,12 @@ class HDF5_Storage (_FileStorage):
         f = None
         try:
             if group is None:
-                self._check_file()
-                f = _h5py.File(self._filename, 'r')
-                group = f[self.group]
+                if isinstance(self.group, _h5py.Group):
+                    group = self.group
+                else:
+                    self._check_file()
+                    f = _h5py.File(self._filename, 'r')
+                    group = f[self.group]
             for s in config.settings:
                 if s.name not in group.keys():
                     continue
@@ -228,9 +231,12 @@ class HDF5_Storage (_FileStorage):
         f = None
         try:
             if group is None:
-                self._check_file()
-                f = _h5py.File(self._filename, 'a')
-                group = f[self.group]
+                if isinstance(self.group, _h5py.Group):
+                    group = self.group
+                else:
+                    self._check_file()
+                    f = _h5py.File(self._filename, 'a')
+                    group = f[self.group]
             for s in config.settings:
                 value = None
                 if isinstance(s, (_config.BooleanSetting,