'Repair a measure if it is empty by inserting a whole measure rest.
If a <measure> only consists of a <forward> element that advances
the time cursor, remove the <forward> element and replace
with a whole measure rest of the same duration.
Args:
measure: The measure to repair.'

def _repair_empty_measure(self, measure):

    forward_count = len(measure.findall('forward'))
    note_count = len(measure.findall('note'))
    if ((note_count == 0) and (forward_count == 1)):
        xml_forward = measure.find('forward')
        xml_duration = xml_forward.find('duration')
        forward_duration = int(xml_duration.text)
        measure.remove(xml_forward)
        new_note = '<note>'
        new_note += (('<rest    /><duration>' + str(forward_duration)) + '</duration>')
        new_note += '<voice>1</voice><type>whole</type><staff>1</staff>'
        new_note += '</note>'
        new_note_xml = ET.fromstring(new_note)
        measure.append(new_note_xml)
