]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/convert-ly.py
patch::: 1.3.139.jcn1
[lilypond.git] / scripts / convert-ly.py
index 348161524142f8e1dd240053ba68972f431164ba..a960d24e7c575a0931eedf9356965202d5b791a9 100644 (file)
@@ -24,8 +24,10 @@ import  string
 import re
 import time
 
-lilypond_version_re_str = '\\\\version *\"(.*)\"'
-lilypond_version_re = re.compile(lilypond_version_re_str)
+# Did we ever have \mudela-version?  I doubt it.
+# lilypond_version_re_str = '\\\\version *\"(.*)\"'
+lilypond_version_re_str = '\\\\(mudela-)?version *\"(.*)\"'
+lilypond_version_re = re.compile (lilypond_version_re_str)
 
 def program_id ():
        return '%s (GNU LilyPond) %s' %(program_name,  version);
@@ -92,11 +94,11 @@ def version_cmp (t1, t2):
                        return t1[x] - t2[x]
        return 0
 
-def guess_lilypond_version(filename):
+def guess_lilypond_version (filename):
        s = gulp_file (filename)
        m = lilypond_version_re.search (s)
        if m:
-               return m.group(1)
+               return m.group (2)
        else:
                return ''
 
@@ -177,6 +179,8 @@ if 1:
 if 1:
        def conv(str):
                str =  re.sub ('\\\\melodic', '\\\\notes',str)
+               if re.search ('\\\\header', str):
+                       sys.stderr.write ('\nNot smart enough to convert \\multi constructs')
                        
                return str
        
@@ -185,8 +189,7 @@ if 1:
 if 1:
        def conv(str):
                str =  re.sub ('default_paper *=', '',str)
-               str =  re.sub ('default_midi *=', '',x)                 
-                       
+               str =  re.sub ('default_midi *=', '',str)
                return str
        
        conversions.append (((1,0,4), conv, 'default_{paper,midi}'))
@@ -570,8 +573,18 @@ if 1:
 
                str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?timeSignatureStyle"? *= *"([^"]*)"', '\\\\property \\1.TimeSignature \\\\override #\'style = #\'\\2', str) 
 
-               str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?horizontalNoteShift"? *= *"?#?([0-9]+)"?', '\\\\property \\1.NoteColumn \\\\override #\'horizonta-shift = #\\2', str) 
+               str = re.sub ('"?timeSignatureStyle"? *= *#?""', 'TimeSignature \\\\override #\'style = ##f', str)
+               
+               str = re.sub ('"?timeSignatureStyle"? *= *#?"([^"]*)"', 'TimeSignature \\\\override #\'style = #\'\\1', str)
+               
+               str = re.sub ('#\'style *= #*"([^"])"', '#\'style = #\'\\1', str)
+               
+               str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?horizontalNoteShift"? *= *"?#?([0-9]+)"?', '\\\\property \\1.NoteColumn \\\\override #\'horizontal-shift = #\\2', str) 
 
+               # ugh
+               str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *""', '\\\\property \\1.Stem \\\\override #\'flag-style = ##f', str)
+               
+               str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *"([^"]*)"', '\\\\property \\1.Stem \\\\override #\'flag-style = #\'\\2', str) 
                return str
        
        conversions.append (((1,3,98), conv, 'CONTEXT.textStyle -> GROB.#font-style '))
@@ -664,6 +677,28 @@ if 1:
        
        conversions.append (((1,3,122), conv, 'drarnChords -> chordChanges, \\musicalpitch -> \\pitch'))
 
+if 1:
+       def conv (str):
+               str = re.sub ('ly-([sg])et-elt-property', 'ly-\\1et-grob-property', str)
+               return str
+       
+       conversions.append (((1,3,136), conv, 'ly-X-elt-property -> ly-X-grob-property'))
+
+if 1:
+       def conv (str):
+               str = re.sub ('point-and-click +#t', 'point-and-click line-column-location', str)
+               return str
+       
+       conversions.append (((1,3,138), conv, 'point-and-click argument changed to procedure.'))
+
+if 1:
+       def conv (str):
+               str = re.sub ('followThread', 'followVoice', str)
+               str = re.sub ('FollowThread', 'VoiceFollower', str)
+               return str
+       
+       conversions.append (((1,3,138), conv, 'followThread -> followVoice.'))
+
 
 ############################
        
@@ -695,10 +730,13 @@ def do_conversion (infile, from_version, outfile, to_version):
        if last_conversion:
                sys.stderr.write ('\n')
                new_ver =  '\\version \"%s\"' % tup_to_str (last_conversion)
+               # JUNKME?
+               # ugh: this all really doesn't help
+               # esp. as current conversion rules are soo incomplete
                if re.search (lilypond_version_re_str, str):
                        str = re.sub (lilypond_version_re_str,'\\'+new_ver , str)
-               else:
-                       str = new_ver + '\n' + str
+               #else:
+               #       str = new_ver + '\n' + str
 
                outfile.write(str)
 
@@ -797,4 +835,9 @@ for f in files:
        try:
                do_one_file (f)
        except UnknownVersion:
+               sys.stderr.write ('\n')
+               sys.stderr.write ("%s: can't determine version for %s" % (program_name, f))
+               sys.stderr.write ('\n')
+               sys.stderr.write ("%s: skipping" % program_name)
                pass
+sys.stderr.write ('\n')