X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=python%2Fmusicxml.py;h=278e108b1da4075b436ba8af7fe4ba0f7890f465;hb=8a7f57d93480c1ac296623ef1abfda23eb9544ea;hp=2ddeacbc3a79fb940d75810b9feb0c73fdb2eba9;hpb=20596e17d6f8026f7199c9ae0e5f03517631a66c;p=lilypond.git diff --git a/python/musicxml.py b/python/musicxml.py index 2ddeacbc3a..278e108b1d 100644 --- a/python/musicxml.py +++ b/python/musicxml.py @@ -9,9 +9,6 @@ import lilylib as ly _ = ly._ -def error (str): - ly.stderr_write ((_ ("error: %s") % str) + "\n") - def escape_ly_output_string (input_string): return_string = input_string @@ -76,23 +73,23 @@ class Xml_node: return ''.join ([c.get_text () for c in self._children]) def message (self, msg): - ly.stderr_write (msg+'\n') + ly.warning (msg) p = self while p: - sys.stderr.write (' In: <%s %s>\n' % (p._name, ' '.join (['%s=%s' % item for item in p._attribute_dict.items ()]))) + ly.progress (' In: <%s %s>\n' % (p._name, ' '.join (['%s=%s' % item for item in p._attribute_dict.items ()]))) p = p.get_parent () def dump (self, indent = ''): - sys.stderr.write ('%s<%s%s>' % (indent, self._name, ''.join ([' %s=%s' % item for item in self._attribute_dict.items ()]))) + ly.debug_output ('%s<%s%s>' % (indent, self._name, ''.join ([' %s=%s' % item for item in self._attribute_dict.items ()]))) non_text_children = [c for c in self._children if not isinstance (c, Hash_text)] if non_text_children: - sys.stderr.write ('\n') + ly.debug_output ('\n') for c in self._children: c.dump (indent + " ") if non_text_children: - sys.stderr.write (indent) - sys.stderr.write ('\n' % self._name) + ly.debug_output (indent) + ly.debug_output ('\n' % self._name) def get_typed_children (self, klass): @@ -128,7 +125,7 @@ class Xml_node: def get_unique_typed_child (self, klass): cn = self.get_typed_children(klass) if len (cn) <> 1: - sys.stderr.write (self.__dict__ + '\n') + ly.error (self.__dict__) raise 'Child is not unique for', (klass, 'found', cn) return cn[0] @@ -246,7 +243,7 @@ class Hash_comment (Music_xml_node): pass class Hash_text (Music_xml_node): def dump (self, indent = ''): - sys.stderr.write ('%s' % string.strip (self._data)) + ly.debug_output ('%s' % string.strip (self._data)) class Pitch (Music_xml_node): def get_step (self): @@ -355,7 +352,7 @@ class Attributes (Measure_element): if mxl.get_maybe_exist_named_child ('senza-misura'): # TODO: Handle pieces without a time signature! - error (_ ("Senza-misura time signatures are not yet supported!")) + ly.warning (_ ("Senza-misura time signatures are not yet supported!")) return (4, 4) else: signature = [] @@ -517,7 +514,7 @@ class Part_list (Music_xml_node): if instrument_name: return instrument_name else: - ly.stderr_write (_ ("Unable to find instrument for ID=%s\n") % id) + ly.warning (_ ("Unable to find instrument for ID=%s\n") % id) return "Grand Piano" class Part_group (Music_xml_node): @@ -762,6 +759,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 +787,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 +796,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() @@ -837,7 +842,7 @@ class Part (Music_xml_node): continue if isinstance (n, Attributes): - # assign these only to the voices they really belongs to! + # assign these only to the voices they really belong to! for (s, vids) in staff_to_voice_dict.items (): staff_attributes = part.extract_attributes_for_staff (n, s) if staff_attributes: