# 0.2
# - rewrite in python
-program_name = 'convert-ly'
-version = '@TOPLEVEL_VERSION@'
-
import os
import sys
import __main__
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
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-relative-size\s*=\s*#\+?([0-9-]+)", func, str)
str =re.sub (r"#'font-family\s*=\s*#'ancient",
r"#'font-family = #'music", 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
################################