From a4b7c6a8b07507c28a3b6176715858cb99051a17 Mon Sep 17 00:00:00 2001 From: Florez Ospina Juan Felipe Date: Fri, 23 Aug 2024 15:45:32 +0200 Subject: [PATCH] Moved copy_file_in_group() into hdf5_lib.py because it is not really doing the same role of all filereaders --- .../config_text_reader.yaml} | 0 instruments/readers/g5505_file_reader.py | 17 +---------------- 2 files changed, 1 insertion(+), 16 deletions(-) rename instruments/{text_data_sources.yaml => readers/config_text_reader.yaml} (100%) diff --git a/instruments/text_data_sources.yaml b/instruments/readers/config_text_reader.yaml similarity index 100% rename from instruments/text_data_sources.yaml rename to instruments/readers/config_text_reader.yaml diff --git a/instruments/readers/g5505_file_reader.py b/instruments/readers/g5505_file_reader.py index a60a12a..ee26d5c 100644 --- a/instruments/readers/g5505_file_reader.py +++ b/instruments/readers/g5505_file_reader.py @@ -27,7 +27,7 @@ file_readers = { 'txt': lambda a1: read_txt_files_as_dict(a1, instruments_dir=default_instruments_dir, work_with_copy=False), 'TXT': lambda a1: read_txt_files_as_dict(a1, instruments_dir=default_instruments_dir, work_with_copy=False), 'dat': lambda a1: read_txt_files_as_dict(a1, instruments_dir=default_instruments_dir, work_with_copy=False), - 'h5': lambda a1, a2, a3: copy_file_in_group(a1, a2, a3, work_with_copy=False), + #'h5': lambda a1, a2, a3: copy_file_in_group(a1, a2, a3, work_with_copy=False), 'ACSM_TOFWARE_txt': lambda a1: read_txt_files_as_dict(a1, instruments_dir=default_instruments_dir, work_with_copy=False), 'ACSM_TOFWARE_csv': lambda a1: read_txt_files_as_dict(a1, instruments_dir=default_instruments_dir, work_with_copy=False) } @@ -110,21 +110,6 @@ def read_xps_ibw_file_as_dict(filename): return file_dict -def copy_file_in_group(source_file_path, dest_file_obj : h5py.File, dest_group_name, work_with_copy : bool = True): - # Create copy of original file to avoid possible file corruption and work with it. - - if work_with_copy: - tmp_file_path = utils.make_file_copy(source_file_path) - else: - tmp_file_path = source_file_path - - # Open backup h5 file and copy complet filesystem directory onto a group in h5file - with h5py.File(tmp_file_path,'r') as src_file: - dest_file_obj.copy(source= src_file['/'], dest= dest_group_name) - - if 'tmp_files' in tmp_file_path: - os.remove(tmp_file_path) - def read_txt_files_as_dict(filename: str, instruments_dir: str = None, work_with_copy: bool = True): # If instruments_dir is not provided, use the default path relative to the module directory if not instruments_dir: