#
# 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>
def usage ():
sys.stdout.write (
- r"""Usage: %s [OPTION]... [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
+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.
- -s, --show-rules print all rules.
- -t, --to=VERSION target version
- -n, --no-version don't add new version stamp.
+ -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 show target version
+ -n, --no-version don't add new version stamp
--version print program version
-Report bugs to bugs-gnu-music@gnu.org
+Report bugs to bugs-gnu-music@gnu.org.
""" % program_name)
str = re.sub (r"linewidth *= *-[0-9.]+ *(\\mm|\\cm|\\in|\\pt)?", 'raggedright = ##t', str )
return str
- conversions.append (((1,7,16), conv, "linewidth = -1 -> raggedright = ##t"))
+ 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,"#'type -> #'style"))
+
+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"))
+
+
+
+if 1:
+
+ def sub_chord (m):
+ str = m.group(1)
+
+ origstr = '<%s>' % str
+ if re.search (r'\\\\', str):
+ return origstr
+
+ if re.search (r'\\property', str):
+ return origstr
+
+ if re.match (r'^\s*\)?\s*\\[a-zA-Z]+', str):
+ return origstr
+
+ durs = []
+ def sub_durs (m):
+ durs.append(m.group(2))
+ return m.group (1)
+
+ str = re.sub ("([a-z]+[,'!? ]*)([0-9.]+)", sub_durs, str)
+ dur_str = ''
+
+ for d in durs:
+ if dur_str == '':
+ dur_str = d
+ if dur_str <> d:
+ return '<%s>' % m.group (1)
+
+ pslur_strs = ['']
+ dyns = ['']
+ slur_strs = ['']
+
+ 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, '') \
+ + string.join (dyns, '')
+
+ return '@STARTCHORD@%s@ENDCHORD@%s%s' % (str , dur_str, suffix)
+
+
+
+
+
+ def sub_chords (str):
+ simend = '>'
+ 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 (r'\[ *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)',
+ 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)
+ str = re.sub ('@STARTCRESC@', r'\\<', str)
+ str = re.sub ('@STARTDECRESC@', r'\\>' ,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 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)
+ return str
+
+ def conv_relative(str):
+ if re.search (r"\\relative", str):
+ str= "#(ly:set-option 'old-relative)\n" + str
+
+ return str
+
+ def conv (str):
+ str = conv_relative (str)
+ str = sub_chords (str)
+
+ str = articulation_substitute (str)
+
+ return str
+
+ conversions.append (((1,9,0), conv, """New relative mode,
+Postfix articulations, new chord syntax."""))
+
+if 1:
+ def conv (str):
+ if re.search ("font-style",str):
+ sys.stderr.write ("font-style is deprecated. Please remove.")
+ raise FatalConversionError()
+
+ str = re.sub (r'-\\markup', r'@\\markup', str)
+ str = re.sub (r'-\\', r'\\', str)
+ str = re.sub (r'-\)', ')', str)
+ str = re.sub (r'-\(', '(', str)
+ str = re.sub ('-\[', '[', str)
+ str = re.sub ('-\]', ']', str)
+ str = re.sub ('-~', '~', str)
+ str = re.sub (r'@\\markup', r'-\\markup', str)
+ return str
+
+ conversions.append (((1,9,1), conv, """Remove - before articulation"""))
+if 1:
+ def conv (str):
+ str = re.sub ('ly:set-context-property',
+ 'ly:set-context-property!', str)
+ str = re.sub ('\\\\newcontext', '\\\\new', str)
+ str = re.sub ('\\\\grace[\t\n ]*([^{ ]+)',
+ r'\\grace { \1 }', str)
+ str = re.sub ("\\\\grace[\t\n ]*{([^}]+)}",
+ r"""\\grace {
+ \\property Voice.Stem \\override #'stroke-style = #"grace"
+ \1
+ \\property Voice.Stem \\revert #'stroke-style }
+""", str)
+
+ return str
+
+ conversions.append (((1,9,2), conv, """\newcontext -> \new"""))
+
+if 1:
+ def conv (str):
+ str = re.sub ('accacciatura',
+ 'acciaccatura', str)
+
+ 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)',
+ "fingeringOrientations = #'(up down left)", str)
+ str = re.sub ('fingerHorizontalDirection *= *#(RIGHT|1)',
+ "fingeringOrientations = #'(up down right)", str)
+
+ return str
+
+ conversions.append (((1,9,3), conv,
+ """\acciaccatura misspelling, fingerHorizontalDirection -> fingeringOrientations"""))
+
+
+def conv (str):
+ if re.search ('\\figures', str):
+ sys.stderr.write ("Warning: attempting automatic \\figures conversion. Check results!");
+
+
+ def figures_replace (m):
+ s = m.group (1)
+ s = re.sub ('<', '@FIGOPEN@',s)
+ s = re.sub ('>', '@FIGCLOSE@',s)
+ return '\\figures { %s }' % s
+
+ str = re.sub (r'\\figures[ \t\n]*{([^}]+)}', figures_replace, 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'<<', '@STARTCHORD@', str)
+ str = re.sub (r'>>', '@ENDCHORD@', str)
+ str = re.sub (r'>', '@ENDSIMUL@', str)
+ str = re.sub (r'<', '@STARTSIMUL@', str)
+ str = re.sub ('@STARTDECRESC@', '\\>', str)
+ str = re.sub ('@STARTCRESC@', '\\<', str)
+ str = re.sub ('@ACCENT@', '>', str)
+ str = re.sub ('@ENDCHORD@', '>', str)
+ str = re.sub ('@STARTCHORD@', '<', str)
+ str = re.sub ('@STARTSIMUL@', '<<', str)
+ str = re.sub ('@ENDSIMUL@', '>>', str)
+ str = re.sub ('@FIGOPEN@', '<', str)
+ str = re.sub ('@FIGCLOSE@', '>', str)
+
+ return str
+
+conversions.append (((1,9,4), conv, 'Swap < > and << >>'))
+
+
+def conv (str):
+ str = re.sub ('HaraKiriVerticalGroup', 'RemoveEmptyVerticalGroup', str)
+
+ return str
+
+conversions.append (((1,9,5), conv, 'HaraKiriVerticalGroup -> RemoveEmptyVerticalGroup'))
+
+def conv (str):
+ if re.search ("ly:get-font", str) :
+ sys.stderr.write (r"(ly:get-font foo ..) has been replaced by" + \
+ " (ly:paper-get-font (ly:grob-get-paper foo) .. ).\n" +\
+ "please update manually.")
+
+ raise FatalConversionError()
+
+ if re.search ("\\pitch *#", str) :
+ sys.stderr.write (r"\\pitch has been deprecated. " +\
+ " Use Scheme code to construct arbitrary note events.")
+
+ raise FatalConversionError()
+
+ return str
+
+
+conversions.append (((1,9,6), conv, 'ly:get-font deprecated.'))
+
+def conv (str):
+ def sub_alteration (m):
+ alt = m.group (3)
+ alt = {
+ '-1': 'FLAT',
+ '-2': 'DOUBLE-FLAT',
+ '0': 'NATURAL',
+ '1': 'SHARP',
+ '2': 'DOUBLE-SHARP',
+ }[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)
+ return str
+conversions.append (((1,9,7), conv, 'use symbolic constants for alterations.'))
+
+
################################
# END OF CONVERSIONS
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]
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:
else:
sys.stderr.write ("%s: skipping: `%s' " % (program_name, f))
pass
+
sys.stderr.write ('\n')