]> git.donarmstrong.com Git - lilypond.git/blobdiff - python/musicxml.py
Fix cross-staff thinko.
[lilypond.git] / python / musicxml.py
index 8413480aef40c668679ce9818ce35cfb213677ae..431bcd695d69949e500d533c1fb2b23d5e4ebb50 100644 (file)
@@ -15,7 +15,7 @@ def error (str):
 
 def escape_ly_output_string (input_string):
     return_string = input_string
-    needs_quotes = not re.match (u"^[a-zA-ZäöüÜÄÖßñ]*$", return_string);
+    needs_quotes = not re.match (u"^[a-zA-ZäöüÜÄÖß,\.!:ñ]*$", return_string);
     if needs_quotes:
         return_string = "\"" + string.replace (return_string, "\"", "\\\"") + "\""
     return return_string
@@ -35,6 +35,13 @@ def musicxml_duration_to_log (dur):
              'longa': -2,
              'long': -2}.get (dur, 0)
 
+def interpret_alter_element (alter_elm):
+    alter = 0
+    if alter_elm:
+        val = eval(alter_elm.get_text ())
+        if type (val) in (int, float):
+            alter = val
+    return alter
 
 
 class Xml_node:
@@ -252,10 +259,7 @@ class Pitch (Music_xml_node):
 
     def get_alteration (self):
        ch = self.get_maybe_exist_typed_child (get_class (u'alter'))
-       alter = 0
-       if ch:
-           alter = int (ch.get_text ().strip ())
-       return alter
+       return interpret_alter_element (ch)
 
 class Unpitched (Music_xml_node):
     def get_step (self):
@@ -415,7 +419,7 @@ class Attributes (Measure_element):
                 if isinstance (i, KeyStep):
                     current_step = int (i.get_text ())
                 elif isinstance (i, KeyAlter):
-                    alterations.append ([current_step, int (i.get_text ())])
+                    alterations.append ([current_step, interpret_alter_element (i)])
                 elif isinstance (i, KeyOctave):
                     nr = -1
                     if hasattr (i, 'number'):
@@ -426,8 +430,6 @@ class Attributes (Measure_element):
                     else:
                         i.message (_ ("Key alteration octave given for a "
                             "non-existing alteration nr. %s, available numbers: %s!") % (nr, len(alterations)))
-                    i.message ( "Non-standard key signature (after octave %s for alter nr %s): %s" % (i.get_text (), nr, alterations))
-            i.message ( "Non-standard key signature with alterations %s found!" % alterations)
             return alterations
 
     def get_transposition (self):
@@ -537,6 +539,8 @@ class Syllabic (Music_xml_node):
         return (text == "begin") or (text == "middle")
 class Elision (Music_xml_node):
     pass
+class Extend (Music_xml_node):
+    pass
 class Text (Music_xml_node):
     pass
 
@@ -1059,10 +1063,7 @@ class DirType (Music_xml_node):
 class Bend (Music_xml_node):
     def bend_alter (self):
         alter = self.get_maybe_exist_named_child ('bend-alter')
-        if alter:
-            return alter.get_text()
-        else:
-            return 0
+        return interpret_alter_element (alter)
 
 class Words (Music_xml_node):
     pass
@@ -1080,10 +1081,7 @@ class ChordPitch (Music_xml_node):
         return ch.get_text ().strip ()
     def get_alteration (self):
         ch = self.get_maybe_exist_typed_child (get_class (self.alter_class_name ()))
-        alter = 0
-        if ch:
-            alter = int (ch.get_text ().strip ())
-        return alter
+        return interpret_alter_element (ch)
 
 class Root (ChordPitch):
     pass
@@ -1106,10 +1104,7 @@ class ChordModification (Music_xml_node):
         return value
     def get_alter (self):
         ch = self.get_maybe_exist_typed_child (get_class (u'degree-alter'))
-        value = 0
-        if ch:
-            value = int (ch.get_text ().strip ())
-        return value
+        return interpret_alter_element (ch)
 
 
 class Frame (Music_xml_node):
@@ -1180,6 +1175,7 @@ class_dict = {
         'direction-type': DirType,
        'duration': Duration,
         'elision': Elision,
+        'extend': Extend,
         'frame': Frame,
         'frame-note': Frame_Note,
         'figured-bass': FiguredBass,