Replaced git commands in terms of subprocess.run

This commit is contained in:
2024-04-17 15:26:45 +02:00
parent a1c88fdb5a
commit 1ed37920c2

View File

@ -166,10 +166,11 @@ def second_save_metadata_review(review_yaml_file_path, reviewer_attrs):
# Collect modified review files # Collect modified review files
status = subprocess.run(status_command,capture_output=True,check=True) status = subprocess.run(status_command,capture_output=True,check=True)
modified_files = [] modified_files = []
os.path.basename(review_yaml_file_path)
for line in status.stdout.splitlines(): for line in status.stdout.splitlines():
# conver line from bytes to str # conver line from bytes to str
tmp = line.decode("utf-8") 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]) modified_files.append(tmp.split()[1])
# Stage modified files and commit them to local repository # 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): if isinstance(attr_value,dict):
# Retreive possibly new attribute's name and value # 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_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 hdf5_obj.attrs[new_attr_name] = new_attr_value