]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/convert-ly.py
add verbs.
[lilypond.git] / scripts / convert-ly.py
index d9fe48c397cee50c23dcd2cdf0ff58cd67ab3d12..9326c6f399a654c6fd4d36a010fe0029e0457707 100644 (file)
@@ -4,7 +4,7 @@
 # 
 # source file of the GNU LilyPond music typesetter
 # 
-# (c) 1998--2002  Han-Wen Nienhuys <hanwen@cs.uu.nl>
+# (c)  1998--2003  Han-Wen Nienhuys <hanwen@cs.uu.nl>
 #                 Jan Nieuwenhuizen <janneke@gnu.org>
 
 
@@ -46,12 +46,11 @@ Try to convert to newer lilypond-versions.  The version number of the
 input is guessed by default from \version directive
 
 Options:
-  -a, --assume-old       apply all conversions to unversioned files
   -h, --help             print this help
-  -e, --edit             in place edit
-  -f, --from=VERSION     start from version. Overrides \version found in file.
+  -e, --edit             edit in place
+  -f, --from=VERSION     start from version; overrides \version found in file
   -s, --show-rules       print all rules.
-  -t, --to=VERSION       target version
+  -t, --to=VERSION       show target version
   -n, --no-version       don't add new version stamp.
       --version          print program version
 
@@ -1076,6 +1075,9 @@ if 1:
 
 if 1:
        def conv(str):
+               if re.search ('new-chords-done',str):
+                       return str
+               
                str = re.sub (r'<<', '< <', str)
                str = re.sub (r'>>', '> >', str)
                return str
@@ -1087,9 +1089,9 @@ if 1:
                str = re.sub (r"\\transpose", r"\\transpose c'", str)
                str = re.sub (r"\\transpose c' *([a-z]+)'", r"\\transpose c \1", str)
                return str
-       conversions.append (((1,7,5), conv, '\transpose TO -> \transpose FROM  TO'))
+       conversions.append (((1,7,5), conv, '\\transpose TO -> \\transpose FROM  TO'))
 
-if 0:
+if 1:
        def conv(str):
                kws =   ['arpeggio',
                         'sustainDown',
@@ -1106,9 +1108,146 @@ if 0:
                         ]
 
                origstr = string.join (kws, '|')
-               str = re.sub (r'([^-])\\(%s)\b' % origstr, r'\1-\\\2', str)
-       conversions.append (((1,7,4), conv, 'note\\script -> note-\script'))
+               str = re.sub (r'([^_^-])\\(%s)\b' % origstr, r'\1-\\\2', str)
+               return str
+       conversions.append (((1,7,6), conv, 'note\\script -> note-\script'))
+
+
+if 1:
+       def conv(str):
+               str = re.sub (r"\\property *ChordNames *\. *ChordName *\\(set|override) *#'style *= *#('[a-z]+)",
+                             r"#(set-chord-name-style \2)", str)
+               str = re.sub (r"\\property *ChordNames *\. *ChordName *\\revert *#'style",
+                             r"", str)
+               return str
+       conversions.append (((1,7,10), conv, "\property ChordName #'style -> #(set-chord-name-style 'style)"))
+       
+
+
+if 1:
+       def conv(str):
+               str = re.sub (r"ly:transpose-pitch", "ly:pitch-transpose", str)
+               
+               return str
+       conversions.append (((1,7,11), conv, "transpose-pitch -> pitch-transpose"))
+
+if 1:
+       def conv(str):
+               str = re.sub (r"ly:get-molecule-extent", "ly:molecule-get-extent", str)
+               str = re.sub (r"ly:set-molecule-extent!", "ly:molecule-set-extent!", str)
+               str = re.sub (r"ly:add-molecule", "ly:molecule-add", str)
+               str = re.sub (r"ly:combine-molecule-at-edge", "ly:molecule-combine-at-edge", str)
+               str = re.sub (r"ly:align-to!", "ly:molecule-align-to!", str)
+               
+               return str
+       
+       conversions.append (((1,7,13), conv, "ly:XX-molecule-YY -> ly:molecule-XX-YY")) 
+
+if 1:
+       def conv(str):
+               str = re.sub (r"linewidth *= *-[0-9.]+ *(\\mm|\\cm|\\in|\\pt)?", 'raggedright = ##t', str )
+               return str
+       
+       conversions.append (((1,7,15), conv, "linewidth = -1 -> raggedright = ##t"))    
+
+if 1:
+       def conv(str):
+               str = re.sub ("divisiomaior",
+                             "divisioMaior", str)
+               str = re.sub ("divisiominima",
+                             "divisioMinima", str)
+               str = re.sub ("divisiomaxima",
+                             "divisioMaxima", str)
+               return str
+       
+       conversions.append (((1,7,16), conv, "divisiomaior -> divisioMaior"))
+
+if 1:
+       def conv(str):
+               str = re.sub ("Skip_req_swallow_translator",
+                             "Skip_event_swallow_translator", str)
+               return str
+       
+       conversions.append (((1,7,17), conv, "Skip_req  -> Skip_event"))
+
+if 1:
+       def conv(str):
+               str = re.sub ("groupOpen",
+                             "startGroup", str)
+               str = re.sub ("groupClose",
+                             "stopGroup", str)
+               str = re.sub ("#'outer",
+                             "#'enclose-bounds", str)
+
+               return str
+       
+       conversions.append (((1,7,18), conv,
+                            """groupOpen/Close  -> start/stopGroup,
+                            #'outer  -> #'enclose-bounds
+                            """))
+
+if 1:
+       def conv(str):
+               if re.search( r'\\GraceContext', str):
+                       sys.stderr.write ("GraceContext has been removed")
+                       sys.stderr.write ("please use #(add-to-grace-init .. )")
+                       raise FatalConversionError()
+
+               str = re.sub ('HaraKiriStaffContext', 'RemoveEmptyStaffContext', str)
+               return str
+       
+       conversions.append (((1,7,19), conv,"remove GraceContext"))
+
+
+
+if 1:
+       def conv(str):
+               str = re.sub (
+                       r"(set|override|revert) *#'type",
+                       r"\1 #'style",
+                       str)
+               return str
+       
+       conversions.append (((1,7,22), conv,"remove GraceContext"))
+
+if 1:
+       def conv(str):
+               str = re.sub (
+                       "barNonAuto *= *##t",
+                       "automaticBars = ##f",
+                       str)
+               str = re.sub (
+                       "barNonAuto *= *##f",
+                       "automaticBars = ##t",
+                       str)
+               return str
        
+       conversions.append (((1,7,23), conv,"barNonAuto -> automaticBars"))
+       
+
+if 1:
+       def conv(str):
+               if re.search( r'-(start|stop)Cluster', str):
+                       sys.stderr.write ("""Cluster syntax has been changed.
+Please refer to the manual for details, and convert manually.
+""")
+                       
+                       raise FatalConversionError()
+
+               return str
+       
+       conversions.append (((1,7,24), conv,"cluster syntax"))
+
+if 1:
+       def conv(str):
+               str = re.sub (r"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\(override|set) *#'pedal-type *",
+                               r"\property Staff.pedal\1Style ", str)
+               str = re.sub (r"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\revert *#'pedal-type", '', str)
+               return str
+       
+       conversions.append (((1,7,28), conv,"new Pedal style syntax"))
+
+
 
 ################################
 #      END OF CONVERSIONS      
@@ -1212,7 +1351,7 @@ from_version = ()
 outfile_name = ''
 
 (options, files) = getopt.getopt (
-       sys.argv[1:], 'ao:f:t:senh', ['no-version', 'assume-old', 'version', 'output', 'show-rules', 'help', 'edit', 'from=', 'to='])
+       sys.argv[1:], 'ao:f:t:senh', ['no-version', 'version', 'output', 'show-rules', 'help', 'edit', 'from=', 'to='])
 
 for opt in options:
        o = opt[0]
@@ -1234,8 +1373,6 @@ for opt in options:
                sys.exit(0)
        elif o == '--output' or o == '-o':
                outfile_name = a
-       elif o == '--assume-old' or o == '-a':
-               assume_old = 1
        elif o == '--no-version' or o == '-n':
                add_version = 0
        else: