]> git.donarmstrong.com Git - lilypond.git/commitdiff
abc2ly: Fix church modes (Issue #512), was a simple upper/lowercase issue; Generalize...
authorReinhold Kainhofer <reinhold@kainhofer.com>
Thu, 12 Nov 2009 15:49:43 +0000 (16:49 +0100)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Thu, 12 Nov 2009 16:25:17 +0000 (17:25 +0100)
scripts/abc2ly.py

index 626387a21d042ab4e2c602233455a63ac0a2ad5a..3100c136817e4aec495d68a789441636a6bf074c 100644 (file)
@@ -680,16 +680,19 @@ def try_parse_header_line (ln, state):
         if g == 'K': # KEY
             a = check_clef(a)
             if a:
-                m = re.match ('^([^ \t]*) *(.*)$', a) # seperate clef info
+                m = re.match ('^([^ \t]*) *([^ ]*)( *)(.*)$', a) # seperate clef info
                 if m:
                     # there may or may not be a space
                     # between the key letter and the mode
-                    if key_lookup.has_key(m.group(2)[0:3]):
-                        key_info = m.group(1) + m.group(2)[0:3]
-                        clef_info = m.group(2)[4:]
+                    # convert the mode to lower-case before comparing
+                    mode = m.group(2)[0:3].lower();
+                    if key_lookup.has_key(mode):
+                        # use the full mode, not only the first three letters
+                        key_info = m.group(1) + m.group(2).lower()
+                        clef_info = a[m.start(4):]
                     else:
                         key_info = m.group(1)
-                        clef_info = m.group(2)
+                        clef_info = a[m.start(2):]
                     __main__.global_key  = compute_key (key_info)
                     k = lily_key (key_info)
                     if k: