Commit 0358e8f5 authored by Vincent POLLET's avatar Vincent POLLET
Browse files

Remove handle_file indicator, bob.io.base.HDF5File files must be managed by StreamFile.

parent 3b41869d
Pipeline #42528 canceled with stage
in 27 seconds
......@@ -11,10 +11,8 @@ class StreamFile:
def __init__(self, hdf5_file=None, data_format_config_file_path=None, camera_config_file_path=None, mode="r"):
if isinstance(hdf5_file, str): # case string: it is a path, use bob.io.base.HDF5File
self.hdf5_file = HDF5File(hdf5_file, mode)
self.handle_file = True
elif hdf5_file is not None: # otherwise expect a file object (bob.io.base.HDF5File, h5py.File, etc...)
elif hdf5_file is not None: # otherwise expect an opened file object (h5py.File, etc...)
self.hdf5_file = hdf5_file
self.handle_file = False # do not handle opening or closing the actual file object
else:
self.hdf5_file = None
if data_format_config_file_path is not None:
......@@ -30,7 +28,7 @@ class StreamFile:
pass
def __exit__(self, exc_type, exc_val, exc_tb):
if self.hdf5_file is not None and self.handle_file:
if isinstance(self.hdf5_file, HDF5File):
self.hdf5_file.close()
# set source
......
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