X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=python%2Fmusicxml.py;h=be3c61ca8f99a9bc4cf0ba8d7d0c992826359eba;hb=7490718e554fdf4019c2e6420072c0dbe4981d3d;hp=0400cce2532de083414c0ebbb3a730cc75e32b75;hpb=ff46d5884c9c99ed33896585fd9d245e953092fb;p=lilypond.git diff --git a/python/musicxml.py b/python/musicxml.py index 0400cce253..be3c61ca8f 100644 --- a/python/musicxml.py +++ b/python/musicxml.py @@ -35,6 +35,8 @@ def musicxml_duration_to_log (dur): 'longa': -2, 'long': -2}.get (dur, 0) + + def interpret_alter_element (alter_elm): alter = 0 if alter_elm: @@ -253,9 +255,8 @@ class Pitch (Music_xml_node): return step def get_octave (self): ch = self.get_unique_typed_child (get_class (u'octave')) - - step = ch.get_text ().strip () - return int (step) + octave = ch.get_text ().strip () + return int (octave) def get_alteration (self): ch = self.get_maybe_exist_typed_child (get_class (u'alter')) @@ -417,7 +418,7 @@ class Attributes (Measure_element): current_step = 0 for i in key.get_all_children (): if isinstance (i, KeyStep): - current_step = int (i.get_text ()) + current_step = i.get_text ().strip () elif isinstance (i, KeyAlter): alterations.append ([current_step, interpret_alter_element (i)]) elif isinstance (i, KeyOctave): @@ -997,7 +998,10 @@ class Beam (Music_xml_spanner): def get_type (self): return self.get_text () def is_primary (self): - return self.number == "1" + if hasattr (self, 'number'): + return self.number == "1" + else: + return True class Wavy_line (Music_xml_spanner): pass @@ -1036,15 +1040,14 @@ class Rest (Music_xml_node): def get_step (self): ch = self.get_maybe_exist_typed_child (get_class (u'display-step')) if ch: - step = ch.get_text ().strip () - return step + return ch.get_text ().strip () else: return None def get_octave (self): ch = self.get_maybe_exist_typed_child (get_class (u'display-octave')) if ch: - step = ch.get_text ().strip () - return int (step) + oct = ch.get_text ().strip () + return int (oct) else: return None