Beispiel #1
0
def staff_list(MEI_tree):
    all_staffGrp = MEI_tree.getDescendantsByName("staffGrp")
    staff_list = []
    if len(all_staffGrp) < 1:
        logging.error("Error: No staffGrp in file.")
    else:
        if len(all_staffGrp) > 1:
            logging.warning("Warning: more than one <staffGrp>; using first occurrence.")
        staffGrp = all_staffGrp[0]
        for staffDef in staffGrp.getDescendantsByName("staffDef"):
            staff_name = staffDef.getAttribute("label").getValue()
            staff_name_split = split("_", staff_name)
            staff_n = staffDef.getAttribute("n").getValue()

            staff_voice = staff_name_split[0]
            staff_type = VARIANT
            staff_source = ""
            # If it's a special staff (variant, reconstruction, etc.)
            if len(staff_name_split) > 1:
                staff_type = staff_role(staff_name_split[1])
                if len(staff_name_split) > 2:
                    staff_source = staff_name_split[2]
            # If it's an empty staff
            if is_empty(MEI_tree, staff_n):
                staff_type = BLANK
                staff_source = staff_name

            staff_list.append((staff_name, staff_voice, staff_type, source_name2NCName(staff_source), staff_n))
    return staff_list
def validate_ncnames(alternates_list):
    res_list = []
    for alternates_item in alternates_list:
        res_item = (alternates_item[0],
                    alternates_item[1],
                    alternates_item[2],
                    source_name2NCName(alternates_item[3])
                    )
        res_list.append(res_item)
    return res_list
Beispiel #3
0
def staff_list(MEI_tree):
    def get_role_from_name(staff_name):
        if 'recon' in staff_name.lower():
            return RECONSTRUCTION
        elif 'emend' in staff_name.lower() or 'amend' in staff_name.lower():
            return EMENDATION
        elif 'concord' in staff_name.lower():
            return CONCORDANCE
        elif 'ignore' in staff_name.lower():
            return IGNORED
        # Make VARIANT the default case
        else:
            return VARIANT

    all_staffGrp = MEI_tree.getDescendantsByName('staffGrp')
    staff_list = []
    if len(all_staffGrp) < 1:
        logging.error("Error: No staffGrp in file.")
    else:
        if len(all_staffGrp) > 1:
            logging.warning("Warning: more than one <staffGrp>; using first occurrence.")
        staffGrp = all_staffGrp[0]
        for staffDef in staffGrp.getDescendantsByName('staffDef'):
            staff_name = staffDef.getAttribute('label').getValue()
            staff_name_split = split('_', staff_name)
            staff_n = staffDef.getAttribute('n').getValue()

            staff_voice = staff_name_split[0]
            # VARIANT is the default -- original staves are
            # marked as variants of themselves.
            staff_type = VARIANT
            staff_source = ''
            # If it's a special staff (true variant, reconstruction, etc.)
            if len(staff_name_split) > 1:
                staff_type = get_role_from_name(staff_name)
                if len(staff_name_split) > 2:
                    staff_source = staff_name_split[2]
            # If it's an empty staff
            if is_empty(MEI_tree, staff_n):
                staff_type = BLANK
                staff_source = staff_name

            staff_list.append(
                (staff_name,
                 staff_voice,
                 staff_type,
                 source_name2NCName(staff_source),
                 staff_n,
                 )
            )
    return staff_list
Beispiel #4
0
def staff_list(MEI_tree):
	all_staffGrp = MEI_tree.getDescendantsByName('staffGrp')
	staff_list = []
	if len(all_staffGrp) < 1:
		logging.error("Error: No staffGrp in file.")
	else:
		if len(all_staffGrp) > 1:
			logging.warning("Warning: more than one <staffGrp>; using first occurrence.")
		staffGrp = all_staffGrp[0]
		for staffDef in staffGrp.getDescendantsByName('staffDef'):
			staff_name = staffDef.getAttribute('label').getValue()
			staff_name_split = split('_', staff_name)
			staff_n = staffDef.getAttribute('n').getValue()

			staff_voice = staff_name_split[0]
			staff_type = VARIANT
			staff_source = ''
			if len(staff_name_split)>1:
				staff_type = staff_role(staff_name_split[1])
				if len(staff_name_split)>2:
					staff_source = staff_name_split[2]
			staff_list.append((staff_name, staff_voice, staff_type, source_name2NCName(staff_source), staff_n))
	return staff_list