Better solution to overwriting preexisting datasets.
authorW. Trevor King <wking@drexel.edu>
Tue, 19 Apr 2011 23:06:28 +0000 (19:06 -0400)
committerW. Trevor King <wking@drexel.edu>
Tue, 19 Apr 2011 23:06:28 +0000 (19:06 -0400)
Remove them and start from scratch.  The previous implementation did
things like

  >>> dataset = 'no'
  >>> dataset[...] = 'yes'
  >>> dataset[...]
  'ye'

pypiezo/config.py

index 878027b84886ab7f99bb44ce43a2ce67e7e1492f..1d67a18f50f493a50f6916a2b3d4651581eb3fd9 100644 (file)
@@ -576,12 +576,12 @@ class _HDF5Config (_BackedConfig):
         else:
             f = None
         for s in self.settings:
+            value = s.convert_to_text(self[s.name])
             try:
-                dataset = group[s.name]
+                del group[s.name]
             except KeyError:
-                group[s.name] = s.convert_to_text(self[s.name])
-            else:
-                group[s.name][...] = s.convert_to_text(self[s.name])
+                pass
+            group[s.name] = value
         if f:
             f.close()