]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Add sanity check before setting a duration
authorReinhold Kainhofer <reinhold@kainhofer.com>
Wed, 10 Oct 2007 13:00:03 +0000 (15:00 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Wed, 10 Oct 2007 13:00:03 +0000 (15:00 +0200)
scripts/musicxml2ly.py

index b31511a2919f7cc3856cac768ce3fbaa4afd4ba1..e07584eae23f01cf7e1722b6c41962864889e847 100644 (file)
@@ -156,7 +156,14 @@ def rational_to_lily_duration (rational_len):
     d = musicexp.Duration ()
     d.duration_log = {1: 0, 2: 1, 4:2, 8:3, 16:4, 32:5, 64:6, 128:7, 256:8, 512:9}.get (rational_len.denominator (), -1)
     d.factor = Rational (rational_len.numerator ())
-    return d
+    if d.duration_log < 0:
+        error_message ("Encountered rational duration with denominator %s, "
+                       "unable to convert to lilypond duration" %
+                       rational_len.denominator ())
+        # TODO: Test the above error message
+        return None
+    else:
+        return d
 
 def musicxml_partial_to_lily (partial_len):
     if partial_len > 0: