]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/convert-ly.py
Changed scripts/* to use sys.argv[0]
[lilypond.git] / scripts / convert-ly.py
index 2211b25055bb557a2885a6f9fa79b7b51a77fdea..b683a293f33bfffdd4c98816fff3525620332825 100644 (file)
@@ -1,10 +1,10 @@
 #!@PYTHON@
 #
 # convert-ly.py -- Update old LilyPond input files (fix name?)
-# 
+#
 # source file of the GNU LilyPond music typesetter
-# 
-# (c)  1998--2003  Han-Wen Nienhuys <hanwen@cs.uu.nl>
+#
+# (c) 1998--2004  Han-Wen Nienhuys <hanwen@cs.uu.nl>
 #                 Jan Nieuwenhuizen <janneke@gnu.org>
 
 
@@ -15,9 +15,6 @@
 # 0.2
 #  - rewrite in python
 
-program_name = 'convert-ly'
-version = '@TOPLEVEL_VERSION@'
-
 import os
 import sys
 import __main__
@@ -26,9 +23,13 @@ import  string
 import re
 import time
 
+program_name = sys.argv[0]
+
+version = '@TOPLEVEL_VERSION@'
+
 # Did we ever have \mudela-version?  I doubt it.
 # lilypond_version_re_str = '\\\\version *\"(.*)\"'
-lilypond_version_re_str = '\\\\(mudela-)?version *\"(.*)\"'
+lilypond_version_re_str = '\\\\(mudela-)?version *\"([^"]+)\"'
 lilypond_version_re = re.compile (lilypond_version_re_str)
 add_version = 1
 
@@ -41,7 +42,7 @@ def identify ():
 
 def usage ():
        sys.stdout.write (
-               r"""Usage: %s [OPTIONS]... [FILE]... 
+               r"""Usage: %s [OPTIONS]... [FILE]...
 Try to convert to newer lilypond-versions.  The version number of the
 input is guessed by default from \version directive.
 
@@ -148,7 +149,7 @@ if 1:                                       # need new a namespace
                return str
 
        conversions.append ((
-               ((0,1,20), conv, 'deprecated \\textstyle, new \key syntax')))
+               ((0,1,20), conv, 'deprecated \\textstyle, new \\key syntax')))
 
 
 if 1:
@@ -402,7 +403,7 @@ if 1:
                return str
 
        conversions.append (((1,3,4), conv,
-                '\\cadenza -> \cadenza{On|Off}'))
+                '\\cadenza -> \\cadenza{On|Off}'))
 
 if 1:
        def conv (str):
@@ -517,7 +518,7 @@ if 1:
                str = re.sub (r"""\\key *([a-z]+) *;""", r"""\\key \1 \major;""",str);
                return str
        conversions.append (((1,3,59), conv,
-                '\key X ; -> \key X major; ')) 
+                '\key X ; -> \key X major; '))
 
 if 1:
        def conv (str):
@@ -632,7 +633,7 @@ if 1:
                str = re.sub ('\\\\property *"?Voice"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Voice.TextScript \\\\set #\'font-style = #\'\\1', str)
                str = re.sub ('\\\\property *"?Lyrics"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Lyrics.LyricText \\\\set #\'font-style = #\'\\1', str)
 
-               str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?timeSignatureStyle"? *= *"([^"]*)"', '\\\\property \\1.TimeSignature \\\\override #\'style = #\'\\2', str) 
+               str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?timeSignatureStyle"? *= *"([^"]*)"', '\\\\property \\1.TimeSignature \\\\override #\'style = #\'\\2', str)
 
                str = re.sub ('"?timeSignatureStyle"? *= *#?""', 'TimeSignature \\\\override #\'style = ##f', str)
                
@@ -640,12 +641,12 @@ if 1:
                
                str = re.sub ('#\'style *= #*"([^"])"', '#\'style = #\'\\1', str)
                
-               str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?horizontalNoteShift"? *= *"?#?([-0-9]+)"?', '\\\\property \\1.NoteColumn \\\\override #\'horizontal-shift = #\\2', 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) 
+               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 '))
@@ -866,7 +867,7 @@ if 1:
                              func, str)
                return str
 
-       # 40 ? 
+       # 40 ?
        conversions.append (((1,5,40), conv, 'breakAlignOrder property names'))
        
 
@@ -1008,7 +1009,7 @@ if 1:
                return "(make-span-event '%s %s)" % (mtype , stype)
 
        def subst_definition_ev_name(match):
-               return ' = #%s' % subst_ev_name (match) 
+               return ' = #%s' % subst_ev_name (match)
        def subst_inline_ev_name (match):
                s = subst_ev_name (match)
                return '#(ly-export %s)' % s
@@ -1265,11 +1266,11 @@ if 1:
                        return origstr
 
                durs = []
-               def sub_durs (m):
+               def sub_durs (m, durs = durs):
                        durs.append(m.group(2))
                        return m.group (1)
 
-               str = re.sub ("([a-z]+[,'!? ]*)([0-9.]+)", sub_durs, str)
+               str = re.sub (r"([a-z]+[,'!? ]*)([0-9]+\.*)", sub_durs, str)
                dur_str = ''
 
                for d in durs:
@@ -1284,113 +1285,145 @@ if 1:
 
                last_str = ''
                while last_str <> str:
-                 last_str = str
-                 def sub_tremolos (m):
-                         tr = m.group (2)
-                         if tr not in slur_strs:
-                                 slur_strs.append (tr)
-                         return  m.group (1)
-                 
-                 str = re.sub (r"([a-z]+[',!? ]*)(:[0-9]+)", sub_tremolos, str)
-
-                 def sub_dyn_end (m):
-                         dyns.append (' \!')
-                         return ' ' + m.group(2)
-
-                 str = re.sub (r'(\\!)\s*([a-z]+)', sub_dyn_end, str)
-                 def sub_slurs(m):
-                         if '-)' not in slur_strs:
-                                 slur_strs.append ( ')')
-                         return m.group(1)
-                 def sub_p_slurs(m):
-                         if '-\)' not in slur_strs:
-                                 slur_strs.append ( '\)')
-                         return m.group(1)
-                 str = re.sub (r"\)[ ]*([a-z]+)", sub_slurs, str)
-                 str = re.sub (r"\\\)[ ]*([a-z]+)", sub_p_slurs, str)
-                 def sub_begin_slurs(m):
-                         if '-(' not in slur_strs:
-                                 slur_strs.append ( '(')
-                         return m.group(1)
-                 str = re.sub (r"([a-z]+[,'!?0-9 ]*)\(", sub_begin_slurs, str)
-                 def sub_begin_p_slurs(m):
-                         if '-\(' not in slur_strs:
-                                 slur_strs.append ( '\(')
-                         return m.group(1)
-
-                 str = re.sub (r"([a-z]+[,'!?0-9 ]*)\\\(", sub_begin_p_slurs, str)
-
-                 def sub_dyns (m):
-                         s = m.group(0)
-                         if s == '@STARTCRESC@':
-                                 slur_strs.append ("\\<")
-                         elif s == '@STARTDECRESC@':
-                                 slur_strs.append ("\\>")
-                         elif s == r'-?\\!':
-                                 slur_strs.append ('\\!')
-                         return ''
-
-                 str = re.sub (r'@STARTCRESC@', sub_dyns, str)
-                 str = re.sub (r'-?\\!', sub_dyns, str)
-
-                 def sub_articulations (m):
-                         a = m.group(1)
-                         if a not in slur_strs:
-                                 slur_strs.append (a)
-                         return ''
-
-                 str = re.sub (r"([_^-]\@ACCENT\@)", sub_articulations, str)
-                 str = re.sub (r"([_^-]\\[a-z]+)", sub_articulations, str)
-                 str = re.sub (r"([_^-][>_.+|^-])", sub_articulations, str)
-
-                 def sub_pslurs(m):
-                         slur_strs.append ( ' \\)')
-                         return m.group(1)
-                 str = re.sub (r"\\\)[ ]*([a-z]+)", sub_pslurs, str)
-
-               suffix = string.join (slur_strs, '') + string.join (pslur_strs, '') \
+                       last_str = str
+
+                       def sub_tremolos (m, slur_strs = slur_strs):
+                               tr = m.group (2)
+                               if tr not in slur_strs:
+                                       slur_strs.append (tr)
+                               return  m.group (1)
+                       
+                       str = re.sub (r"([a-z]+[',!? ]*)(:[0-9]+)",
+                                     sub_tremolos, str)
+
+                       def sub_dyn_end (m, dyns = dyns):
+                               dyns.append (' \!')
+                               return ' ' + m.group(2)
+
+                       str = re.sub (r'(\\!)\s*([a-z]+)', sub_dyn_end, str)
+                       def sub_slurs(m, slur_strs = slur_strs):
+                               if '-)' not in slur_strs:
+                                       slur_strs.append (')')
+                               return m.group(1)
+                       
+                       def sub_p_slurs(m, slur_strs = slur_strs):
+                               if '-\)' not in slur_strs:
+                                       slur_strs.append ('\)')
+                               return m.group(1)
+                       
+                       str = re.sub (r"\)[ ]*([a-z]+)", sub_slurs, str)
+                       str = re.sub (r"\\\)[ ]*([a-z]+)", sub_p_slurs, str)
+                       def sub_begin_slurs(m, slur_strs = slur_strs):
+                               if '-(' not in slur_strs:
+                                       slur_strs.append ('(')
+                               return m.group(1)
+                       
+                       str = re.sub (r"([a-z]+[,'!?0-9 ]*)\(",
+                                     sub_begin_slurs, str)
+                       def sub_begin_p_slurs(m, slur_strs = slur_strs):
+                               if '-\(' not in slur_strs:
+                                       slur_strs.append ('\(')
+                               return m.group(1)
+
+                       str = re.sub (r"([a-z]+[,'!?0-9 ]*)\\\(",
+                               sub_begin_p_slurs, str)
+
+                       def sub_dyns (m, slur_strs = slur_strs):
+                               s = m.group(0)
+                               if s == '@STARTCRESC@':
+                                       slur_strs.append ("\\<")
+                               elif s == '@STARTDECRESC@':
+                                       slur_strs.append ("\\>")
+                               elif s == r'-?\\!':
+                                       slur_strs.append ('\\!')
+                               return ''
+
+                       str = re.sub (r'@STARTCRESC@', sub_dyns, str)
+                       str = re.sub (r'-?\\!', sub_dyns, str)
+
+                       def sub_articulations (m, slur_strs = slur_strs):
+                               a = m.group(1)
+                               if a not in slur_strs:
+                                       slur_strs.append (a)
+                               return ''
+
+                       str = re.sub (r"([_^-]\@ACCENT\@)", sub_articulations,
+                                     str)
+                       str = re.sub (r"([_^-]\\[a-z]+)", sub_articulations,
+                                     str)
+                       str = re.sub (r"([_^-][>_.+|^-])", sub_articulations,
+                                     str)
+                       str = re.sub (r'([_^-]"[^"]+")', sub_articulations,
+                                     str)
+
+                       def sub_pslurs(m, slur_strs = slur_strs):
+                               slur_strs.append (' \\)')
+                               return m.group(1)
+                       str = re.sub (r"\\\)[ ]*([a-z]+)", sub_pslurs, str)
+
+               ## end of while <>
+
+               suffix = string.join (slur_strs, '') + string.join (pslur_strs,
+                                                                   '') \
                         + string.join (dyns, '')
 
                return '@STARTCHORD@%s@ENDCHORD@%s%s' % (str , dur_str, suffix)
 
 
 
-
-
        def sub_chords (str):
                simend = '>'
-               simstart = "<" 
+               simstart = '<'
                chordstart = '<<'
                chordend = '>>'
                marker_str = '%% new-chords-done %%'
 
                if re.search (marker_str,str):
                        return str
-               str= re.sub (r'\\<', '@STARTCRESC@', str)
-               str= re.sub (r'\\>', '@STARTDECRESC@', str)
-               str= re.sub (r'([_^-])>', r'\1@ACCENT@', str)
-               str = re.sub ('<([^<>{}]+)>', sub_chord, str)
-
+               str = re.sub ('<<', '@STARTCHORD@', str)
+               str = re.sub ('>>', '@ENDCHORD@', str)
+               
+               str = re.sub (r'\\<', '@STARTCRESC@', str)
+               str = re.sub (r'\\>', '@STARTDECRESC@', str)
+               str = re.sub (r'([_^-])>', r'\1@ACCENT@', str)
+               str = re.sub (r'<([^<>{}]+)>', sub_chord, str)
+
+               # add dash: -[, so that [<<a b>> c d] becomes
+               #                      <<a b>>-[ c d]
+               # and gets skipped by articulation_substitute
                str = re.sub (r'\[ *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)',
-                             r'\1[',
-                             str)
+                             r'\1-[', str)
                str = re.sub (r'\\! *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)',
-                             r'\1\\!',
-                             str)
-               str = re.sub ('<([^?])', r'%s\1' % simstart, str)
-               str = re.sub ('>([^?])', r'%s\1' % simend,  str)
+                             r'\1-\\!', str)
+               
+               str = re.sub (r'<([^?])', r'%s\1' % simstart, str)
+               str = re.sub (r'>([^?])', r'%s\1' % simend,  str)
                str = re.sub ('@STARTCRESC@', r'\\<', str)
                str = re.sub ('@STARTDECRESC@', r'\\>' ,str)
-               str = re.sub (r'\\context *Voice *@STARTCHORD@', '@STARTCHORD@', str)
+               str = re.sub (r'\\context *Voice *@STARTCHORD@',
+                             '@STARTCHORD@', str)
                str = re.sub ('@STARTCHORD@', chordstart, str)
                str = re.sub ('@ENDCHORD@', chordend, str)
                str = re.sub (r'@ACCENT@', '>', str)
                return str
 
+       def text_markup (str):
+               str = re.sub (r"""([-_^]) *# *' *\( *music *(\"[^"]*\") *\)""",
+                               r"\1\\markup { \\musicglyph #\2 }", str)
+               str = re.sub (r"""([-_^]) *# *' *\( *([a-z]+) *([^()]*)\)""",
+                               r"\1\\markup { \\\2 \3 }", str)
+               str = re.sub (r"""\\mark *# *' *\( *music *(\"[^"]*\") *\)""",
+                               r"\\mark \\markup { \\musicglyph #\1 }", str)
+               str = re.sub (r"""\\mark *# *' *\( *([a-z]+) *([^()]*)\)""",
+                               r"\\mark \\markup { \\\1 \2 }", str)
+               return str      
+
        def articulation_substitute (str):
                str = re.sub (r"""([^-])\[ *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
-                             r" \1 \2[", str)
-               str = re.sub (r"""([^-])\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
+                             r"\1 \2[", str)
+               str = re.sub (r"""([^-])\\\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
+                             r"\1 \2\\)", str)
+               str = re.sub (r"""([^-\\])\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
                              r"\1 \2)", str)
                str = re.sub (r"""([^-])\\! *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
                              r"\1 \2\\!", str)
@@ -1403,15 +1436,18 @@ if 1:
                return str
        
        def conv (str):
+               str = re.sub (r"#'\(\)", "@SCM_EOL@", str)
                str =  conv_relative (str)
                str = sub_chords (str)
 
+               str = text_markup (str)
                str = articulation_substitute (str)
+               str = re.sub ("@SCM_EOL@", "#'()", str)
                
                return str
        
        conversions.append (((1,9,0), conv, """New relative mode,
-Postfix articulations, new chord syntax."""))
+Postfix articulations, new text markup syntax, new chord syntax."""))
 
 if 1:
        def conv (str):
@@ -1436,7 +1472,7 @@ if 1:
                              'ly:set-context-property!', str)
                str = re.sub ('\\\\newcontext', '\\\\new', str)
                str = re.sub ('\\\\grace[\t\n ]*([^{ ]+)',
-                             r'\\grace { \1 }', str) 
+                             r'\\grace { \1 }', str)
                str = re.sub ("\\\\grace[\t\n ]*{([^}]+)}",
                              r"""\\grace {
   \\property Voice.Stem \\override #'stroke-style = #"grace"
@@ -1446,7 +1482,7 @@ if 1:
                
                return str
        
-       conversions.append (((1,9,2), conv, """\newcontext -> \new"""))
+       conversions.append (((1,9,2), conv, """\\newcontext -> \\new"""))
 
 if 1:
        def conv (str):
@@ -1455,7 +1491,7 @@ if 1:
 
                if re.search ("context-spec-music", str):
                        sys.stderr.write ("context-spec-music takes a symbol for the context now. Update by hand.")
-                                         
+                                       
                        raise FatalConversionError()
                
                str = re.sub ('fingerHorizontalDirection *= *#(LEFT|-1)',
@@ -1466,7 +1502,7 @@ if 1:
                return str
        
        conversions.append (((1,9,3), conv,
-                            """\acciaccatura misspelling, fingerHorizontalDirection -> fingeringOrientations"""))
+                            """\\acciaccatura misspelling, fingerHorizontalDirection -> fingeringOrientations"""))
 
 
 def conv (str):
@@ -1540,9 +1576,11 @@ def conv (str):
                        '2': 'DOUBLE-SHARP',
                        }[alt]
                
-               return '(ly:make-pitch %s %s %s)' % (m.group(1), m.group (2), alt)
+               return '(ly:make-pitch %s %s %s)' % (m.group(1), m.group (2),
+                                                    alt)
        
-       str =re.sub ("\\(ly:make-pitch *([0-9-]+) *([0-9-]+) *([0-9-]+) *\\)", sub_alteration, str) 
+       str =re.sub ("\\(ly:make-pitch *([0-9-]+) *([0-9-]+) *([0-9-]+) *\\)",
+                    sub_alteration, str)
 
 
        str = re.sub ("ly:verbose", "ly:get-option 'verbose", str)
@@ -1550,7 +1588,7 @@ def conv (str):
        m= re.search ("\\\\outputproperty #([^#]+)[\t\n ]*#'([^ ]+)", str)
        if m:
                sys.stderr.write (\
-                       r"""\outputproperty found, 
+                       r"""\outputproperty found,
 Please hand-edit, using
 
   \applyoutput #(outputproperty-compatibility %s '%s <GROB PROPERTY VALUE>)
@@ -1558,11 +1596,15 @@ Please hand-edit, using
 as a substitution text.""" % (m.group (1), m.group (2)) )
                raise FatalConversionError ()
 
-       if re.search ("ly:(make-pitch|ly:pitch-alteration)", str):
+       if re.search ("ly:(make-pitch|pitch-alteration)", str) \
+              or re.search ("keySignature", str):
                sys.stderr.write (
 """The alteration field of Scheme pitches was multiplied by 2
-to support quarter tone accidentals. Please edit ly:make-pitch and
-ly:pitch-alteration calls by hand""")
+to support quarter tone accidentals. You have to edit the following constructs by hand:
+
+* calls of  ly:make-pitch and ly:pitch-alteration
+* keySignature settings made with \property
+""")
                raise FatalConversionError ()
        
        return str
@@ -1571,6 +1613,587 @@ conversions.append (((1,9,7), conv,
 remove \\outputproperty, move ly:verbose into ly:get-option'''))
 
 
+def conv (str):
+       if re.search ("dash-length",str):
+               sys.stderr.write ("""dash-length has been removed. Use dash-fraction instead.""")
+               raise FatalConversionError()
+       return str
+
+conversions.append (((1,9,8), conv, """dash-length -> dash-fraction"""))
+
+
+def conv (str):
+       def func(match):
+               return "#'font-size = #%d" % (2*string.atoi (match.group (1))) 
+               
+       str =re.sub (r"#'font-relative-size\s*=\s*#\+?([0-9-]+)", func, str)
+       str =re.sub (r"#'font-family\s*=\s*#'ancient",
+                    r"#'font-family = #'music", str)
+       
+       return str
+
+conversions.append (((2,1,1), conv, """font-relative-size -> font-size"""))
+
+def conv (str):
+       str =re.sub (r"ly:get-music-length", "ly:music-length", str)
+       return str
+
+conversions.append (((2,1,2), conv, """ly:get-music-length -> ly:music-length"""))
+
+def conv (str):
+       str =re.sub (r"\.\s+stz=", ". instr ", str)
+       return str
+
+conversions.append (((2,1,3), conv, """stanza -> instrument"""))
+
+def conv (str):
+       def func (match):
+               c = match.group (1)
+               b = match.group (2)
+               
+               if b == 't':
+                       if c == 'Score':
+                               return ''
+                       else:
+                               return r" \property %s.melismaBusyProperties \unset"  % c
+               elif b == 'f':
+                       return r"\property %s.melismaBusyProperties = #'(melismaBusy)"  % c
+               
+       str =re.sub (r"\\property ([a-zA-Z]+)\s*\.\s*automaticMelismata\s*=\s*##([ft])", func, str)
+       return str
+
+conversions.append (((2,1,4), conv, """removal of automaticMelismata; use melismaBusyProperties instead."""))
+
+
+
+def conv (str):
+       str =re.sub (r"\\translator\s+([a-zA-Z]+)", r"\\change \1", str)
+       return str
+
+conversions.append (((2,1,7), conv, """\\translator Staff -> \\change Staff"""))
+
+def conv (str):
+       str =re.sub (r"\\newaddlyrics", r"\\lyricsto", str)
+       return str
+
+conversions.append (((2,1,10), conv, """\\newaddlyrics -> \\lyricsto"""))
+
+def conv (str):
+       str = re.sub (r'\\include\s*"paper([0-9]+)(-init)?.ly"',
+                     r"#(set-staff-size \1)", str)
+
+       def sub_note (match):
+               dur = ''
+               log = string.atoi (match.group (1))
+               dots = string.atoi (match.group (2))
+               
+               if log >= 0:
+                       dur = '%d' % (1 << log)
+               else:
+                       dur = { -1 : 'breve',
+                               -2 : 'longa',
+                               -3 : 'maxima'}[log]
+
+               dur += ('.' * dots)
+               
+               return r'\note #"%s" #%s' % (dur, match.group (3))
+       
+       str = re.sub (r'\\note\s+#([0-9-]+)\s+#([0-9]+)\s+#([0-9.-]+)',
+                     sub_note, str)
+       return str
+
+conversions.append (((2,1,11), conv, """\\include "paper16.ly" -> #(set-staff-size 16)
+\\note #3 #1 #1 -> \\note #"8." #1
+"""))
+
+
+def conv (str):
+       str =re.sub (r"OttavaSpanner", r"OttavaBracket", str)
+       return str
+
+conversions.append (((2,1,12), conv, """OttavaSpanner -> OttavaBracket"""))
+
+
+def conv (str):
+       str =re.sub (r"\(set-staff-size ", r"(set-global-staff-size ", str)
+       return str
+
+conversions.append (((2,1,13), conv, """set-staff-size -> set-global-staff-size"""))
+
+def conv (str):
+       str =re.sub (r"#'style\s*=\s*#'dotted-line",
+                    r"#'dash-fraction = #0.0 ", str)
+       return str
+
+conversions.append (((2,1,14), conv, """style = dotted -> dash-fraction = 0"""))
+
+def conv (str):
+       str =re.sub (r'LyricsVoice\s*\.\s*instrument\s*=\s*("[^"]*")',
+                    r'LyricsVoice . vocalName = \1', str)
+       
+       str =re.sub (r'LyricsVoice\s*\.\s*instr\s*=\s*("[^"]*")',
+                    r'LyricsVoice . vocNam = \1', str)
+       return str
+
+conversions.append (((2,1,15), conv, """LyricsVoice . instr(ument) -> vocalName"""))
+
+def conv (str):
+       def sub_acc (m):
+               d = {
+               '4': 'doublesharp',
+               '3': 'threeqsharp',
+               '2': 'sharp',
+               '1': 'semisharp',
+               '0': 'natural',
+               '-1': 'semiflat',
+               '-2': 'flat',
+               '-3': 'threeqflat',
+               '-4': 'doubleflat'}
+               return '\\%s' %  d[m.group (1)]
+                    
+       str = re.sub (r'\\musicglyph\s*#"accidentals-([0-9-]+)"',
+                     sub_acc, str)
+       return str
+
+conversions.append (((2,1,16), conv, """\\musicglyph #"accidentals-NUM" -> \\sharp/flat/etc."""))
+
+
+def conv (str):
+
+       if re.search (r'\\partcombine', str):
+               sys.stderr.write ('Warning: \\partcombine has been changed. '
+                                 +'Check conversion manually!')
+
+               raise FatalConversionError()
+
+       # this rule doesn't really work,
+       # too lazy to figure out why.
+       str = re.sub (r'\\context\s+Voice\s*=\s*one\s*\\partcombine\s+Voice\s*\\context\s+Thread\s*=\s*one(.*)\s*'
+                     + r'\\context\s+Thread\s*=\s*two',
+                     '\\\\newpartcombine\n\\1\n', str)
+       
+       
+       return str
+
+conversions.append (((2,1,17), conv, """\\partcombine syntax change to \\newpartcombine"""))
+
+
+def conv (str):
+       str = re.sub (r'\\newpartcombine', r'\\partcombine', str)
+       str = re.sub (r'\\autochange\s+Staff', r'\\autochange ', str)
+       return str
+
+conversions.append (((2,1,18), conv, """\\newpartcombine -> \\partcombine,
+\\autochange Staff -> \\autochange
+"""))
+
+
+
+
+def conv (str):
+       str = re.sub (r'\\include "drumpitch-init.ly"','', str)
+       str = re.sub (r'\\pitchnames ','pitchnames = ', str)
+       str = re.sub (r'\\chordmodifiers ','chordmodifiers = ', str)
+       str = re.sub (r'\bdrums\b\s*=','drumContents = ', str)
+       str = re.sub (r'\\drums\b','\\drumContents ', str)
+       
+
+       if re.search ('drums->paper', str):
+               sys.stderr.write ("\nDrum notation found. Check file manually!")
+               
+       str = re.sub (r"""\\apply\s+#\(drums->paper\s+'([a-z]+)\)""",
+                     r"""\property DrumStaff.drumStyleTable = #\1-style""",
+                     str)
+
+       if re.search ('Thread', str):
+               sys.stderr.write ("\nThread found. Check file manually!\n");
+
+       str = re.sub (r"""(\\once\s*)?\\property\s+Thread\s*\.\s*NoteHead\s*"""
+                     + r"""\\(set|override)\s*#'style\s*=\s*#'harmonic"""
+                     + r"""\s+([a-z]+[,'=]*)([0-9]*\.*)"""                   
+                     ,r"""<\3\\harmonic>\4""", str)
+
+       str = re.sub (r"""\\new Thread""", """\context Voice""", str)
+       str = re.sub (r"""Thread""", """Voice""", str)
+
+       if re.search ('\bLyrics\b', str):
+               sys.stderr.write ("\nLyrics found. Check file manually!\n");
+
+       str = re.sub (r"""LyricsVoice""", r"""L@ricsVoice""", str)
+       str = re.sub (r"""\bLyrics\b""", r"""LyricsVoice""", str)
+       str = re.sub (r"""LyricsContext""", r"""LyricsVoiceContext""", str)
+       str = re.sub (r"""L@ricsVoice""", r"""LyricsVoice""",str)
+       
+       
+       return str
+
+conversions.append (((2,1,19), conv, """Drum notation changes, Removing \\chordmodifiers, \\notenames.
+Harmonic notes. Thread context removed. Lyrics context removed."""))
+
+def conv (str):
+       str = re.sub (r'nonevent-skip', 'skip-music', str)
+       return str
+
+conversions.append (((2,1,20), conv, """nonevent-skip -> skip-music""" ))
+
+def conv (str):
+       str = re.sub (r'molecule-callback', 'print-function', str)
+       str = re.sub (r'brew_molecule', 'print', str)
+       str = re.sub (r'brew-new-markup-molecule', 'Text_item::print', str)
+       str = re.sub (r'LyricsVoice', 'Lyrics', str)
+       str = re.sub (r'tupletInvisible',
+                     r"TupletBracket \\set #'transparent", str)
+#      str = re.sub (r'molecule', 'collage', str)
+#molecule -> collage
+       str = re.sub (r"\\property\s+[a-zA-Z]+\s*\.\s*[a-zA-Z]+\s*"
+                     + r"\\set\s*#'X-extent-callback\s*=\s*#Grob::preset_extent",
+                     "", str)
+
+       return str
+
+conversions.append (((2,1,21), conv, """molecule-callback -> print-function,
+brew_molecule -> print
+brew-new-markup-molecule -> Text_item::print
+LyricsVoice -> Lyrics
+tupletInvisible -> TupletBracket \set #'transparent
+Grob::preset_extent removed.
+""" ))
+
+
+def conv (str):
+       str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\=]+)\s*\\(set|override)',
+                     r"\\overrid@ \1.\2 ", str)
+       str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*=\s*',
+                     r'\\s@t \1.\2 = ', str)
+       str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*\\unset',
+                     r'\\uns@t \1.\2 ', str)
+       str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*\\revert'
+                     + r"\s*#'([-a-z0-9_]+)",
+                     r"\\rev@rt \1.\2 #'\3", str)
+       str = re.sub (r'Voice\.', '', str)
+       str = re.sub (r'Lyrics\.', '', str)
+       str = re.sub (r'ChordNames\.', '', str)
+       
+       str = re.sub ('rev@rt', 'revert',str)
+       str = re.sub ('s@t', 'set',str)
+       str = re.sub ('overrid@', 'override',str)
+
+       str = re.sub ('molecule', 'stencil', str)
+       str = re.sub ('Molecule', 'Stencil', str)
+       return str
+
+conversions.append (((2,1,22), conv, """new syntax for property settings:
+       \\set A.B = #C , \\unset A.B
+       \\override A.B #C = #D, \\revert A.B #C
+
+"""))
+
+def conv (str):
+       def subst_in_trans (match):
+               s = match.group (0)
+               s = re.sub (r'\s([a-zA-Z]+)\s*\\override',
+                             r' \\override \1', s)
+               s = re.sub (r'\s([a-zA-Z]+)\s*\\set',
+                             r' \\override \1', s)
+               s = re.sub (r'\s([a-zA-Z]+)\s*\\revert',
+                             r' \\revert \1', s)
+               return s
+       str = re.sub (r'\\(translator|with)\s*{[^}]+}',  subst_in_trans, str)
+
+       def sub_abs (m):
+               
+               context = m.group ('context')
+               d = m.groupdict ()
+               if context:
+                       context = " '%s" % context[:-1] # -1: remove . 
+               else:
+                       context = ''
+
+               d['context'] = context
+               
+               return r"""#(override-auto-beam-setting %(prop)s %(num)s %(den)s%(context)s)""" % d
+
+       str = re.sub (r"""\\override\s*(?P<context>[a-zA-Z]+\s*\.\s*)?autoBeamSettings"""
+                     +r"""\s*#(?P<prop>[^=]+)\s*=\s*#\(ly:make-moment\s+(?P<num>\d+)\s+(?P<den>\d)\s*\)""",
+                     sub_abs, str)
+       
+       return str
+       
+conversions.append (((2,1,23), conv, """Property setting syntax in \\translator{ }"""))
+def conv (str):
+       str = re.sub (r'music-list\?', 'ly:music-list?', str)
+       str = re.sub (r'\|\s*~', '~ |', str)   
+       return str
+
+conversions.append (((2,1,24), conv, """music-list? -> ly:music-list?"""))
+
+def conv (str):
+       str = re.sub (r'ly:get-spanner-bound', 'ly:spanner-get-bound', str)
+       str = re.sub (r'ly:get-extent', 'ly:grob-extent', str)
+       str = re.sub (r'ly:get-system', 'ly:grob-system', str)
+       str = re.sub (r'ly:get-original', 'ly:grob-original', str)
+       str = re.sub (r'ly:get-parent', 'ly:grob-parent', str)
+       str = re.sub (r'ly:get-broken-into', 'ly:spanner-broken-into', str)
+       str = re.sub (r'Melisma_engraver', 'Melisma_translator', str)
+       if re.search ("ly:get-paper-variable", str):
+               sys.stderr.write ('use (ly:paper-lookup (ly:grob-paper ))')
+               raise FatalConversionError()
+
+       str = re.sub (r'\\defaultAccidentals', "#(set-accidental-style 'default)", str)
+       str = re.sub (r'\\voiceAccidentals', "#(set-accidental-style 'voice)", str)
+       str = re.sub (r'\\modernAccidentals', "#(set-accidental-style 'modern)", str)
+       str = re.sub (r'\\modernCautionaries', "#(set-accidental-style 'modern-cautionary)", str)
+       str = re.sub (r'\\modernVoiceAccidental', "#(set-accidental-style 'modern-voice)", str)
+       str = re.sub (r'\\modernVoiceCautionaries', "#(set-accidental-style 'modern-voice-cautionary)", str)
+       str = re.sub (r'\\pianoAccidentals', "#(set-accidental-style 'piano)", str)
+       str = re.sub (r'\\pianoCautionaries', "#(set-accidental-style 'piano-cautionary)", str)
+       str = re.sub (r'\\forgetAccidentals', "#(set-accidental-style 'forget)", str)
+       str = re.sub (r'\\noResetKey', "#(set-accidental-style 'no-reset)", str)
+       
+       return str
+
+conversions.append (((2,1,25), conv, """Scheme grob function renaming"""))
+
+
+def conv (str):
+       str = re.sub ('ly:set-grob-property!', 'ly:grob-set-property!',str)
+       str = re.sub ('ly:set-mus-property!', 'ly:music-set-property!',str)     
+       str = re.sub ('ly:set-context-property!', 'ly:context-set-property!', str)      
+       str = re.sub ('ly:get-grob-property', 'ly:grob-property',str)
+       str = re.sub ('ly:get-mus-property', 'ly:music-property',str)
+       str = re.sub ('ly:get-context-property', 'ly:context-property',str)
+       
+       return str
+
+conversions.append (((2,1,26), conv, """More Scheme function renaming"""))
+
+def conv (str):
+       def subst (m):
+               g = string.atoi (m.group (2))
+               o = g / 12
+               g -= o * 12
+               if g <  0:
+                       g += 12
+                       o -= 1
+
+
+               lower_pitches = filter (lambda x : x <= g, [0, 2, 4, 5, 7, 9, 11, 12])
+               s = len (lower_pitches) -1 
+               a = g - lower_pitches [-1]
+
+
+               print s , lower_pitches, g, a, s 
+               str = 'cdefgab' [s]
+               str += ['eses', 'es', '', 'is', 'isis'][a + 2]
+               if o < 0:
+                       str += ',' * (-o - 1)
+               elif o >= 0:
+                       str += "'" * (o + 1)
+                       
+               return '\\transposition %s ' % str
+
+       
+       str = re.sub (r"\\set ([A-Za-z]+\s*\.\s*)?transposing\s*=\s*#([-0-9]+)",
+                     subst, str)
+       return str
+
+conversions.append (((2,1,27), conv, """property transposing -> tuning"""))
+
+def conv (str):
+       str = re.sub (r'make-music-by-name', 'make-music', str)
+       str = re.sub (r"\\override\s+.*Arpeggio\s+#.print-function\s+=\s+\\arpeggioBracket", r"\\arpeggioBracket", str)
+       return str
+
+conversions.append (((2,1,28), conv,
+                    """make-music-by-name -> make-music,
+new syntax for setting \\arpeggioBracket"""))
+
+def conv (str):
+       str = re.sub (r'\\center([^-])', '\\center-align\\1', str)
+       str = re.sub (r'\\translator', '\\context', str)
+       return str
+
+conversions.append (((2,1,29), conv,
+                    '\\center -> \\center-align, \\translator -> \\context'))
+
+
+def conv (str):
+       str = re.sub (r'\\threeq(flat|sharp)', r'\\sesqui\1', str)
+       str = re.sub (r'ly:stencil-get-extent',
+                     'ly:stencil-extent', str)
+       str = re.sub (r'ly:translator-find',
+                     'ly:context-find', str)
+       str = re.sub ('ly:unset-context-property','ly:context-unset-property',
+                     str)
+                    
+       str = re.sub (r'ly:get-mutable-properties',
+                     'ly:mutable-music-properties',str)
+       str = re.sub (r'centralCPosition',
+                     'middleCPosition',str)
+       return str
+
+conversions.append (((2,1,30), conv,
+                    '''\\threeq{flat,sharp} -> \\sesqui{flat,sharp}
+ly:get-mutable-properties -> ly:mutable-music-properties
+centralCPosition -> middleCPosition
+ly:unset-context-property -> ly:context-unset-property
+ly:translator-find -> ly:context-find
+ly:get-stencil-extent -> ly:stencil-extent
+'''))
+
+
+def conv (str):
+       str = re.sub (r'\\alias\s*"?Timing"?', '', str)
+       return str
+
+conversions.append (((2,1,31), conv,
+                    '''remove \\alias Timing'''))
+
+def conv (str):
+       str = re.sub (r"(\\set\s+)?(?P<context>(Score\.)?)breakAlignOrder\s*=\s*#'(?P<list>[^\)]+)",
+                     r"\n\\override \g<context>BreakAlignment #'break-align-orders = "
+                     + "#(make-vector 3 '\g<list>)", str)
+                     
+       return str
+
+conversions.append (((2,1,33), conv,
+                    '''breakAlignOrder -> break-align-orders.'''))
+
+def conv (str):
+       str = re.sub (r"\(set-paper-size",
+                     "(set-default-paper-size",str)
+       return str
+
+conversions.append (((2,1,34), conv,
+                    '''set-paper-size -> set-default-paper-size.'''))
+
+def conv (str):
+       str = re.sub (r"ly:mutable-music-properties",
+                     "ly:music-mutable-properties", str)
+       return str
+
+conversions.append (((2,1, 36), conv,
+                    '''ly:mutable-music-properties -> ly:music-mutable-properties'''))
+
+
+
+def conv (str):
+       return str
+
+conversions.append (((2,2, 0), conv,
+                    '''clean up version. '''))
+
+def conv (str):
+       return re.sub (r'\\apply\b', r'\\applymusic', str)
+
+conversions.append (((2, 3, 1), conv,
+                    '''\\apply -> \\applymusic'''))
+
+def conv (str):
+       str = re.sub (r'\\OrchestralScoreContext', '\\Score', str)
+       def func(m):
+               if m.group(1) not in ['RemoveEmptyStaff',
+                                     'AncientRemoveEmptyStaffContext',
+                                     'EasyNotation']:
+                       return '\\' + m.group (1)
+               else:
+                       return m.group (0)
+               
+               
+       str = re.sub (r'\\([a-zA-Z]+)Context\b', func, str)
+
+       str = re.sub ('ly:paper-lookup', 'ly:output-def-lookup', str)
+       return str
+
+conversions.append (((2, 3, 2), conv,
+                    '''\\FooContext -> \\Foo'''))
+
+def conv (str):
+       str = re.sub (r'\\notes\b', '', str)
+       
+       return str
+
+conversions.append (((2, 3, 4), conv,
+                    '''remove \\notes'''))
+
+
+
+def conv (str):
+       str = re.sub (r'\\consistsend', '\\consists', str)
+       str = re.sub (r'\\lyricsto\s+("?[a-zA-Z]+"?)(\s*\\new Lyrics\s*)?\\lyrics',
+                     r'\\lyricsto \1 \2', str)
+       return str
+
+conversions.append (((2, 3, 8), conv,
+                    '''remove \\consistsend, strip \\lyrics from \\lyricsto.'''))
+
+def conv (str):
+       str = re.sub (r'neo_mensural', 'neomensural', str)
+       str = re.sub (r'if-text-padding', 'bound-padding', str)
+       return str
+
+conversions.append (((2, 3, 9), conv,
+                    '''neo_mensural -> neomensural, if-text-padding -> bound-padding'''))
+
+
+
+def conv (str):
+       str = re.sub (r'\\addlyrics', r'\\oldaddlyrics', str)
+       str = re.sub (r'\\newlyrics', r'\\addlyrics', str)
+       return str
+
+conversions.append (((2, 3, 10), conv,
+                    '''\\addlyrics -> \\oldaddlyrics, \\newlyrics -> \\addlyrics'''))
+
+def conv (str):
+       str = re.sub (r'\\setMmRestFermata\s+(R[0-9.*/]*)',
+                     r'\1^\\fermataMarkup', str)
+       return str
+
+conversions.append (((2, 3, 11), conv,
+                    '''\\setMmRestFermata -> ^\\fermataMarkup'''))
+
+def conv (str):
+       str = re.sub (r'\\newpage', r'\\pageBreak', str)
+       str = re.sub (r'\\scriptUp', r"""{
+  \\override TextScript  #'direction = #1
+  \\override Script  #'direction = #1
+}""", str)
+       str = re.sub (r'\\scriptDown', r"""{
+  \\override TextScript  #'direction = #-1
+  \\override Script  #'direction = #-1
+}""", str)
+       str = re.sub (r'\\scriptBoth', r"""{
+  \\revert TextScript  #'direction
+  \\override Script  #'direction
+}""", str)
+       str = re.sub ('soloADue', 'printPartCombineTexts', str)
+       str = re.sub (r'\\applymusic\s*#notes-to-clusters',
+                     '\\makeClusters', str)
+       return str
+
+conversions.append (((2, 3, 12), conv,
+                    '''\\newpage -> \\pageBreak, junk \\script{up,down,both},
+soloADue -> printPartCombineTexts, #notes-to-clusters -> \\makeClusters
+'''))
+
+
+def conv_mode_experiment (str):
+       str = re.sub (r'\\chords\b', r'\\chordmode', str)
+       str = re.sub (r'\\lyrics\b', r'\\lyricmode', str)
+       str = re.sub (r'\\figures\b', r'\\figuremode', str)
+       str = re.sub (r'\\drums\b', r'\\drummode', str)
+       str = re.sub (r'\\chordmode\s*\\new ChordNames', r'\\chords', str)
+       str = re.sub (r'\\new ChordNames\s*\\chordmode', r'\\chords', str)
+       str = re.sub (r'\\new FiguredBass\s*\\figuremode', r'\\figures', str)
+       str = re.sub (r'\\figuremode\s*\new FiguredBass', r'\\figures', str)
+       str = re.sub (r'\\new DrumStaff\s*\\drummode', r'\\drums', str)
+       str = re.sub (r'\\drummode\s*\\new DrumStaff', r'\\drums', str)
+
+       return str
+
+#conversions.append (((2, 3, 9), conv,
+#                   '''fold \new FooContext \foomode into \foo.'''))
 
 ################################
 #      END OF CONVERSIONS      
@@ -1706,7 +2329,7 @@ identify ()
 for f in files:
        if f == '-':
                f = ''
-       if not os.path.isfile (f):
+       elif not os.path.isfile (f):
                continue
        try:
                do_one_file (f)