def get_original_staves(MEI_tree, alternates_list, original_staves_NUM): """Returns a list of all staff objects of which other staff objects are marked as supplied staves; i.e. the ones whose staff information should be removed, though their place in the staff group will be held. """ # Now get list of actuall staff objects all_staves = get_all_staves(MEI_tree) original_staves = [] for staff in all_staves: if staff.getAttribute('n').getValue() in original_staves_NUM: original_staves.append(staff) return original_staves
def get_recon_staves(MEI_tree, alternates_list): """Returns a list of all staff objects that are reconstructions of other staves, and should be moved inside the <app> of those staves. """ recon_staves_NUM = get_recon_staves_NUM(MEI_tree, alternates_list) # Now get list of actuall staff objects all_staves = get_all_staves(MEI_tree) recon_staves = [] for staff in all_staves: if staff.getAttribute('n').getValue() in recon_staves_NUM: recon_staves.append(staff) return recon_staves
def get_supplied_staves(MEI_tree, alternates_list, var_type_list): """Returns a list of all staff objects that are substituting for other staves, and should be moved inside the <app> of those staves. """ supplied_staves_NUM = get_supplied_staves_NUM(MEI_tree, alternates_list, var_type_list) # Now get list of actual staff objects all_staves = get_all_staves(MEI_tree) supplied_staves = [] for staff in all_staves: if staff.getAttribute('n').getValue() in supplied_staves_NUM: supplied_staves.append(staff) return supplied_staves
def make_orig_app(MEI_tree, original_staves): """Based on the list of original staves, replace them with empty <app> elements. and remove the placeholder staff elements. """ all_staves = get_all_staves(MEI_tree) # Go through all staves to maintain original order for staff in all_staves: parent_measure = staff.getParent() old_staff_n = staff.getAttribute('n').getValue() # For original staves, which should be replaced with <app>: if staff in original_staves: new_app = MeiElement('app') new_app.addAttribute('n', old_staff_n) # Add <app> where <staff> was, and delete the latter parent_measure.removeChild(staff) parent_measure.addChild(new_app) # Otherwise, remove it and add it again, so that it will # be in its proper (numerical-order) place. else: parent_measure.removeChild(staff) parent_measure.addChild(staff)
def remove_ignored_staves(MEI_tree, ignored_staves): for staff in get_all_staves(MEI_tree): if staff.getAttribute('n').getValue() in ignored_staves: staff.getParent().removeChild(staff)