From d2e74971775f3ae6e2ca1dc7802d79a887f4f033 Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Thu, 8 Sep 2011 19:03:55 +0200 Subject: [PATCH] MusicXML: If staff number is given in an element, make it work even if other elements don't have a staff number --- python/musicxml.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/python/musicxml.py b/python/musicxml.py index 3a38efafdb..7ba771fa8d 100644 --- a/python/musicxml.py +++ b/python/musicxml.py @@ -762,6 +762,8 @@ class Part (Music_xml_node): attributes._dict = attr._dict.copy () attributes._original_tag = attr # copy only the relevant children over for the given staff + if staff == "None": + staff = "1" for c in attr._children: if (not (hasattr (c, 'number') and (c.number != staff)) and not (isinstance (c, Hash_text))): @@ -788,6 +790,8 @@ class Part (Music_xml_node): if voice_id: vid = voice_id.get_text () elif isinstance (n, Note): + # TODO: Check whether we shall really use "None" here, or + # rather use "1" as the default? vid = "None" staff_id = n.get_maybe_exist_named_child (u'staff') @@ -795,6 +799,10 @@ class Part (Music_xml_node): if staff_id: sid = staff_id.get_text () else: + # TODO: Check whether we shall really use "None" here, or + # rather use "1" as the default? + # If this is changed, need to change the corresponding + # check in extract_attributes_for_staff, too. sid = "None" if vid and not voices.has_key (vid): voices[vid] = Musicxml_voice() -- 2.39.2