From 1ed37920c237e45b8a526c7e78886e41ab7dff71 Mon Sep 17 00:00:00 2001 From: Florez Ospina Juan Felipe Date: Wed, 17 Apr 2024 15:26:45 +0200 Subject: [PATCH] Replaced git commands in terms of subprocess.run --- src/metadata_review_lib.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/metadata_review_lib.py b/src/metadata_review_lib.py index ebb4d22..ff5cb7d 100644 --- a/src/metadata_review_lib.py +++ b/src/metadata_review_lib.py @@ -166,10 +166,11 @@ def second_save_metadata_review(review_yaml_file_path, reviewer_attrs): # Collect modified review files status = subprocess.run(status_command,capture_output=True,check=True) modified_files = [] + os.path.basename(review_yaml_file_path) for line in status.stdout.splitlines(): # conver line from bytes to str tmp = line.decode("utf-8") - if 'modified' in tmp and review_yaml_file_path in tmp: + if 'modified' in tmp and 'review/' in tmp and os.path.basename(review_yaml_file_path) in tmp: modified_files.append(tmp.split()[1]) # Stage modified files and commit them to local repository @@ -245,7 +246,18 @@ def third_update_hdf5_file_with_review(input_hdf5_file, yalm_review_file, review if isinstance(attr_value,dict): # Retreive possibly new attribute's name and value new_attr_name = attr_value.get('rename_as',attr_name) # if 'rename_as' is a key in attr_value returns the value, otherwise it return the existing value - new_attr_value = attr_value.get('value',hdf5_obj.attrs[attr_name]) + + dtype = [] + values_list = [] + max_length = 100 + for key in attr_value.keys(): + if (not key=='rename_as'): + dtype.append((key,f'S{max_length}')) + values_list.append(attr_value.get(key,hdf5_obj.attrs[attr_name])) + if len(values_list)>2: + new_attr_value = np.array([tuple(values_list)],dtype=dtype) + else: + new_attr_value = attr_value.get('value',hdf5_obj.attrs[attr_name]) hdf5_obj.attrs[new_attr_name] = new_attr_value