Implemented delete attribute feature and corrected yaml display of compound attributes

This commit is contained in:
2024-04-25 08:58:29 +02:00
parent 4f15c3b684
commit 3c6440977f
2 changed files with 23 additions and 7 deletions

View File

@ -94,20 +94,34 @@ def make_dtype_yaml_compatible(value):
return value
def is_structured_array(attr_val):
if isinstance(attr_val,np.ndarray):
return True if attr_val.dtype.names is not None else False
else:
return False
def construct_attributes_dict(attrs_obj):
attr_dict = {}
for key, value in attrs_obj.items():
attr_dict[key] = {}
if not key in ['file_list','filtered_file_list']:
value = make_dtype_yaml_compatible(value)
if is_structured_array(value):
for subattr in value.dtype.names:
attr_dict[key][subattr] = make_dtype_yaml_compatible(value[subattr])
else:
value = make_dtype_yaml_compatible(value)
attr_dict[key] = {"rename_as" : key,
"value" : value
}
#if isinstance(value,str):
# value.replace('\\','\\\\')
attr_dict[key] = {"rename_as" : key,
"value" : value
}
return attr_dict
def print_metadata(name, obj, folder_depth, yaml_dict):

View File

@ -65,7 +65,8 @@ def first_initialize_metadata_review(hdf5_file_path, reviewer_attrs):
"""
initials = reviewer_attrs['initials']
branch_name = '-'.join([reviewer_attrs['type'],'review_',initials])
#branch_name = '-'.join([reviewer_attrs['type'],'review_',initials])
branch_name = '_'.join(['review',initials])
hdf5_file_path_tail, filename_path_head = os.path.split(hdf5_file_path)
filename, ext = os.path.splitext(filename_path_head)
@ -154,7 +155,8 @@ def second_save_metadata_review(review_yaml_file_path, reviewer_attrs):
# 3. git add review/ and git commit -m "Submitted metadata review"
initials = reviewer_attrs['initials']
branch_name = '-'.join([reviewer_attrs['type'],'review','by',initials])
#branch_name = '-'.join([reviewer_attrs['type'],'review','by',initials])
branch_name = '_'.join(['review',initials])
# TODO: replace with subprocess + git
#checkout_review_branch(repo_obj, branch_name)