Browse files

WIP don't leave h5py open between method calls


lara object needs to read from archive. But when
you index into lara archive has already been closed.

lara would need to keep track of filename of archive.
  • Loading branch information...
kwgoodman committed Jan 6, 2014
1 parent f080d27 commit bfbe783cfb19423bd60f3ae54eab8171828373a0
Showing with 8 additions and 2 deletions.
  1. +8 −2 la/
@@ -178,13 +178,14 @@ def __getitem__(self, key):
f = h5py.File(self.filename, 'r')
if key in f:
if _is_archived_larry(f[key]):
- return lara(f[key])
+ x = lara(f[key])
+ f.close()
+ return x
msg = "%s is in the archive but it is not a larry."
raise KeyError(msg % key)
raise KeyError("A larry named %s is not in the archive." % key)
- f.close()
def __setitem__(self, key, value):
@@ -210,6 +211,11 @@ def __setitem__(self, key, value):
def __delitem__(self, key):
delete(self.filename, key)
+ def __contains__(self, key):
+ if key in self.keys():
+ return True
+ return False
def __repr__(self):
table = [['larry', 'dtype', 'shape']]
keys = self.keys()

0 comments on commit bfbe783

Please sign in to comment.