Commit 9e16f956 authored by Thomas Vincent's avatar Thomas Vincent
Browse files

Add mode argument to call to h5py.File

parent df6fcb62
......@@ -201,7 +201,7 @@ class H5Base(Node):
return newChildren
def _refreshNode(self):
with h5py.File(self.h5File) as h5f:
with h5py.File(self.h5File, mode="r") as h5f:
thisItem = h5f[self.h5Path]
try:
keys = set(thisItem.keys())
......
......@@ -544,7 +544,7 @@ class QSpaceItemNode(ProjectNode):
return os.path.exists(qspaceFile)
try:
with h5py.File(projectItem.filename) as h5f:
with h5py.File(projectItem.filename, mode="a") as h5f:
del h5f[self.h5Path]
except KeyError:
pass
......@@ -664,7 +664,7 @@ class FitItemNode(ProjectNode):
return os.path.exists(fitFile)
try:
with h5py.File(projectItem.filename) as h5f:
with h5py.File(projectItem.filename, mode="a") as h5f:
del h5f[self.h5Path]
except KeyError:
pass
......
......@@ -68,7 +68,7 @@ class ScanShift(object):
self.__init_tmp()
def __init_tmp(self):
with h5py.File(self.__tmp_file) as tmp_h5:
with h5py.File(self.__tmp_file, mode="a") as tmp_h5:
ref_p0, ref_p1 = _get_ref_positions(self.__xsocs_h5)
tmp_h5['ref_p0'] = ref_p0
tmp_h5['ref_p1'] = ref_p1
......@@ -174,7 +174,7 @@ class ScanShift(object):
if not self.__dirtyGrids[entry]:
dsetPath = '/entries/{0}/grid_indices'.format(entry)
with h5py.File(self.__tmp_file) as tmp_h5:
with h5py.File(self.__tmp_file, mode="r") as tmp_h5:
shifted_idx = tmp_h5.get(dsetPath)[:]
else:
with xsocs_h5:
......@@ -222,7 +222,7 @@ class ScanShift(object):
+ col_idx[valid_idx])
dsetPath = '/entries/{0}/grid_indices'.format(entry)
with h5py.File(self.__tmp_file) as tmp_h5:
with h5py.File(self.__tmp_file, mode="a") as tmp_h5:
if dsetPath not in tmp_h5:
tmp_h5.create_dataset(dsetPath, data=shifted_idx)
else:
......@@ -248,14 +248,14 @@ class ScanShift(object):
dsetPath = '/entries/{0}/free_indices'.format(entry)
if not self.__dirtyFrees[entry]:
with h5py.File(self.__tmp_file) as tmp_h5:
with h5py.File(self.__tmp_file, mode="r") as tmp_h5:
shifted_idx = tmp_h5.get(dsetPath)[:]
else:
shifted_idx = _get_free_shifted_indices(entry,
self.__xsocs_h5,
self.__shifts,
self.__tmp_file)
with h5py.File(self.__tmp_file) as tmp_h5:
with h5py.File(self.__tmp_file, mode="a") as tmp_h5:
if dsetPath not in tmp_h5:
tmp_h5.create_dataset(dsetPath, data=shifted_idx)
else:
......@@ -361,7 +361,7 @@ def _get_free_shifted_indices(entry,
ref_p1=None):
if ref_p0 is None or ref_p1 is None:
with h5py.File(tmp_file) as tmp_h5:
with h5py.File(tmp_file, mode="r") as tmp_h5:
if ref_p0 is None:
ref_p0 = tmp_h5['ref_p0'][:]
if ref_p1 is None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment