3 # convert-ly.py -- Update old LilyPond input files (fix name?)
5 # source file of the GNU LilyPond music typesetter
7 # (c) 1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 # Jan Nieuwenhuizen <janneke@gnu.org>
18 program_name = sys.argv[0]
20 version = '@TOPLEVEL_VERSION@'
22 # Did we ever have \mudela-version? I doubt it.
23 # lilypond_version_re_str = '\\\\version *\"(.*)\"'
24 lilypond_version_re_str = '\\\\(mudela-)?version *\"([^"]+)\"'
25 lilypond_version_re = re.compile (lilypond_version_re_str)
30 return '%s (GNU LilyPond) %s' % (program_name, version)
33 sys.stderr.write (program_id () + '\n')
37 r"""Usage: %s [OPTIONS]... [FILE]...
38 Try to convert to newer lilypond-versions. The version number of the
39 input is guessed by default from \version directive.
42 -h, --help print this help
43 -e, --edit edit in place
44 -f, --from=VERSION start from version [default: \version found in file]
45 -s, --show-rules print all rules
46 -t, --to=VERSION end at version [default: @TOPLEVEL_VERSION@]
47 -n, --no-version don't add new version stamp
48 --version print program version
50 Report bugs to bugs-gnu-music@gnu.org.
59 sys.stdout.write (r"""%s
61 This is free software. It is covered by the GNU General Public
62 License, and you are welcome to change it and/or distribute copies of
63 it under certain conditions. invoke as `%s --warranty' for more
66 """ % (program_id (), program_name))
69 return tuple (map (string.atoi, string.split (s, '.')))
72 return string.join (map (lambda x: '%s' % x, list (t)), '.')
74 def version_cmp (t1, t2):
80 def guess_lilypond_version (filename):
81 s = open (filename).read ()
82 m = lilypond_version_re.search (s)
88 class FatalConversionError:
93 def show_rules (file):
95 if (not from_version or x[0] > from_version) \
96 and (not to_version or x[0] <= to_version):
97 file.write ('%s: %s\n' % (tup_to_str (x[0]), x[2]))
99 ############################
103 if re.search ('\\\\multi', str):
104 sys.stderr.write ('\nNot smart enough to convert \\multi')
107 conversions.append (((0,1,9), conv, '\\header { key = concat + with + operator }'))
109 if 1: # need new a namespace
111 if re.search ('\\\\octave', str):
112 sys.stderr.write ('\nNot smart enough to convert \\octave')
113 # raise FatalConversionError()
117 conversions.append ((
118 ((0,1,19), conv, 'deprecated \\octave; can\'t convert automatically')))
121 if 1: # need new a namespace
123 str = re.sub ('\\\\textstyle([^;]+);',
124 '\\\\property Lyrics . textstyle = \\1', str)
125 # harmful to current .lys
126 # str = re.sub ('\\\\key([^;]+);', '\\\\accidentals \\1;', str)
130 conversions.append ((
131 ((0,1,20), conv, 'deprecated \\textstyle, new \\key syntax')))
136 str = re.sub ('\\\\musical_pitch', '\\\\musicalpitch',str)
137 str = re.sub ('\\\\meter', '\\\\time',str)
141 conversions.append ((
142 ((0,1,21), conv, '\\musical_pitch -> \\musicalpitch, '+
143 '\\meter -> \\time')))
149 conversions.append ((
150 ((1,0,0), conv, '0.1.21 -> 1.0.0 ')))
155 str = re.sub ('\\\\accidentals', '\\\\keysignature',str)
156 str = re.sub ('specialaccidentals *= *1', 'keyoctaviation = 0',str)
157 str = re.sub ('specialaccidentals *= *0', 'keyoctaviation = 1',str)
161 conversions.append ((
162 ((1,0,1), conv, '\\accidentals -> \\keysignature, ' +
163 'specialaccidentals -> keyoctaviation')))
167 if re.search ('\\\\header', str):
168 sys.stderr.write ('\nNot smart enough to convert to new \\header format')
171 conversions.append (((1,0,2), conv, '\\header { key = concat + with + operator }'))
175 str = re.sub ('\\\\melodic([^a-zA-Z])', '\\\\notes\\1',str)
178 conversions.append (((1,0,3), conv, '\\melodic -> \\notes'))
182 str = re.sub ('default_paper *=', '',str)
183 str = re.sub ('default_midi *=', '',str)
186 conversions.append (((1,0,4), conv, 'default_{paper,midi}'))
190 str = re.sub ('ChoireStaff', 'ChoirStaff',str)
191 str = re.sub ('\\\\output', 'output = ',str)
195 conversions.append (((1,0,5), conv, 'ChoireStaff -> ChoirStaff'))
199 if re.search ('[a-zA-Z]+ = *\\translator',str):
200 sys.stderr.write ('\nNot smart enough to change \\translator syntax')
201 # raise FatalConversionError()
204 conversions.append (((1,0,6), conv, 'foo = \\translator {\\type .. } ->\\translator {\\type ..; foo; }'))
209 str = re.sub ('\\\\lyrics*', '\\\\lyrics',str)
213 conversions.append (((1,0,7), conv, '\\lyric -> \\lyrics'))
217 str = re.sub ('\\\\\\[/3+', '\\\\times 2/3 { ',str)
218 str = re.sub ('\\[/3+', '\\\\times 2/3 { [',str)
219 str = re.sub ('\\\\\\[([0-9/]+)', '\\\\times \\1 {',str)
220 str = re.sub ('\\[([0-9/]+)', '\\\\times \\1 { [',str)
221 str = re.sub ('\\\\\\]([0-9/]+)', '}', str)
222 str = re.sub ('\\\\\\]', '}',str)
223 str = re.sub ('\\]([0-9/]+)', '] }', str)
226 conversions.append (((1,0,10), conv, '[2/3 ]1/1 -> \\times 2/3 '))
231 conversions.append (((1,0,12), conv, 'Chord syntax stuff'))
238 str = re.sub ('<([^>~]+)~([^>]*)>','<\\1 \\2> ~', str)
242 conversions.append (((1,0,13), conv, '<a ~ b> c -> <a b> ~ c'))
246 str = re.sub ('<\\[','[<', str)
247 str = re.sub ('\\]>','>]', str)
251 conversions.append (((1,0,14), conv, '<[a b> <a b]>c -> [<a b> <a b>]'))
256 str = re.sub ('\\\\type([^\n]*engraver)','\\\\TYPE\\1', str)
257 str = re.sub ('\\\\type([^\n]*performer)','\\\\TYPE\\1', str)
258 str = re.sub ('\\\\type','\\\\context', str)
259 str = re.sub ('\\\\TYPE','\\\\type', str)
260 str = re.sub ('textstyle','textStyle', str)
264 conversions.append (((1,0,16), conv, '\\type -> \\context, textstyle -> textStyle'))
269 if re.search ('\\\\repeat',str):
270 sys.stderr.write ('\nNot smart enough to convert \\repeat')
271 # raise FatalConversionError()
274 conversions.append (((1,0,18), conv,
275 '\\repeat NUM Music Alternative -> \\repeat FOLDSTR Music Alternative'))
279 str = re.sub ('SkipBars','skipBars', str)
280 str = re.sub ('fontsize','fontSize', str)
281 str = re.sub ('midi_instrument','midiInstrument', str)
285 conversions.append (((1,0,19), conv,
286 'fontsize -> fontSize, midi_instrument -> midiInstrument, SkipBars -> skipBars'))
291 str = re.sub ('tieydirection','tieVerticalDirection', str)
292 str = re.sub ('slurydirection','slurVerticalDirection', str)
293 str = re.sub ('ydirection','verticalDirection', str)
297 conversions.append (((1,0,20), conv,
298 '{,tie,slur}ydirection -> {v,tieV,slurV}erticalDirection'))
303 str = re.sub ('hshift','horizontalNoteShift', str)
307 conversions.append (((1,0,21), conv,
308 'hshift -> horizontalNoteShift'))
313 str = re.sub ('\\\\grouping[^;]*;','', str)
317 conversions.append (((1,1,52), conv,
318 'deprecate \\grouping'))
323 str = re.sub ('\\\\wheel','\\\\coda', str)
327 conversions.append (((1,1,55), conv,
328 '\\wheel -> \\coda'))
332 str = re.sub ('keyoctaviation','keyOctaviation', str)
333 str = re.sub ('slurdash','slurDash', str)
337 conversions.append (((1,1,65), conv,
338 'slurdash -> slurDash, keyoctaviation -> keyOctaviation'))
342 str = re.sub ('\\\\repeat *\"?semi\"?','\\\\repeat "volta"', str)
346 conversions.append (((1,1,66), conv,
352 str = re.sub ('\"?beamAuto\"? *= *\"?0?\"?','noAutoBeaming = "1"', str)
356 conversions.append (((1,1,67), conv,
357 'beamAuto -> noAutoBeaming'))
361 str = re.sub ('automaticMelismas', 'automaticMelismata', str)
365 conversions.append (((1,2,0), conv,
366 'automaticMelismas -> automaticMelismata'))
370 str = re.sub ('dynamicDir\\b', 'dynamicDirection', str)
374 conversions.append (((1,2,1), conv,
375 'dynamicDir -> dynamicDirection'))
379 str = re.sub ('\\\\cadenza *0 *;', '\\\\cadenzaOff', str)
380 str = re.sub ('\\\\cadenza *1 *;', '\\\\cadenzaOn', str)
384 conversions.append (((1,3,4), conv,
385 '\\cadenza -> \\cadenza{On|Off}'))
389 str = re.sub ('"?beamAuto([^"=]+)"? *= *"([0-9]+)/([0-9]+)" *;*',
390 'beamAuto\\1 = #(make-moment \\2 \\3)',
394 conversions.append (((1,3,5), conv, 'beamAuto moment properties'))
398 str = re.sub ('stemStyle',
403 conversions.append (((1,3,17), conv, 'stemStyle -> flagStyle'))
407 str = re.sub ('staffLineLeading',
412 conversions.append (((1,3,18), conv, 'staffLineLeading -> staffSpace'))
417 if re.search ('\\\\repetitions',str):
418 sys.stderr.write ('\nNot smart enough to convert \\repetitions')
419 # raise FatalConversionError()
422 conversions.append (((1,3,23), conv,
423 '\\\\repetitions feature dropped'))
428 str = re.sub ('textEmptyDimension *= *##t',
429 'textNonEmpty = ##f',
431 str = re.sub ('textEmptyDimension *= *##f',
432 'textNonEmpty = ##t',
436 conversions.append (((1,3,35), conv, 'textEmptyDimension -> textNonEmpty'))
440 str = re.sub ("([a-z]+)[ \t]*=[ \t]*\\\\musicalpitch *{([- 0-9]+)} *\n",
441 "(\\1 . (\\2))\n", str)
442 str = re.sub ("\\\\musicalpitch *{([0-9 -]+)}",
443 "\\\\musicalpitch #'(\\1)", str)
444 if re.search ('\\\\notenames',str):
445 sys.stderr.write ('\nNot smart enough to convert to new \\notenames format')
448 conversions.append (((1,3,38), conv, '\musicalpitch { a b c } -> #\'(a b c)'))
453 return '\\key %s;' % string.lower (match.group (1))
455 str = re.sub ("\\\\key ([^;]+);", replace, str)
458 conversions.append (((1,3,39), conv, '\\key A ; ->\\key a;'))
462 if re.search ('\\[:',str):
463 sys.stderr.write ('\nNot smart enough to convert to new tremolo format')
466 conversions.append (((1,3,41), conv,
467 '[:16 c4 d4 ] -> \\repeat "tremolo" 2 { c16 d16 }'))
471 str = re.sub ('Staff_margin_engraver' , 'Instrument_name_engraver', str)
474 conversions.append (((1,3,42), conv,
475 'Staff_margin_engraver deprecated, use Instrument_name_engraver'))
479 str = re.sub ('note[hH]eadStyle\\s*=\\s*"?(\\w+)"?' , "noteHeadStyle = #'\\1", str)
482 conversions.append (((1,3,49), conv,
483 'noteHeadStyle value: string -> symbol'))
487 if re.search ('\\\\keysignature', str):
488 sys.stderr.write ('\nNot smart enough to convert to new tremolo format')
492 conversions.append (((1,3,58), conv,
493 'noteHeadStyle value: string -> symbol'))
497 str = re.sub (r"""\\key *([a-z]+) *;""", r"""\\key \1 \major;""",str);
499 conversions.append (((1,3,59), conv,
500 '\key X ; -> \key X major; '))
504 str = re.sub (r'latexheaders *= *"\\\\input ',
508 conversions.append (((1,3,68), conv, 'latexheaders = "\\input global" -> latexheaders = "global"'))
513 # TODO: lots of other syntax change should be done here as well
516 str = re.sub ('basicCollisionProperties', 'NoteCollision', str)
517 str = re.sub ('basicVoltaSpannerProperties' , "VoltaBracket", str)
518 str = re.sub ('basicKeyProperties' , "KeySignature", str)
520 str = re.sub ('basicClefItemProperties' ,"Clef", str)
523 str = re.sub ('basicLocalKeyProperties' ,"Accidentals", str)
524 str = re.sub ('basicMarkProperties' ,"Accidentals", str)
525 str = re.sub ('basic([A-Za-z_]+)Properties', '\\1', str)
527 str = re.sub ('Repeat_engraver' ,'Volta_engraver', str)
530 conversions.append (((1,3,92), conv, 'basicXXXProperties -> XXX, Repeat_engraver -> Volta_engraver'))
534 # Ugh, but meaning of \stemup changed too
535 # maybe we should do \stemup -> \stemUp\slurUp\tieUp ?
536 str = re.sub ('\\\\stemup', '\\\\stemUp', str)
537 str = re.sub ('\\\\stemdown', '\\\\stemDown', str)
538 str = re.sub ('\\\\stemboth', '\\\\stemBoth', str)
540 str = re.sub ('\\\\slurup', '\\\\slurUp', str)
541 str = re.sub ('\\\\slurboth', '\\\\slurBoth', str)
542 str = re.sub ('\\\\slurdown', '\\\\slurDown', str)
543 str = re.sub ('\\\\slurdotted', '\\\\slurDotted', str)
544 str = re.sub ('\\\\slurnormal', '\\\\slurNoDots', str)
546 str = re.sub ('\\\\shiftoff', '\\\\shiftOff', str)
547 str = re.sub ('\\\\shifton', '\\\\shiftOn', str)
548 str = re.sub ('\\\\shiftonn', '\\\\shiftOnn', str)
549 str = re.sub ('\\\\shiftonnn', '\\\\shiftOnnn', str)
551 str = re.sub ('\\\\onevoice', '\\\\oneVoice', str)
552 str = re.sub ('\\\\voiceone', '\\\\voiceOne', str)
553 str = re.sub ('\\\\voicetwo', '\\\\voiceTwo', str)
554 str = re.sub ('\\\\voicethree', '\\\\voiceThree', str)
555 str = re.sub ('\\\\voicefour', '\\\\voiceFour', str)
557 # I don't know exactly when these happened...
558 # ugh, we loose context setting here...
559 str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\stemUp\\\\slurUp\\\\tieUp', str)
560 str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\stemDown\\\\slurDown\\\\tieDown', str)
561 str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\stemBoth\\\\slurBoth\\\\tieBoth', str)
563 str = re.sub ('verticalDirection[^=]*= *#?"?(1|(\\\\up))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #1', str)
564 str = re.sub ('verticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #-1', str)
565 str = re.sub ('verticalDirection[^=]*= *#?"?(0|(\\\\center))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #0', str)
567 str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\\\1Up', str)
568 str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\\\1Down', str)
569 str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\\\1Both', str)
571 # (lacks capitalisation slur -> Slur)
572 str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\1 \\\\override #\'direction = #1', str)
573 str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\1 \\override #\'direction = #-1', str)
574 str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\1 \\\\override #\'direction = #0', str)
577 str = re.sub ('\\\\property *[^ .]*[.]?dynamicDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\dynamicUp', str)
578 str = re.sub ('\\\\property *[^ .]*[.]?dyn[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\dynamicDown', str)
579 str = re.sub ('\\\\property *[^ .]*[.]?dyn[^=]*= *#?"?(0|(\\\\center))"?', '\\\\dynamicBoth', str)
581 str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)Dash[^=]*= *#?"?(0|(""))"?', '\\\\\\1NoDots', str)
582 str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)Dash[^=]*= *#?"?([1-9]+)"?', '\\\\\\1Dotted', str)
584 str = re.sub ('\\\\property *[^ .]*[.]?noAutoBeaming[^=]*= *#?"?(0|(""))"?', '\\\\autoBeamOn', str)
585 str = re.sub ('\\\\property *[^ .]*[.]?noAutoBeaming[^=]*= *#?"?([1-9]+)"?', '\\\\autoBeamOff', str)
591 conversions.append (((1,3,93), conv,
592 'property definiton case (eg. onevoice -> oneVoice)'))
597 str = re.sub ('ChordNames*', 'ChordNames', str)
598 if re.search ('\\\\textscript "[^"]* *"[^"]*"', str):
599 sys.stderr.write ('\nNot smart enough to convert to new \\textscript markup text')
601 str = re.sub ('\\textscript +("[^"]*")', '\\textscript #\\1', str)
605 conversions.append (((1,3,97), conv, 'ChordName -> ChordNames'))
608 # TODO: add lots of these
612 str = re.sub ('\\\\property *"?Voice"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Voice.TextScript \\\\set #\'font-style = #\'\\1', str)
613 str = re.sub ('\\\\property *"?Lyrics"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Lyrics.LyricText \\\\set #\'font-style = #\'\\1', str)
615 str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?timeSignatureStyle"? *= *"([^"]*)"', '\\\\property \\1.TimeSignature \\\\override #\'style = #\'\\2', str)
617 str = re.sub ('"?timeSignatureStyle"? *= *#?""', 'TimeSignature \\\\override #\'style = ##f', str)
619 str = re.sub ('"?timeSignatureStyle"? *= *#?"([^"]*)"', 'TimeSignature \\\\override #\'style = #\'\\1', str)
621 str = re.sub ('#\'style *= #*"([^"])"', '#\'style = #\'\\1', str)
623 str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?horizontalNoteShift"? *= *"?#?([-0-9]+)"?', '\\\\property \\1.NoteColumn \\\\override #\'horizontal-shift = #\\2', str)
626 str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *""', '\\\\property \\1.Stem \\\\override #\'flag-style = ##f', str)
628 str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *"([^"]*)"', '\\\\property \\1.Stem \\\\override #\'flag-style = #\'\\2', str)
631 conversions.append (((1,3,98), conv, 'CONTEXT.textStyle -> GROB.#font-style '))
635 str = re.sub ('"?beamAutoEnd_([0-9]*)"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(end 1 \\1 * *) = \\2', str)
636 str = re.sub ('"?beamAutoBegin_([0-9]*)"? *= *(#\\([^)]*\))', 'autoBeamSettings \\push #\'(begin 1 \\1 * *) = \\2', str)
637 str = re.sub ('"?beamAutoEnd"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(end * * * *) = \\1', str)
638 str = re.sub ('"?beamAutoBegin"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(begin * * * *) = \\1', str)
643 conversions.append (((1,3,102), conv, 'beamAutoEnd -> autoBeamSettings \\push (end * * * *)'))
648 str = re.sub ('\\\\push', '\\\\override', str)
649 str = re.sub ('\\\\pop', '\\\\revert', str)
653 conversions.append (((1,3,111), conv, '\\push -> \\override, \\pop -> \\revert'))
657 str = re.sub ('LyricVoice', 'LyricsVoice', str)
659 str = re.sub ('Chord[Nn]ames*.Chord[Nn]ames*', 'ChordNames.ChordName', str)
660 str = re.sub ('Chord[Nn]ames([ \t\n]+\\\\override)', 'ChordName\\1', str)
663 conversions.append (((1,3,113), conv, 'LyricVoice -> LyricsVoice'))
665 def regularize_id (str):
672 elif x in string.digits:
673 x = chr(ord (x) - ord ('0') +ord ('A'))
674 elif x not in string.letters:
676 elif x in string.lowercase and lastx == '_':
685 def regularize_dollar_reference (match):
686 return regularize_id (match.group (1))
687 def regularize_assignment (match):
688 return '\n' + regularize_id (match.group (1)) + ' = '
689 str = re.sub ('\$([^\t\n ]+)', regularize_dollar_reference, str)
690 str = re.sub ('\n([^ \t\n]+)[ \t]*= *', regularize_assignment, str)
693 conversions.append (((1,3,117), conv, 'identifier names: $!foo_bar_123 -> xfooBarABC'))
698 def regularize_paper (match):
699 return regularize_id (match.group (1))
701 str = re.sub ('(paper_[a-z]+)', regularize_paper, str)
702 str = re.sub ('sustainup', 'sustainUp', str)
703 str = re.sub ('nobreak', 'noBreak', str)
704 str = re.sub ('sustaindown', 'sustainDown', str)
705 str = re.sub ('sostenutoup', 'sostenutoUp', str)
706 str = re.sub ('sostenutodown', 'sostenutoDown', str)
707 str = re.sub ('unachorda', 'unaChorda', str)
708 str = re.sub ('trechorde', 'treChorde', str)
712 conversions.append (((1,3,120), conv, 'paper_xxx -> paperXxxx, pedalup -> pedalUp.'))
716 str = re.sub ('drarnChords', 'chordChanges', str)
717 str = re.sub ('\\musicalpitch', '\\pitch', str)
720 conversions.append (((1,3,122), conv, 'drarnChords -> chordChanges, \\musicalpitch -> \\pitch'))
724 str = re.sub ('ly-([sg])et-elt-property', 'ly-\\1et-grob-property', str)
727 conversions.append (((1,3,136), conv, 'ly-X-elt-property -> ly-X-grob-property'))
731 str = re.sub ('point-and-click +#t', 'point-and-click line-column-location', str)
734 conversions.append (((1,3,138), conv, 'point-and-click argument changed to procedure.'))
738 str = re.sub ('followThread', 'followVoice', str)
739 str = re.sub ('Thread.FollowThread', 'Voice.VoiceFollower', str)
740 str = re.sub ('FollowThread', 'VoiceFollower', str)
743 conversions.append (((1,3,138), conv, 'followThread -> followVoice.'))
747 str = re.sub ('font-point-size', 'font-design-size', str)
750 conversions.append (((1,3,139), conv, 'font-point-size -> font-design-size.'))
754 str = re.sub ('([a-zA-Z]*)NoDots', '\\1Solid', str)
757 conversions.append (((1,3,141), conv, 'xNoDots -> xSolid'))
761 str = re.sub ('([Cc])hord([ea])', '\\1ord\\2', str)
764 conversions.append (((1,3,144), conv, 'Chorda -> Corda'))
769 str = re.sub ('([A-Za-z]+)MinimumVerticalExtent', 'MinimumV@rticalExtent', str)
770 str = re.sub ('([A-Za-z]+)ExtraVerticalExtent', 'ExtraV@rticalExtent', str)
771 str = re.sub ('([A-Za-z]+)VerticalExtent', 'VerticalExtent', str)
772 str = re.sub ('ExtraV@rticalExtent', 'ExtraVerticalExtent', str)
773 str = re.sub ('MinimumV@rticalExtent', 'MinimumVerticalExtent', str)
776 conversions.append (((1,3,145), conv,
777 'ContextNameXxxxVerticalExtent -> XxxxVerticalExtent'))
781 str = re.sub ('\\\\key[ \t]*;', '\\key \\default;', str)
782 str = re.sub ('\\\\mark[ \t]*;', '\\mark \\default;', str)
784 # Make sure groups of more than one ; have space before
785 # them, so that non of them gets removed by next rule
786 str = re.sub ("([^ \n\t;]);(;+)", "\\1 ;\\2", str)
788 # Only remove ; that are not after spaces, # or ;
789 # Otherwise we interfere with Scheme comments,
790 # which is badbadbad.
791 str = re.sub ("([^ \t;#]);", "\\1", str)
794 conversions.append (((1,3,146), conv, 'semicolons removed'))
798 str = re.sub ('default-neutral-direction', 'neutral-direction',str)
800 conversions.append (((1,3,147), conv, 'default-neutral-direction -> neutral-direction'))
804 str = re.sub ('\(align', '(axis', str)
805 str = re.sub ('\(rows', '(columns', str)
807 conversions.append (((1,3,148), conv, '"(align" -> "(axis", "(rows" -> "(columns"'))
812 str = re.sub ('SystemStartDelimiter', 'systemStartDelimiter', str)
814 conversions.append (((1,5,33), conv, 'SystemStartDelimiter -> systemStartDelimiter'))
818 str = re.sub ('arithmetic-multiplier', 'spacing-increment', str)
819 str = re.sub ('arithmetic-basicspace', 'shortest-duration-space', str)
822 conversions.append (((1,5,38), conv, 'SystemStartDelimiter -> systemStartDelimiter'))
830 "Instrument_name": "instrument-name",
831 "Left_edge_item": "left-edge",
832 "Span_bar": "span-bar",
833 "Breathing_sign": "breathing-sign",
834 "Staff_bar": "staff-bar",
836 "Key_item": "key-signature",
837 "Time_signature": "time-signature",
840 props = match.group (1)
841 for (k,v) in break_dict.items():
842 props = re.sub (k, v, props)
843 return "breakAlignOrder = #'(%s)" % props
845 str = re.sub ("breakAlignOrder *= *#'\\(([a-z_\n\tA-Z ]+)\\)",
850 conversions.append (((1,5,40), conv, 'breakAlignOrder property names'))
855 str = re.sub ('noAutoBeaming *= *##f', 'autoBeaming = ##t', str)
856 str = re.sub ('noAutoBeaming *= *##t', 'autoBeaming = ##f', str)
859 conversions.append (((1,5,49), conv, 'noAutoBeaming -> autoBeaming'))
863 str = re.sub ('tuplet-bracket-visibility', 'bracket-visibility', str)
864 str = re.sub ('tuplet-number-visibility', 'number-visibility', str)
867 conversions.append (((1,5,52), conv, 'tuplet-X-visibility -> X-visibility'))
871 str = re.sub ('Pitch::transpose', 'ly-transpose-pitch', str)
875 conversions.append (((1,5,56), conv, 'Pitch::transpose -> ly-transpose-pitch'))
879 str = re.sub ('textNonEmpty *= *##t', "TextScript \\set #'no-spacing-rods = ##f", str)
880 str = re.sub ('textNonEmpty *= *##f', "TextScript \\set #'no-spacing-rods = ##t", str)
883 conversions.append (((1,5,58), conv, 'deprecate textNonEmpty'))
888 str = re.sub ('MinimumVerticalExtent', 'minimumV@rticalExtent', str)
889 str = re.sub ('minimumVerticalExtent', 'minimumV@rticalExtent', str)
890 str = re.sub ('ExtraVerticalExtent', 'extraV@rticalExtent', str)
891 str = re.sub ('extraVerticalExtent', 'extraV@rticalExtent', str)
892 str = re.sub ('VerticalExtent', 'verticalExtent', str)
893 str = re.sub ('extraV@rticalExtent', 'extraVerticalExtent', str)
894 str = re.sub ('minimumV@rticalExtent', 'minimumVerticalExtent', str)
897 conversions.append (((1,5,59), conv,
898 'XxxxVerticalExtent -> xxxVerticalExtent'))
902 str = re.sub ('visibility-lambda', 'break-visibility', str)
905 conversions.append (((1,5,62), conv,
906 'visibility-lambda -> break-visibility'))
911 if re.search (r'\addlyrics',str) \
912 and re.search ('automaticMelismata', str) == None:
913 sys.stderr.write ('automaticMelismata is turned on by default since 1.5.67. Please fix this by hand.')
914 raise FatalConversionError()
917 conversions.append (((1,5,67), conv,
918 'automaticMelismata turned on by default'))
922 str = re.sub ('ly-set-grob-property([^!])', 'ly-set-grob-property!\1', str)
923 str = re.sub ('ly-set-mus-property([^!])', 'ly-set-mus-property!\1', str)
926 conversions.append (((1,5,68), conv, 'ly-set-X-property -> ly-set-X-property!'))
930 str = re.sub ('extent-X', 'X-extent', str)
931 str = re.sub ('extent-Y', 'Y-extent', str)
934 conversions.append (((1,5,71), conv, 'extent-[XY] -> [XY]-extent'))
939 str = re.sub ("""#\(set! +point-and-click +line-column-location\)""",
940 """#(set-point-and-click! \'line-column)""", str)
941 str = re.sub ("""#\(set![ \t]+point-and-click +line-location\)""",
942 '#(set-point-and-click! \'line)', str)
943 str = re.sub ('#\(set! +point-and-click +#f\)',
944 '#(set-point-and-click! \'none)', str)
947 conversions.append (((1,5,72), conv, 'set! point-and-click -> set-point-and-click!'))
952 str = re.sub ('flag-style', 'stroke-style', str)
953 str = re.sub (r"""Stem([ ]+)\\override #'style""", r"""Stem \\override #'flag-style""", str);
954 str = re.sub (r"""Stem([ ]+)\\set([ ]+)#'style""", r"""Stem \\set #'flag-style""", str);
957 conversions.append (((1,6,5), conv, 'Stems: flag-style -> stroke-style; style -> flag-style'))
961 def subst_req_name (match):
962 return "(make-music-by-name \'%sEvent)" % regularize_id (match.group(1))
965 str = re.sub ('\\(ly-make-music *\"([A-Z][a-z_]+)_req\"\\)', subst_req_name, str)
966 str = re.sub ('Request_chord', 'EventChord', str)
969 conversions.append (((1,7,1), conv, 'ly-make-music foo_bar_req -> make-music-by-name FooBarEvent'))
974 "text" : 'TextSpanEvent',
975 "decrescendo" : 'DecrescendoEvent',
976 "crescendo" : 'CrescendoEvent',
977 "Sustain" : 'SustainPedalEvent',
978 "slur" : 'SlurEvent',
979 "UnaCorda" : 'UnaCordaEvent',
980 "Sostenuto" : 'SostenutoEvent',
982 def subst_ev_name (match):
984 if re.search ('start', match.group(1)):
987 mtype = spanner_subst[match.group(2)]
988 return "(make-span-event '%s %s)" % (mtype , stype)
990 def subst_definition_ev_name(match):
991 return ' = #%s' % subst_ev_name (match)
992 def subst_inline_ev_name (match):
993 s = subst_ev_name (match)
994 return '#(ly-export %s)' % s
995 def subst_csp_definition (match):
996 return ' = #(make-event-chord (list %s))' % subst_ev_name (match)
997 def subst_csp_inline (match):
998 return '#(ly-export (make-event-chord (list %s)))' % subst_ev_name (match)
1001 str = re.sub (r' *= *\\spanrequest *([^ ]+) *"([^"]+)"', subst_definition_ev_name, str)
1002 str = re.sub (r'\\spanrequest *([^ ]+) *"([^"]+)"', subst_inline_ev_name, str)
1003 str = re.sub (r' *= *\\commandspanrequest *([^ ]+) *"([^"]+)"', subst_csp_definition, str)
1004 str = re.sub (r'\\commandspanrequest *([^ ]+) *"([^"]+)"', subst_csp_inline, str)
1005 str = re.sub (r'ly-id ', 'ly-import ', str)
1007 str = re.sub (r' *= *\\script "([^"]+)"', ' = #(make-articulation "\\1")', str)
1008 str = re.sub (r'\\script "([^"]+)"', '#(ly-export (make-articulation "\\1"))', str)
1011 conversions.append (((1,7,2), conv, '\\spanrequest -> #(make-span-event .. ), \script -> #(make-articulation .. )'))
1015 str = re.sub (r'\(ly-', '(ly:', str)
1025 'music-duration-length',
1027 'duration-dotcount',
1030 'transpose-key-alist',
1034 'set-point-and-click!',
1043 'music-duration-compress',
1044 'set-point-and-click!'
1047 origre = r'\b(%s)' % string.join (changed, '|')
1049 str = re.sub (origre, r'ly:\1',str)
1050 str = re.sub ('set-point-and-click!', 'set-point-and-click', str)
1054 conversions.append (((1,7,3), conv, 'ly- -> ly:'))
1058 if re.search ('new-chords-done',str):
1061 str = re.sub (r'<<', '< <', str)
1062 str = re.sub (r'>>', '> >', str)
1065 conversions.append (((1,7,4), conv, '<< >> -> < < > >'))
1069 str = re.sub (r"\\transpose", r"\\transpose c'", str)
1070 str = re.sub (r"\\transpose c' *([a-z]+)'", r"\\transpose c \1", str)
1072 conversions.append (((1,7,5), conv, '\\transpose TO -> \\transpose FROM TO'))
1090 origstr = string.join (kws, '|')
1091 str = re.sub (r'([^_^-])\\(%s)\b' % origstr, r'\1-\\\2', str)
1093 conversions.append (((1,7,6), conv, 'note\\script -> note-\script'))
1098 str = re.sub (r"\\property *ChordNames *\. *ChordName *\\(set|override) *#'style *= *#('[a-z]+)",
1099 r"#(set-chord-name-style \2)", str)
1100 str = re.sub (r"\\property *ChordNames *\. *ChordName *\\revert *#'style",
1103 conversions.append (((1,7,10), conv, "\property ChordName #'style -> #(set-chord-name-style 'style)"))
1109 str = re.sub (r"ly:transpose-pitch", "ly:pitch-transpose", str)
1112 conversions.append (((1,7,11), conv, "transpose-pitch -> pitch-transpose"))
1116 str = re.sub (r"ly:get-molecule-extent", "ly:molecule-get-extent", str)
1117 str = re.sub (r"ly:set-molecule-extent!", "ly:molecule-set-extent!", str)
1118 str = re.sub (r"ly:add-molecule", "ly:molecule-add", str)
1119 str = re.sub (r"ly:combine-molecule-at-edge", "ly:molecule-combine-at-edge", str)
1120 str = re.sub (r"ly:align-to!", "ly:molecule-align-to!", str)
1124 conversions.append (((1,7,13), conv, "ly:XX-molecule-YY -> ly:molecule-XX-YY"))
1128 str = re.sub (r"linewidth *= *-[0-9.]+ *(\\mm|\\cm|\\in|\\pt)?", 'raggedright = ##t', str )
1131 conversions.append (((1,7,15), conv, "linewidth = -1 -> raggedright = ##t"))
1135 str = re.sub ("divisiomaior",
1136 "divisioMaior", str)
1137 str = re.sub ("divisiominima",
1138 "divisioMinima", str)
1139 str = re.sub ("divisiomaxima",
1140 "divisioMaxima", str)
1143 conversions.append (((1,7,16), conv, "divisiomaior -> divisioMaior"))
1147 str = re.sub ("Skip_req_swallow_translator",
1148 "Skip_event_swallow_translator", str)
1151 conversions.append (((1,7,17), conv, "Skip_req -> Skip_event"))
1155 str = re.sub ("groupOpen",
1157 str = re.sub ("groupClose",
1159 str = re.sub ("#'outer",
1160 "#'enclose-bounds", str)
1164 conversions.append (((1,7,18), conv,
1165 """groupOpen/Close -> start/stopGroup,
1166 #'outer -> #'enclose-bounds
1171 if re.search( r'\\GraceContext', str):
1172 sys.stderr.write ("GraceContext has been removed")
1173 sys.stderr.write ("please use #(add-to-grace-init .. )")
1174 raise FatalConversionError()
1176 str = re.sub ('HaraKiriStaffContext', 'RemoveEmptyStaffContext', str)
1179 conversions.append (((1,7,19), conv,"remove GraceContext"))
1186 r"(set|override|revert) *#'type",
1191 conversions.append (((1,7,22), conv,"#'type -> #'style"))
1196 "barNonAuto *= *##t",
1197 "automaticBars = ##f",
1200 "barNonAuto *= *##f",
1201 "automaticBars = ##t",
1205 conversions.append (((1,7,23), conv,"barNonAuto -> automaticBars"))
1210 if re.search( r'-(start|stop)Cluster', str):
1211 sys.stderr.write ("""Cluster syntax has been changed.
1212 Please refer to the manual for details, and convert manually.
1215 raise FatalConversionError()
1219 conversions.append (((1,7,24), conv,"cluster syntax"))
1223 str = re.sub (r"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\(override|set) *#'pedal-type *",
1224 r"\property Staff.pedal\1Style ", str)
1225 str = re.sub (r"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\revert *#'pedal-type", '', str)
1228 conversions.append (((1,7,28), conv,"new Pedal style syntax"))
1237 origstr = '<%s>' % str
1238 if re.search (r'\\\\', str):
1241 if re.search (r'\\property', str):
1244 if re.match (r'^\s*\)?\s*\\[a-zA-Z]+', str):
1248 def sub_durs (m, durs = durs):
1249 durs.append(m.group(2))
1252 str = re.sub (r"([a-z]+[,'!? ]*)([0-9]+\.*)", sub_durs, str)
1259 return '<%s>' % m.group (1)
1266 while last_str <> str:
1269 def sub_tremolos (m, slur_strs = slur_strs):
1271 if tr not in slur_strs:
1272 slur_strs.append (tr)
1275 str = re.sub (r"([a-z]+[',!? ]*)(:[0-9]+)",
1278 def sub_dyn_end (m, dyns = dyns):
1280 return ' ' + m.group(2)
1282 str = re.sub (r'(\\!)\s*([a-z]+)', sub_dyn_end, str)
1283 def sub_slurs(m, slur_strs = slur_strs):
1284 if '-)' not in slur_strs:
1285 slur_strs.append (')')
1288 def sub_p_slurs(m, slur_strs = slur_strs):
1289 if '-\)' not in slur_strs:
1290 slur_strs.append ('\)')
1293 str = re.sub (r"\)[ ]*([a-z]+)", sub_slurs, str)
1294 str = re.sub (r"\\\)[ ]*([a-z]+)", sub_p_slurs, str)
1295 def sub_begin_slurs(m, slur_strs = slur_strs):
1296 if '-(' not in slur_strs:
1297 slur_strs.append ('(')
1300 str = re.sub (r"([a-z]+[,'!?0-9 ]*)\(",
1301 sub_begin_slurs, str)
1302 def sub_begin_p_slurs(m, slur_strs = slur_strs):
1303 if '-\(' not in slur_strs:
1304 slur_strs.append ('\(')
1307 str = re.sub (r"([a-z]+[,'!?0-9 ]*)\\\(",
1308 sub_begin_p_slurs, str)
1310 def sub_dyns (m, slur_strs = slur_strs):
1312 if s == '@STARTCRESC@':
1313 slur_strs.append ("\\<")
1314 elif s == '@STARTDECRESC@':
1315 slur_strs.append ("\\>")
1317 slur_strs.append ('\\!')
1320 str = re.sub (r'@STARTCRESC@', sub_dyns, str)
1321 str = re.sub (r'-?\\!', sub_dyns, str)
1323 def sub_articulations (m, slur_strs = slur_strs):
1325 if a not in slur_strs:
1326 slur_strs.append (a)
1329 str = re.sub (r"([_^-]\@ACCENT\@)", sub_articulations,
1331 str = re.sub (r"([_^-]\\[a-z]+)", sub_articulations,
1333 str = re.sub (r"([_^-][>_.+|^-])", sub_articulations,
1335 str = re.sub (r'([_^-]"[^"]+")', sub_articulations,
1338 def sub_pslurs(m, slur_strs = slur_strs):
1339 slur_strs.append (' \\)')
1341 str = re.sub (r"\\\)[ ]*([a-z]+)", sub_pslurs, str)
1345 suffix = string.join (slur_strs, '') + string.join (pslur_strs,
1347 + string.join (dyns, '')
1349 return '@STARTCHORD@%s@ENDCHORD@%s%s' % (str , dur_str, suffix)
1353 def sub_chords (str):
1358 marker_str = '%% new-chords-done %%'
1360 if re.search (marker_str,str):
1362 str = re.sub ('<<', '@STARTCHORD@', str)
1363 str = re.sub ('>>', '@ENDCHORD@', str)
1365 str = re.sub (r'\\<', '@STARTCRESC@', str)
1366 str = re.sub (r'\\>', '@STARTDECRESC@', str)
1367 str = re.sub (r'([_^-])>', r'\1@ACCENT@', str)
1368 str = re.sub (r'<([^<>{}]+)>', sub_chord, str)
1370 # add dash: -[, so that [<<a b>> c d] becomes
1372 # and gets skipped by articulation_substitute
1373 str = re.sub (r'\[ *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)',
1375 str = re.sub (r'\\! *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)',
1378 str = re.sub (r'<([^?])', r'%s\1' % simstart, str)
1379 str = re.sub (r'>([^?])', r'%s\1' % simend, str)
1380 str = re.sub ('@STARTCRESC@', r'\\<', str)
1381 str = re.sub ('@STARTDECRESC@', r'\\>' ,str)
1382 str = re.sub (r'\\context *Voice *@STARTCHORD@',
1383 '@STARTCHORD@', str)
1384 str = re.sub ('@STARTCHORD@', chordstart, str)
1385 str = re.sub ('@ENDCHORD@', chordend, str)
1386 str = re.sub (r'@ACCENT@', '>', str)
1389 def text_markup (str):
1390 str = re.sub (r"""([-_^]) *# *' *\( *music *(\"[^"]*\") *\)""",
1391 r"\1\\markup { \\musicglyph #\2 }", str)
1392 str = re.sub (r"""([-_^]) *# *' *\( *([a-z]+) *([^()]*)\)""",
1393 r"\1\\markup { \\\2 \3 }", str)
1394 str = re.sub (r"""\\mark *# *' *\( *music *(\"[^"]*\") *\)""",
1395 r"\\mark \\markup { \\musicglyph #\1 }", str)
1396 str = re.sub (r"""\\mark *# *' *\( *([a-z]+) *([^()]*)\)""",
1397 r"\\mark \\markup { \\\1 \2 }", str)
1400 def articulation_substitute (str):
1401 str = re.sub (r"""([^-])\[ *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
1403 str = re.sub (r"""([^-])\\\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
1405 str = re.sub (r"""([^-\\])\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
1407 str = re.sub (r"""([^-])\\! *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
1411 def conv_relative(str):
1412 if re.search (r"\\relative", str):
1413 str= "#(ly:set-option 'old-relative)\n" + str
1418 str = re.sub (r"#'\(\)", "@SCM_EOL@", str)
1419 str = conv_relative (str)
1420 str = sub_chords (str)
1422 str = text_markup (str)
1423 str = articulation_substitute (str)
1424 str = re.sub ("@SCM_EOL@", "#'()", str)
1428 conversions.append (((1,9,0), conv, """New relative mode,
1429 Postfix articulations, new text markup syntax, new chord syntax."""))
1433 if re.search ("font-style",str):
1434 sys.stderr.write ("font-style is deprecated. Please remove.")
1435 raise FatalConversionError()
1437 str = re.sub (r'-\\markup', r'@\\markup', str)
1438 str = re.sub (r'-\\', r'\\', str)
1439 str = re.sub (r'-\)', ')', str)
1440 str = re.sub (r'-\(', '(', str)
1441 str = re.sub ('-\[', '[', str)
1442 str = re.sub ('-\]', ']', str)
1443 str = re.sub ('-~', '~', str)
1444 str = re.sub (r'@\\markup', r'-\\markup', str)
1447 conversions.append (((1,9,1), conv, """Remove - before articulation"""))
1450 str = re.sub ('ly:set-context-property',
1451 'ly:set-context-property!', str)
1452 str = re.sub ('\\\\newcontext', '\\\\new', str)
1453 str = re.sub ('\\\\grace[\t\n ]*([^{ ]+)',
1454 r'\\grace { \1 }', str)
1455 str = re.sub ("\\\\grace[\t\n ]*{([^}]+)}",
1457 \\property Voice.Stem \\override #'stroke-style = #"grace"
1459 \\property Voice.Stem \\revert #'stroke-style }
1464 conversions.append (((1,9,2), conv, """\\newcontext -> \\new"""))
1468 str = re.sub ('accacciatura',
1469 'acciaccatura', str)
1471 if re.search ("context-spec-music", str):
1472 sys.stderr.write ("context-spec-music takes a symbol for the context now. Update by hand.")
1474 raise FatalConversionError()
1476 str = re.sub ('fingerHorizontalDirection *= *#(LEFT|-1)',
1477 "fingeringOrientations = #'(up down left)", str)
1478 str = re.sub ('fingerHorizontalDirection *= *#(RIGHT|1)',
1479 "fingeringOrientations = #'(up down right)", str)
1483 conversions.append (((1,9,3), conv,
1484 """\\acciaccatura misspelling, fingerHorizontalDirection -> fingeringOrientations"""))
1488 if re.search ('\\figures', str):
1489 sys.stderr.write ("Warning: attempting automatic \\figures conversion. Check results!");
1492 def figures_replace (m):
1494 s = re.sub ('<', '@FIGOPEN@',s)
1495 s = re.sub ('>', '@FIGCLOSE@',s)
1496 return '\\figures { %s }' % s
1498 str = re.sub (r'\\figures[ \t\n]*{([^}]+)}', figures_replace, str)
1499 str = re.sub (r'\\<', '@STARTCRESC@', str)
1500 str = re.sub (r'\\>', '@STARTDECRESC@', str)
1501 str = re.sub (r'([-^_])>', r'\1@ACCENT@', str)
1502 str = re.sub (r'<<', '@STARTCHORD@', str)
1503 str = re.sub (r'>>', '@ENDCHORD@', str)
1504 str = re.sub (r'>', '@ENDSIMUL@', str)
1505 str = re.sub (r'<', '@STARTSIMUL@', str)
1506 str = re.sub ('@STARTDECRESC@', '\\>', str)
1507 str = re.sub ('@STARTCRESC@', '\\<', str)
1508 str = re.sub ('@ACCENT@', '>', str)
1509 str = re.sub ('@ENDCHORD@', '>', str)
1510 str = re.sub ('@STARTCHORD@', '<', str)
1511 str = re.sub ('@STARTSIMUL@', '<<', str)
1512 str = re.sub ('@ENDSIMUL@', '>>', str)
1513 str = re.sub ('@FIGOPEN@', '<', str)
1514 str = re.sub ('@FIGCLOSE@', '>', str)
1518 conversions.append (((1,9,4), conv, 'Swap < > and << >>'))
1522 str = re.sub ('HaraKiriVerticalGroup', 'RemoveEmptyVerticalGroup', str)
1526 conversions.append (((1,9,5), conv, 'HaraKiriVerticalGroup -> RemoveEmptyVerticalGroup'))
1529 if re.search ("ly:get-font", str) :
1530 sys.stderr.write (r"(ly:get-font foo ..) has been replaced by" + \
1531 " (ly:paper-get-font (ly:grob-get-paper foo) .. ).\n" +\
1532 "please update manually.")
1534 raise FatalConversionError()
1536 if re.search ("\\pitch *#", str) :
1537 sys.stderr.write (r"\\pitch has been deprecated. " +\
1538 " Use Scheme code to construct arbitrary note events.")
1540 raise FatalConversionError()
1545 conversions.append (((1,9,6), conv, 'ly:get-font deprecated.'))
1548 def sub_alteration (m):
1552 '-2': 'DOUBLE-FLAT',
1555 '2': 'DOUBLE-SHARP',
1558 return '(ly:make-pitch %s %s %s)' % (m.group(1), m.group (2),
1561 str =re.sub ("\\(ly:make-pitch *([0-9-]+) *([0-9-]+) *([0-9-]+) *\\)",
1562 sub_alteration, str)
1565 str = re.sub ("ly:verbose", "ly:get-option 'verbose", str)
1567 m= re.search ("\\\\outputproperty #([^#]+)[\t\n ]*#'([^ ]+)", str)
1570 r"""\outputproperty found,
1571 Please hand-edit, using
1573 \applyoutput #(outputproperty-compatibility %s '%s <GROB PROPERTY VALUE>)
1575 as a substitution text.""" % (m.group (1), m.group (2)) )
1576 raise FatalConversionError ()
1578 if re.search ("ly:(make-pitch|pitch-alteration)", str) \
1579 or re.search ("keySignature", str):
1581 """The alteration field of Scheme pitches was multiplied by 2
1582 to support quarter tone accidentals. You have to edit the following constructs by hand:
1584 * calls of ly:make-pitch and ly:pitch-alteration
1585 * keySignature settings made with \property
1587 raise FatalConversionError ()
1590 conversions.append (((1,9,7), conv,
1591 '''use symbolic constants for alterations,
1592 remove \\outputproperty, move ly:verbose into ly:get-option'''))
1596 if re.search ("dash-length",str):
1597 sys.stderr.write ("""dash-length has been removed. Use dash-fraction instead.""")
1598 raise FatalConversionError()
1601 conversions.append (((1,9,8), conv, """dash-length -> dash-fraction"""))
1606 return "#'font-size = #%d" % (2*string.atoi (match.group (1)))
1608 str =re.sub (r"#'font-relative-size\s*=\s*#\+?([0-9-]+)", func, str)
1609 str =re.sub (r"#'font-family\s*=\s*#'ancient",
1610 r"#'font-family = #'music", str)
1614 conversions.append (((2,1,1), conv, """font-relative-size -> font-size"""))
1617 str =re.sub (r"ly:get-music-length", "ly:music-length", str)
1620 conversions.append (((2,1,2), conv, """ly:get-music-length -> ly:music-length"""))
1623 str =re.sub (r"\.\s+stz=", ". instr ", str)
1626 conversions.append (((2,1,3), conv, """stanza -> instrument"""))
1637 return r" \property %s.melismaBusyProperties \unset" % c
1639 return r"\property %s.melismaBusyProperties = #'(melismaBusy)" % c
1641 str =re.sub (r"\\property ([a-zA-Z]+)\s*\.\s*automaticMelismata\s*=\s*##([ft])", func, str)
1644 conversions.append (((2,1,4), conv, """removal of automaticMelismata; use melismaBusyProperties instead."""))
1649 str =re.sub (r"\\translator\s+([a-zA-Z]+)", r"\\change \1", str)
1652 conversions.append (((2,1,7), conv, """\\translator Staff -> \\change Staff"""))
1655 str =re.sub (r"\\newaddlyrics", r"\\lyricsto", str)
1658 conversions.append (((2,1,10), conv, """\\newaddlyrics -> \\lyricsto"""))
1661 str = re.sub (r'\\include\s*"paper([0-9]+)(-init)?.ly"',
1662 r"#(set-staff-size \1)", str)
1664 def sub_note (match):
1666 log = string.atoi (match.group (1))
1667 dots = string.atoi (match.group (2))
1670 dur = '%d' % (1 << log)
1672 dur = { -1 : 'breve',
1678 return r'\note #"%s" #%s' % (dur, match.group (3))
1680 str = re.sub (r'\\note\s+#([0-9-]+)\s+#([0-9]+)\s+#([0-9.-]+)',
1684 conversions.append (((2,1,11), conv, """\\include "paper16.ly" -> #(set-staff-size 16)
1685 \\note #3 #1 #1 -> \\note #"8." #1
1690 str =re.sub (r"OttavaSpanner", r"OttavaBracket", str)
1693 conversions.append (((2,1,12), conv, """OttavaSpanner -> OttavaBracket"""))
1697 str =re.sub (r"\(set-staff-size ", r"(set-global-staff-size ", str)
1700 conversions.append (((2,1,13), conv, """set-staff-size -> set-global-staff-size"""))
1703 str =re.sub (r"#'style\s*=\s*#'dotted-line",
1704 r"#'dash-fraction = #0.0 ", str)
1707 conversions.append (((2,1,14), conv, """style = dotted -> dash-fraction = 0"""))
1710 str =re.sub (r'LyricsVoice\s*\.\s*instrument\s*=\s*("[^"]*")',
1711 r'LyricsVoice . vocalName = \1', str)
1713 str =re.sub (r'LyricsVoice\s*\.\s*instr\s*=\s*("[^"]*")',
1714 r'LyricsVoice . vocNam = \1', str)
1717 conversions.append (((2,1,15), conv, """LyricsVoice . instr(ument) -> vocalName"""))
1731 return '\\%s' % d[m.group (1)]
1733 str = re.sub (r'\\musicglyph\s*#"accidentals-([0-9-]+)"',
1737 conversions.append (((2,1,16), conv, """\\musicglyph #"accidentals-NUM" -> \\sharp/flat/etc."""))
1742 if re.search (r'\\partcombine', str):
1743 sys.stderr.write ('Warning: \\partcombine has been changed. '
1744 +'Check conversion manually!')
1746 raise FatalConversionError()
1748 # this rule doesn't really work,
1749 # too lazy to figure out why.
1750 str = re.sub (r'\\context\s+Voice\s*=\s*one\s*\\partcombine\s+Voice\s*\\context\s+Thread\s*=\s*one(.*)\s*'
1751 + r'\\context\s+Thread\s*=\s*two',
1752 '\\\\newpartcombine\n\\1\n', str)
1757 conversions.append (((2,1,17), conv, """\\partcombine syntax change to \\newpartcombine"""))
1761 str = re.sub (r'\\newpartcombine', r'\\partcombine', str)
1762 str = re.sub (r'\\autochange\s+Staff', r'\\autochange ', str)
1765 conversions.append (((2,1,18), conv, """\\newpartcombine -> \\partcombine,
1766 \\autochange Staff -> \\autochange
1773 str = re.sub (r'\\include "drumpitch-init.ly"','', str)
1774 str = re.sub (r'\\pitchnames ','pitchnames = ', str)
1775 str = re.sub (r'\\chordmodifiers ','chordmodifiers = ', str)
1776 str = re.sub (r'\bdrums\b\s*=','drumContents = ', str)
1777 str = re.sub (r'\\drums\b','\\drumContents ', str)
1780 if re.search ('drums->paper', str):
1781 sys.stderr.write ("\nDrum notation found. Check file manually!")
1783 str = re.sub (r"""\\apply\s+#\(drums->paper\s+'([a-z]+)\)""",
1784 r"""\property DrumStaff.drumStyleTable = #\1-style""",
1787 if re.search ('Thread', str):
1788 sys.stderr.write ("\nThread found. Check file manually!\n");
1790 str = re.sub (r"""(\\once\s*)?\\property\s+Thread\s*\.\s*NoteHead\s*"""
1791 + r"""\\(set|override)\s*#'style\s*=\s*#'harmonic"""
1792 + r"""\s+([a-z]+[,'=]*)([0-9]*\.*)"""
1793 ,r"""<\3\\harmonic>\4""", str)
1795 str = re.sub (r"""\\new Thread""", """\context Voice""", str)
1796 str = re.sub (r"""Thread""", """Voice""", str)
1798 if re.search ('\bLyrics\b', str):
1799 sys.stderr.write ("\nLyrics found. Check file manually!\n");
1801 str = re.sub (r"""LyricsVoice""", r"""L@ricsVoice""", str)
1802 str = re.sub (r"""\bLyrics\b""", r"""LyricsVoice""", str)
1803 str = re.sub (r"""LyricsContext""", r"""LyricsVoiceContext""", str)
1804 str = re.sub (r"""L@ricsVoice""", r"""LyricsVoice""",str)
1809 conversions.append (((2,1,19), conv, """Drum notation changes, Removing \\chordmodifiers, \\notenames.
1810 Harmonic notes. Thread context removed. Lyrics context removed."""))
1813 str = re.sub (r'nonevent-skip', 'skip-music', str)
1816 conversions.append (((2,1,20), conv, """nonevent-skip -> skip-music""" ))
1819 str = re.sub (r'molecule-callback', 'print-function', str)
1820 str = re.sub (r'brew_molecule', 'print', str)
1821 str = re.sub (r'brew-new-markup-molecule', 'Text_item::print', str)
1822 str = re.sub (r'LyricsVoice', 'Lyrics', str)
1823 str = re.sub (r'tupletInvisible',
1824 r"TupletBracket \\set #'transparent", str)
1825 # str = re.sub (r'molecule', 'collage', str)
1826 #molecule -> collage
1827 str = re.sub (r"\\property\s+[a-zA-Z]+\s*\.\s*[a-zA-Z]+\s*"
1828 + r"\\set\s*#'X-extent-callback\s*=\s*#Grob::preset_extent",
1833 conversions.append (((2,1,21), conv, """molecule-callback -> print-function,
1834 brew_molecule -> print
1835 brew-new-markup-molecule -> Text_item::print
1836 LyricsVoice -> Lyrics
1837 tupletInvisible -> TupletBracket \set #'transparent
1838 Grob::preset_extent removed.
1843 str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\=]+)\s*\\(set|override)',
1844 r"\\overrid@ \1.\2 ", str)
1845 str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*=\s*',
1846 r'\\s@t \1.\2 = ', str)
1847 str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*\\unset',
1848 r'\\uns@t \1.\2 ', str)
1849 str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*\\revert'
1850 + r"\s*#'([-a-z0-9_]+)",
1851 r"\\rev@rt \1.\2 #'\3", str)
1852 str = re.sub (r'Voice\.', '', str)
1853 str = re.sub (r'Lyrics\.', '', str)
1854 str = re.sub (r'ChordNames\.', '', str)
1856 str = re.sub ('rev@rt', 'revert',str)
1857 str = re.sub ('s@t', 'set',str)
1858 str = re.sub ('overrid@', 'override',str)
1860 str = re.sub ('molecule', 'stencil', str)
1861 str = re.sub ('Molecule', 'Stencil', str)
1864 conversions.append (((2,1,22), conv, """new syntax for property settings:
1865 \\set A.B = #C , \\unset A.B
1866 \\override A.B #C = #D, \\revert A.B #C
1871 def subst_in_trans (match):
1873 s = re.sub (r'\s([a-zA-Z]+)\s*\\override',
1874 r' \\override \1', s)
1875 s = re.sub (r'\s([a-zA-Z]+)\s*\\set',
1876 r' \\override \1', s)
1877 s = re.sub (r'\s([a-zA-Z]+)\s*\\revert',
1880 str = re.sub (r'\\(translator|with)\s*{[^}]+}', subst_in_trans, str)
1884 context = m.group ('context')
1887 context = " '%s" % context[:-1] # -1: remove .
1891 d['context'] = context
1893 return r"""#(override-auto-beam-setting %(prop)s %(num)s %(den)s%(context)s)""" % d
1895 str = re.sub (r"""\\override\s*(?P<context>[a-zA-Z]+\s*\.\s*)?autoBeamSettings"""
1896 +r"""\s*#(?P<prop>[^=]+)\s*=\s*#\(ly:make-moment\s+(?P<num>\d+)\s+(?P<den>\d)\s*\)""",
1901 conversions.append (((2,1,23), conv, """Property setting syntax in \\translator{ }"""))
1903 str = re.sub (r'music-list\?', 'ly:music-list?', str)
1904 str = re.sub (r'\|\s*~', '~ |', str)
1907 conversions.append (((2,1,24), conv, """music-list? -> ly:music-list?"""))
1910 str = re.sub (r'ly:get-spanner-bound', 'ly:spanner-get-bound', str)
1911 str = re.sub (r'ly:get-extent', 'ly:grob-extent', str)
1912 str = re.sub (r'ly:get-system', 'ly:grob-system', str)
1913 str = re.sub (r'ly:get-original', 'ly:grob-original', str)
1914 str = re.sub (r'ly:get-parent', 'ly:grob-parent', str)
1915 str = re.sub (r'ly:get-broken-into', 'ly:spanner-broken-into', str)
1916 str = re.sub (r'Melisma_engraver', 'Melisma_translator', str)
1917 if re.search ("ly:get-paper-variable", str):
1918 sys.stderr.write ('use (ly:paper-lookup (ly:grob-paper ))')
1919 raise FatalConversionError()
1921 str = re.sub (r'\\defaultAccidentals', "#(set-accidental-style 'default)", str)
1922 str = re.sub (r'\\voiceAccidentals', "#(set-accidental-style 'voice)", str)
1923 str = re.sub (r'\\modernAccidentals', "#(set-accidental-style 'modern)", str)
1924 str = re.sub (r'\\modernCautionaries', "#(set-accidental-style 'modern-cautionary)", str)
1925 str = re.sub (r'\\modernVoiceAccidental', "#(set-accidental-style 'modern-voice)", str)
1926 str = re.sub (r'\\modernVoiceCautionaries', "#(set-accidental-style 'modern-voice-cautionary)", str)
1927 str = re.sub (r'\\pianoAccidentals', "#(set-accidental-style 'piano)", str)
1928 str = re.sub (r'\\pianoCautionaries', "#(set-accidental-style 'piano-cautionary)", str)
1929 str = re.sub (r'\\forgetAccidentals', "#(set-accidental-style 'forget)", str)
1930 str = re.sub (r'\\noResetKey', "#(set-accidental-style 'no-reset)", str)
1934 conversions.append (((2,1,25), conv, """Scheme grob function renaming"""))
1938 str = re.sub ('ly:set-grob-property!', 'ly:grob-set-property!',str)
1939 str = re.sub ('ly:set-mus-property!', 'ly:music-set-property!',str)
1940 str = re.sub ('ly:set-context-property!', 'ly:context-set-property!', str)
1941 str = re.sub ('ly:get-grob-property', 'ly:grob-property',str)
1942 str = re.sub ('ly:get-mus-property', 'ly:music-property',str)
1943 str = re.sub ('ly:get-context-property', 'ly:context-property',str)
1947 conversions.append (((2,1,26), conv, """More Scheme function renaming"""))
1951 g = string.atoi (m.group (2))
1959 lower_pitches = filter (lambda x : x <= g, [0, 2, 4, 5, 7, 9, 11, 12])
1960 s = len (lower_pitches) -1
1961 a = g - lower_pitches [-1]
1964 print s , lower_pitches, g, a, s
1966 str += ['eses', 'es', '', 'is', 'isis'][a + 2]
1968 str += ',' * (-o - 1)
1970 str += "'" * (o + 1)
1972 return '\\transposition %s ' % str
1975 str = re.sub (r"\\set ([A-Za-z]+\s*\.\s*)?transposing\s*=\s*#([-0-9]+)",
1979 conversions.append (((2,1,27), conv, """property transposing -> tuning"""))
1982 str = re.sub (r'make-music-by-name', 'make-music', str)
1983 str = re.sub (r"\\override\s+.*Arpeggio\s+#.print-function\s+=\s+\\arpeggioBracket", r"\\arpeggioBracket", str)
1986 conversions.append (((2,1,28), conv,
1987 """make-music-by-name -> make-music,
1988 new syntax for setting \\arpeggioBracket"""))
1991 str = re.sub (r'\\center([^-])', '\\center-align\\1', str)
1992 str = re.sub (r'\\translator', '\\context', str)
1995 conversions.append (((2,1,29), conv,
1996 '\\center -> \\center-align, \\translator -> \\context'))
2000 str = re.sub (r'\\threeq(flat|sharp)', r'\\sesqui\1', str)
2001 str = re.sub (r'ly:stencil-get-extent',
2002 'ly:stencil-extent', str)
2003 str = re.sub (r'ly:translator-find',
2004 'ly:context-find', str)
2005 str = re.sub ('ly:unset-context-property','ly:context-unset-property',
2008 str = re.sub (r'ly:get-mutable-properties',
2009 'ly:mutable-music-properties',str)
2010 str = re.sub (r'centralCPosition',
2011 'middleCPosition',str)
2014 conversions.append (((2,1,30), conv,
2015 '''\\threeq{flat,sharp} -> \\sesqui{flat,sharp}
2016 ly:get-mutable-properties -> ly:mutable-music-properties
2017 centralCPosition -> middleCPosition
2018 ly:unset-context-property -> ly:context-unset-property
2019 ly:translator-find -> ly:context-find
2020 ly:get-stencil-extent -> ly:stencil-extent
2025 str = re.sub (r'\\alias\s*"?Timing"?', '', str)
2028 conversions.append (((2,1,31), conv,
2029 '''remove \\alias Timing'''))
2032 str = re.sub (r"(\\set\s+)?(?P<context>(Score\.)?)breakAlignOrder\s*=\s*#'(?P<list>[^\)]+)",
2033 r"\n\\override \g<context>BreakAlignment #'break-align-orders = "
2034 + "#(make-vector 3 '\g<list>)", str)
2038 conversions.append (((2,1,33), conv,
2039 '''breakAlignOrder -> break-align-orders.'''))
2042 str = re.sub (r"\(set-paper-size",
2043 "(set-default-paper-size",str)
2046 conversions.append (((2,1,34), conv,
2047 '''set-paper-size -> set-default-paper-size.'''))
2050 str = re.sub (r"ly:mutable-music-properties",
2051 "ly:music-mutable-properties", str)
2054 conversions.append (((2,1, 36), conv,
2055 '''ly:mutable-music-properties -> ly:music-mutable-properties'''))
2062 conversions.append (((2, 2, 0), conv,
2063 '''clean up version. '''))
2066 return re.sub (r'\\apply\b', r'\\applymusic', str)
2068 conversions.append (((2, 3, 1), conv,
2069 '''\\apply -> \\applymusic'''))
2072 if re.search ('textheight', str):
2073 sys.stderr.write("\nWarning: tuning of page layout has changed. See reference manual.\n")
2075 str = re.sub (r'\\OrchestralScoreContext', '\\Score', str)
2077 if m.group(1) not in ['RemoveEmptyStaff',
2078 'AncientRemoveEmptyStaffContext',
2080 return '\\' + m.group (1)
2085 str = re.sub (r'\\([a-zA-Z]+)Context\b', func, str)
2087 str = re.sub ('ly:paper-lookup', 'ly:output-def-lookup', str)
2090 conversions.append (((2, 3, 2), conv,
2091 '''\\FooContext -> \\Foo'''))
2094 str = re.sub (r'\\notes\b', '', str)
2098 conversions.append (((2, 3, 4), conv,
2099 '''remove \\notes'''))
2104 str = re.sub (r'lastpagefill\s*=\s*"?1"', 'raggedlastbottom = ##t', str)
2107 conversions.append (((2, 3, 6), conv,
2108 '''lastpagefill -> raggedlastbottom'''))
2113 str = re.sub (r'\\consistsend', '\\consists', str)
2114 str = re.sub (r'\\lyricsto\s+("?[a-zA-Z]+"?)(\s*\\new Lyrics\s*)?\\lyrics',
2115 r'\\lyricsto \1 \2', str)
2118 conversions.append (((2, 3, 8), conv,
2119 '''remove \\consistsend, strip \\lyrics from \\lyricsto.'''))
2122 str = re.sub (r'neo_mensural', 'neomensural', str)
2123 str = re.sub (r'if-text-padding', 'bound-padding', str)
2126 conversions.append (((2, 3, 9), conv,
2127 '''neo_mensural -> neomensural, if-text-padding -> bound-padding'''))
2132 str = re.sub (r'\\addlyrics', r'\\oldaddlyrics', str)
2133 str = re.sub (r'\\newlyrics', r'\\addlyrics', str)
2134 if re.search (r"\\override\s*TextSpanner", str):
2135 sys.stderr.write ("\nWarning: TextSpanner has been split into DynamicTextSpanner and TextSpanner\n")
2138 conversions.append (((2, 3, 10), conv,
2139 '''\\addlyrics -> \\oldaddlyrics, \\newlyrics -> \\addlyrics'''))
2142 str = re.sub (r'\\setMmRestFermata\s+(R[0-9.*/]*)',
2143 r'\1^\\fermataMarkup', str)
2146 conversions.append (((2, 3, 11), conv,
2147 '''\\setMmRestFermata -> ^\\fermataMarkup'''))
2150 str = re.sub (r'\\newpage', r'\\pageBreak', str)
2151 str = re.sub (r'\\scriptUp', r"""{
2152 \\override TextScript #'direction = #1
2153 \\override Script #'direction = #1
2155 str = re.sub (r'\\scriptDown', r"""{
2156 \\override TextScript #'direction = #-1
2157 \\override Script #'direction = #-1
2159 str = re.sub (r'\\scriptBoth', r"""{
2160 \\revert TextScript #'direction
2161 \\revert Script #'direction
2163 str = re.sub ('soloADue', 'printPartCombineTexts', str)
2164 str = re.sub (r'\\applymusic\s*#notes-to-clusters',
2165 '\\makeClusters', str)
2167 str = re.sub (r'pagenumber\s*=', 'firstpagenumber', str)
2170 conversions.append (((2, 3, 12), conv,
2171 '''\\newpage -> \\pageBreak, junk \\script{up,down,both},
2172 soloADue -> printPartCombineTexts, #notes-to-clusters -> \\makeClusters
2177 str = re.sub (r'\\chords\b', r'\\chordmode', str)
2178 str = re.sub (r'\\lyrics\b', r'\\lyricmode', str)
2179 str = re.sub (r'\\figures\b', r'\\figuremode', str)
2180 str = re.sub (r'\\notes\b', r'\\notemode', str)
2181 str = re.sub (r'\\drums\b', r'\\drummode', str)
2182 str = re.sub (r'\\chordmode\s*\\new ChordNames', r'\\chords', str)
2183 str = re.sub (r'\\new ChordNames\s*\\chordmode', r'\\chords', str)
2184 str = re.sub (r'\\new FiguredBass\s*\\figuremode', r'\\figures', str)
2185 str = re.sub (r'\\figuremode\s*\new FiguredBass', r'\\figures', str)
2186 str = re.sub (r'\\new DrumStaff\s*\\drummode', r'\\drums', str)
2187 str = re.sub (r'\\drummode\s*\\new DrumStaff', r'\\drums', str)
2191 conversions.append (((2, 3, 16), conv,
2192 '''\foo -> \foomode (for chords, notes, etc.)
2193 fold \new FooContext \foomode into \foo.'''))
2196 str = re.sub (r'(slur|stem|phrasingSlur|tie|dynamic|dots|tuplet|arpeggio|)Both', r'\1Neutral', str)
2197 str = re.sub (r"\\applymusic\s*#\(remove-tag\s*'([a-z-0-9]+)\)",
2198 r"\\removeWithTag #'\1", str)
2201 conversions.append (((2, 3, 17), conv,
2202 '''\foo -> \foomode (for chords, notes, etc.)
2203 fold \new FooContext \foomode into \foo.'''))
2207 str = re.sub (r'Text_item', 'Text_interface', str)
2210 conversions.append (((2, 3, 18),
2212 '''Text_item -> Text_interface''' ))
2215 str = re.sub (r'\\paper', r'\\layout', str)
2216 str = re.sub (r'\\bookpaper', r'\\paper', str)
2217 if re.search ('paper-set-staff-size', str):
2218 sys.stderr.write ('''\nWarning: staff size should be changed at top-level
2221 #(set-global-staff-size <STAFF-HEIGHT-IN-POINT>)
2226 str = re.sub (r'#\(paper-set-staff-size', '%Use set-global-staff-size at toplevel\n% #(layout-set-staff-size', str)
2229 conversions.append (((2, 3, 22),
2232 bookpaper -> paper''' ))
2236 str = re.sub (r'\\context\s+([a-zA-Z]+)\s*=\s*([a-z]+)\s',
2237 r'\\context \1 = "\2" ',
2241 conversions.append (((2, 3, 23),
2243 '''\context Foo = NOTENAME -> \context Foo = "NOTENAME"'''))
2249 conversions.append (((2, 4, 0),
2255 str = re.sub (r'\\quote\s+"?([a-zA-Z0-9]+)"?\s+([0-9.*/]+)',
2256 r'\\quoteDuring #"\1" { \skip \2 }',
2261 conversions.append (((2, 5, 0),
2267 str = re.sub (r'ly:import-module',
2268 r'ly:module-copy', str)
2271 conversions.append (((2, 5, 1),
2273 'ly:import-module -> ly:module-copy'))
2276 str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<([^<]*)>',
2278 str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<([^<]*)>',
2280 str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<([^<]*)>',
2284 conversions.append (((2, 5, 2),
2286 '\markup .. < .. > .. -> \markup .. { .. } ..'))
2289 str = re.sub ('ly:find-glyph-by-name', 'ly:font-get-glyph', str)
2290 str = re.sub ('"(scripts|clefs|accidentals)-', r'"\1.', str)
2291 str = re.sub ("'hufnagel-do-fa", "'hufnagel.do.fa", str)
2292 str = re.sub ("'(vaticana|hufnagel|medicaea|petrucci|neomensural|mensural)-", r"'\1.", str)
2295 conversions.append (((2, 5, 3),
2297 'ly:find-glyph-by-name -> ly:font-get-glyph, remove - from glyphnames.'))
2302 if re.search (r"\\encoding", str):
2303 sys.stderr.write ("Sorry, input files should be UTF8.\n"
2304 + "Please convert by hand.")
2305 raise FatalConversionError()
2309 conversions.append (((2, 5, 2),
2311 'ly:find-glyph-by-name -> ly:font-get-glyph, remove - from glyphnames.'))
2314 ################################
2315 # END OF CONVERSIONS
2316 ################################
2318 def get_conversions (from_version, to_version):
2319 def version_b (v, f = from_version, t = to_version):
2320 return version_cmp (v[0], f) > 0 and version_cmp (v[0], t) <= 0
2321 return filter (version_b, conversions)
2324 def latest_version ():
2325 return conversions[-1][0]
2327 def do_conversion (infile, from_version, outfile, to_version):
2328 conv_list = get_conversions (from_version, to_version)
2330 sys.stderr.write ('Applying conversions: ')
2331 str = infile.read ()
2332 last_conversion = ()
2335 sys.stderr.write (tup_to_str (x[0]) + ', ')
2337 last_conversion = x[0]
2339 except FatalConversionError:
2340 sys.stderr.write ('Error while converting; I won\'t convert any further')
2343 sys.stderr.write ('\n')
2344 new_ver = '\\version \"%s\"' % tup_to_str (last_conversion)
2346 if re.search (lilypond_version_re_str, str):
2347 str = re.sub (lilypond_version_re_str,'\\'+new_ver, str)
2349 str = new_ver + '\n' + str
2353 return last_conversion
2355 class UnknownVersion:
2358 def do_one_file (infile_name):
2359 sys.stderr.write ('Processing `%s\' ... '% infile_name)
2362 outfile_name = infile_name + '.NEW'
2363 elif __main__.outfile_name:
2364 outfile_name = __main__.outfile_name
2366 if __main__.from_version:
2367 from_version = __main__.from_version
2369 guess = guess_lilypond_version (infile_name)
2371 raise UnknownVersion ()
2372 from_version = str_to_tuple (guess)
2374 if __main__.to_version:
2375 to_version = __main__.to_version
2377 to_version = latest_version ()
2381 infile = open (infile_name,'r')
2386 outfile = open (outfile_name, 'w')
2388 outfile = sys.stdout
2390 touched = do_conversion (infile, from_version, outfile, to_version)
2398 if __main__.edit and touched:
2400 os.remove(infile_name + '~')
2403 os.rename (infile_name, infile_name + '~')
2404 os.rename (infile_name + '.NEW', infile_name)
2406 sys.stderr.write ('\n')
2416 (options, files) = getopt.getopt (sys.argv[1:], 'ao:f:t:senh',
2417 ['no-version', 'version', 'output',
2418 'show-rules', 'help', 'edit',
2424 if o == '--help' or o == '-h':
2427 elif o == '--version' or o == '-v':
2430 elif o== '--from' or o=='-f':
2431 from_version = str_to_tuple (a)
2432 elif o== '--to' or o=='-t':
2433 to_version = str_to_tuple (a)
2434 elif o== '--edit' or o == '-e':
2436 elif o== '--show-rules' or o == '-s':
2438 elif o == '--output' or o == '-o':
2440 elif o == '--no-version' or o == '-n':
2446 # should parse files[] to read \version?
2448 show_rules (sys.stdout)
2455 elif not os.path.isfile (f):
2459 except UnknownVersion:
2460 sys.stderr.write ('\n')
2461 sys.stderr.write ("%s: can't determine version for `%s'" % (program_name, f))
2462 sys.stderr.write ('\n')
2465 from_version = (0, 0, 0)
2469 sys.stderr.write ("%s: skipping: `%s' " % (program_name, f))
2472 sys.stderr.write ('\n')