From 89e9dd9ab11cac74d81828b38bdf9c9d9e93f37c Mon Sep 17 00:00:00 2001 From: Florez Ospina Juan Felipe Date: Thu, 3 Oct 2024 09:32:25 +0200 Subject: [PATCH] Fixed bugs in update_file() method and create_hdf5_file_from_filesystem_path() --- src/hdf5_lib.py | 8 ++++---- src/hdf5_ops.py | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/hdf5_lib.py b/src/hdf5_lib.py index 4c798db..d46364f 100644 --- a/src/hdf5_lib.py +++ b/src/hdf5_lib.py @@ -138,10 +138,10 @@ def create_hdf5_file_from_filesystem_path(path_to_input_directory: str, select_dir_keywords[i] = keyword.replace('/',os.sep) if not path_to_filenames_dict: - # On dry_run=True, returns path to files dictionary of the output directory without making a actual copy of the input directory - path_to_output_directory = os.path.join(path_to_input_directory,'..') - path_to_filenames_dict = utils.copy_directory_with_contraints(path_to_input_directory, - path_to_output_directory, + # On dry_run=True, returns path to files dictionary of the output directory without making a actual copy of the input directory. + # Therefore, there wont be a copying conflict by setting up input and output directories the same + path_to_filenames_dict = utils.copy_directory_with_contraints(input_dir_path=path_to_input_directory, + output_dir_path=path_to_input_directory, dry_run=True) # Set input_directory as copied input directory root_dir = path_to_input_directory diff --git a/src/hdf5_ops.py b/src/hdf5_ops.py index 4f0aabf..55d862a 100644 --- a/src/hdf5_ops.py +++ b/src/hdf5_ops.py @@ -359,11 +359,12 @@ class HDF5DataOpsManager(): def update_file(self, path_to_append_dir): # Split the reference file path and the append directory path into directories and filenames ref_tail, ref_head = os.path.split(self.file_path) + ref_head_filename, head_ext = os.path.splitext(ref_head) tail, head = os.path.split(path_to_append_dir) - head_filename, head_ext = os.path.splitext(head) + # Ensure the append directory is in the same directory as the reference file and has the same name (without extension) - if not (ref_tail == tail and ref_head == head_filename): + if not (ref_tail == tail and ref_head_filename == head): raise ValueError("The append directory must be in the same directory as the reference HDF5 file and have the same name without the extension.") # Close the file if it's already open