3 # convert-ly.py -- Update old LilyPond input files (fix name?)
5 # source file of the GNU LilyPond music typesetter
7 # (c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 # Jan Nieuwenhuizen <janneke@gnu.org>
18 localedir = '@localedir@'
21 gettext.bindtextdomain ('lilypond', localedir)
22 gettext.textdomain ('lilypond')
29 program_name = sys.argv[0]
31 version = '@TOPLEVEL_VERSION@'
33 # Did we ever have \mudela-version? I doubt it.
34 # lilypond_version_re_str = '\\\\version *\"(.*)\"'
35 lilypond_version_re_str = '\\\\(mudela-)?version *\"([^"]+)\"'
36 lilypond_version_re = re.compile (lilypond_version_re_str)
41 return '%s (GNU LilyPond) %s' % (program_name, version)
44 sys.stderr.write (program_id () + '\n')
48 r"""Usage: %s [OPTIONS]... [FILE]...
49 Try to convert to newer lilypond-versions. The version number of the
50 input is guessed by default from \version directive.
53 -h, --help print this help
54 -e, --edit edit in place
55 -f, --from=VERSION start from version [default: \version found in file]
56 -s, --show-rules print all rules
57 -t, --to=VERSION end at version [default: @TOPLEVEL_VERSION@]
58 -n, --no-version don't add new version stamp
59 --version print program version
61 Report bugs to bugs-gnu-music@gnu.org.
70 sys.stdout.write (r"""%s
72 This is free software. It is covered by the GNU General Public
73 License, and you are welcome to change it and/or distribute copies of
74 it under certain conditions. invoke as `%s --warranty' for more
77 """ % (program_id (), program_name))
80 return tuple (map (string.atoi, string.split (s, '.')))
83 return string.join (map (lambda x: '%s' % x, list (t)), '.')
85 def version_cmp (t1, t2):
91 def guess_lilypond_version (filename):
92 s = open (filename).read ()
93 m = lilypond_version_re.search (s)
99 class FatalConversionError:
104 def show_rules (file):
105 for x in conversions:
106 if (not from_version or x[0] > from_version) \
107 and (not to_version or x[0] <= to_version):
108 file.write ('%s: %s\n' % (tup_to_str (x[0]), x[2]))
110 ############################
114 if re.search ('\\\\multi', str):
115 sys.stderr.write ('\nNot smart enough to convert \\multi')
118 conversions.append (((0,1,9), conv, '\\header { key = concat + with + operator }'))
120 if 1: # need new a namespace
122 if re.search ('\\\\octave', str):
123 sys.stderr.write ('\nNot smart enough to convert \\octave')
124 # raise FatalConversionError ()
128 conversions.append ((
129 ((0,1,19), conv, 'deprecated \\octave; can\'t convert automatically')))
132 if 1: # need new a namespace
134 str = re.sub ('\\\\textstyle([^;]+);',
135 '\\\\property Lyrics . textstyle = \\1', str)
136 # harmful to current .lys
137 # str = re.sub ('\\\\key([^;]+);', '\\\\accidentals \\1;', str)
141 conversions.append ((
142 ((0,1,20), conv, 'deprecated \\textstyle, new \\key syntax')))
147 str = re.sub ('\\\\musical_pitch', '\\\\musicalpitch',str)
148 str = re.sub ('\\\\meter', '\\\\time',str)
152 conversions.append ((
153 ((0,1,21), conv, '\\musical_pitch -> \\musicalpitch, '+
154 '\\meter -> \\time')))
160 conversions.append ((
161 ((1,0,0), conv, '0.1.21 -> 1.0.0 ')))
166 str = re.sub ('\\\\accidentals', '\\\\keysignature',str)
167 str = re.sub ('specialaccidentals *= *1', 'keyoctaviation = 0',str)
168 str = re.sub ('specialaccidentals *= *0', 'keyoctaviation = 1',str)
172 conversions.append ((
173 ((1,0,1), conv, '\\accidentals -> \\keysignature, ' +
174 'specialaccidentals -> keyoctaviation')))
178 if re.search ('\\\\header', str):
179 sys.stderr.write ('\nNot smart enough to convert to new \\header format')
182 conversions.append (((1,0,2), conv, '\\header { key = concat + with + operator }'))
186 str = re.sub ('\\\\melodic([^a-zA-Z])', '\\\\notes\\1',str)
189 conversions.append (((1,0,3), conv, '\\melodic -> \\notes'))
193 str = re.sub ('default_paper *=', '',str)
194 str = re.sub ('default_midi *=', '',str)
197 conversions.append (((1,0,4), conv, 'default_{paper,midi}'))
201 str = re.sub ('ChoireStaff', 'ChoirStaff',str)
202 str = re.sub ('\\\\output', 'output = ',str)
206 conversions.append (((1,0,5), conv, 'ChoireStaff -> ChoirStaff'))
210 if re.search ('[a-zA-Z]+ = *\\translator',str):
211 sys.stderr.write ('\nNot smart enough to change \\translator syntax')
212 # raise FatalConversionError ()
215 conversions.append (((1,0,6), conv, 'foo = \\translator {\\type .. } ->\\translator {\\type ..; foo; }'))
220 str = re.sub ('\\\\lyrics*', '\\\\lyrics',str)
224 conversions.append (((1,0,7), conv, '\\lyric -> \\lyrics'))
228 str = re.sub ('\\\\\\[/3+', '\\\\times 2/3 { ',str)
229 str = re.sub ('\\[/3+', '\\\\times 2/3 { [',str)
230 str = re.sub ('\\\\\\[([0-9/]+)', '\\\\times \\1 {',str)
231 str = re.sub ('\\[([0-9/]+)', '\\\\times \\1 { [',str)
232 str = re.sub ('\\\\\\]([0-9/]+)', '}', str)
233 str = re.sub ('\\\\\\]', '}',str)
234 str = re.sub ('\\]([0-9/]+)', '] }', str)
237 conversions.append (((1,0,10), conv, '[2/3 ]1/1 -> \\times 2/3 '))
242 conversions.append (((1,0,12), conv, 'Chord syntax stuff'))
249 str = re.sub ('<([^>~]+)~([^>]*)>','<\\1 \\2> ~', str)
253 conversions.append (((1,0,13), conv, '<a ~ b> c -> <a b> ~ c'))
257 str = re.sub ('<\\[','[<', str)
258 str = re.sub ('\\]>','>]', str)
262 conversions.append (((1,0,14), conv, '<[a b> <a b]>c -> [<a b> <a b>]'))
267 str = re.sub ('\\\\type([^\n]*engraver)','\\\\TYPE\\1', str)
268 str = re.sub ('\\\\type([^\n]*performer)','\\\\TYPE\\1', str)
269 str = re.sub ('\\\\type','\\\\context', str)
270 str = re.sub ('\\\\TYPE','\\\\type', str)
271 str = re.sub ('textstyle','textStyle', str)
275 conversions.append (((1,0,16), conv, '\\type -> \\context, textstyle -> textStyle'))
280 if re.search ('\\\\repeat',str):
281 sys.stderr.write ('\nNot smart enough to convert \\repeat')
282 # raise FatalConversionError ()
285 conversions.append (((1,0,18), conv,
286 '\\repeat NUM Music Alternative -> \\repeat FOLDSTR Music Alternative'))
290 str = re.sub ('SkipBars','skipBars', str)
291 str = re.sub ('fontsize','fontSize', str)
292 str = re.sub ('midi_instrument','midiInstrument', str)
296 conversions.append (((1,0,19), conv,
297 'fontsize -> fontSize, midi_instrument -> midiInstrument, SkipBars -> skipBars'))
302 str = re.sub ('tieydirection','tieVerticalDirection', str)
303 str = re.sub ('slurydirection','slurVerticalDirection', str)
304 str = re.sub ('ydirection','verticalDirection', str)
308 conversions.append (((1,0,20), conv,
309 '{,tie,slur}ydirection -> {v,tieV,slurV}erticalDirection'))
314 str = re.sub ('hshift','horizontalNoteShift', str)
318 conversions.append (((1,0,21), conv,
319 'hshift -> horizontalNoteShift'))
324 str = re.sub ('\\\\grouping[^;]*;','', str)
328 conversions.append (((1,1,52), conv,
329 'deprecate \\grouping'))
334 str = re.sub ('\\\\wheel','\\\\coda', str)
338 conversions.append (((1,1,55), conv,
339 '\\wheel -> \\coda'))
343 str = re.sub ('keyoctaviation','keyOctaviation', str)
344 str = re.sub ('slurdash','slurDash', str)
348 conversions.append (((1,1,65), conv,
349 'slurdash -> slurDash, keyoctaviation -> keyOctaviation'))
353 str = re.sub ('\\\\repeat *\"?semi\"?','\\\\repeat "volta"', str)
357 conversions.append (((1,1,66), conv,
363 str = re.sub ('\"?beamAuto\"? *= *\"?0?\"?','noAutoBeaming = "1"', str)
367 conversions.append (((1,1,67), conv,
368 'beamAuto -> noAutoBeaming'))
372 str = re.sub ('automaticMelismas', 'automaticMelismata', str)
376 conversions.append (((1,2,0), conv,
377 'automaticMelismas -> automaticMelismata'))
381 str = re.sub ('dynamicDir\\b', 'dynamicDirection', str)
385 conversions.append (((1,2,1), conv,
386 'dynamicDir -> dynamicDirection'))
390 str = re.sub ('\\\\cadenza *0 *;', '\\\\cadenzaOff', str)
391 str = re.sub ('\\\\cadenza *1 *;', '\\\\cadenzaOn', str)
395 conversions.append (((1,3,4), conv,
396 '\\cadenza -> \\cadenza{On|Off}'))
400 str = re.sub ('"?beamAuto([^"=]+)"? *= *"([0-9]+)/([0-9]+)" *;*',
401 'beamAuto\\1 = #(make-moment \\2 \\3)',
405 conversions.append (((1,3,5), conv, 'beamAuto moment properties'))
409 str = re.sub ('stemStyle',
414 conversions.append (((1,3,17), conv, 'stemStyle -> flagStyle'))
418 str = re.sub ('staffLineLeading',
423 conversions.append (((1,3,18), conv, 'staffLineLeading -> staffSpace'))
428 if re.search ('\\\\repetitions',str):
429 sys.stderr.write ('\nNot smart enough to convert \\repetitions')
430 # raise FatalConversionError()
433 conversions.append (((1,3,23), conv,
434 '\\\\repetitions feature dropped'))
439 str = re.sub ('textEmptyDimension *= *##t',
440 'textNonEmpty = ##f',
442 str = re.sub ('textEmptyDimension *= *##f',
443 'textNonEmpty = ##t',
447 conversions.append (((1,3,35), conv, 'textEmptyDimension -> textNonEmpty'))
451 str = re.sub ("([a-z]+)[ \t]*=[ \t]*\\\\musicalpitch *{([- 0-9]+)} *\n",
452 "(\\1 . (\\2))\n", str)
453 str = re.sub ("\\\\musicalpitch *{([0-9 -]+)}",
454 "\\\\musicalpitch #'(\\1)", str)
455 if re.search ('\\\\notenames',str):
456 sys.stderr.write ('\nNot smart enough to convert to new \\notenames format')
459 conversions.append (((1,3,38), conv, '\musicalpitch { a b c } -> #\'(a b c)'))
464 return '\\key %s;' % string.lower (match.group (1))
466 str = re.sub ("\\\\key ([^;]+);", replace, str)
469 conversions.append (((1,3,39), conv, '\\key A ; ->\\key a;'))
473 if re.search ('\\[:',str):
474 sys.stderr.write ('\nNot smart enough to convert to new tremolo format')
477 conversions.append (((1,3,41), conv,
478 '[:16 c4 d4 ] -> \\repeat "tremolo" 2 { c16 d16 }'))
482 str = re.sub ('Staff_margin_engraver' , 'Instrument_name_engraver', str)
485 conversions.append (((1,3,42), conv,
486 'Staff_margin_engraver deprecated, use Instrument_name_engraver'))
490 str = re.sub ('note[hH]eadStyle\\s*=\\s*"?(\\w+)"?' , "noteHeadStyle = #'\\1", str)
493 conversions.append (((1,3,49), conv,
494 'noteHeadStyle value: string -> symbol'))
498 if re.search ('\\\\keysignature', str):
499 sys.stderr.write ('\nNot smart enough to convert to new tremolo format')
503 conversions.append (((1,3,58), conv,
504 'noteHeadStyle value: string -> symbol'))
508 str = re.sub (r"""\\key *([a-z]+) *;""", r"""\\key \1 \major;""",str);
510 conversions.append (((1,3,59), conv,
511 '\key X ; -> \key X major; '))
515 str = re.sub (r'latexheaders *= *"\\\\input ',
519 conversions.append (((1,3,68), conv, 'latexheaders = "\\input global" -> latexheaders = "global"'))
524 # TODO: lots of other syntax change should be done here as well
527 str = re.sub ('basicCollisionProperties', 'NoteCollision', str)
528 str = re.sub ('basicVoltaSpannerProperties' , "VoltaBracket", str)
529 str = re.sub ('basicKeyProperties' , "KeySignature", str)
531 str = re.sub ('basicClefItemProperties' ,"Clef", str)
534 str = re.sub ('basicLocalKeyProperties' ,"Accidentals", str)
535 str = re.sub ('basicMarkProperties' ,"Accidentals", str)
536 str = re.sub ('basic([A-Za-z_]+)Properties', '\\1', str)
538 str = re.sub ('Repeat_engraver' ,'Volta_engraver', str)
541 conversions.append (((1,3,92), conv, 'basicXXXProperties -> XXX, Repeat_engraver -> Volta_engraver'))
545 # Ugh, but meaning of \stemup changed too
546 # maybe we should do \stemup -> \stemUp\slurUp\tieUp ?
547 str = re.sub ('\\\\stemup', '\\\\stemUp', str)
548 str = re.sub ('\\\\stemdown', '\\\\stemDown', str)
549 str = re.sub ('\\\\stemboth', '\\\\stemBoth', str)
551 str = re.sub ('\\\\slurup', '\\\\slurUp', str)
552 str = re.sub ('\\\\slurboth', '\\\\slurBoth', str)
553 str = re.sub ('\\\\slurdown', '\\\\slurDown', str)
554 str = re.sub ('\\\\slurdotted', '\\\\slurDotted', str)
555 str = re.sub ('\\\\slurnormal', '\\\\slurNoDots', str)
557 str = re.sub ('\\\\shiftoff', '\\\\shiftOff', str)
558 str = re.sub ('\\\\shifton', '\\\\shiftOn', str)
559 str = re.sub ('\\\\shiftonn', '\\\\shiftOnn', str)
560 str = re.sub ('\\\\shiftonnn', '\\\\shiftOnnn', str)
562 str = re.sub ('\\\\onevoice', '\\\\oneVoice', str)
563 str = re.sub ('\\\\voiceone', '\\\\voiceOne', str)
564 str = re.sub ('\\\\voicetwo', '\\\\voiceTwo', str)
565 str = re.sub ('\\\\voicethree', '\\\\voiceThree', str)
566 str = re.sub ('\\\\voicefour', '\\\\voiceFour', str)
568 # I don't know exactly when these happened...
569 # ugh, we loose context setting here...
570 str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\stemUp\\\\slurUp\\\\tieUp', str)
571 str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\stemDown\\\\slurDown\\\\tieDown', str)
572 str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\stemBoth\\\\slurBoth\\\\tieBoth', str)
574 str = re.sub ('verticalDirection[^=]*= *#?"?(1|(\\\\up))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #1', str)
575 str = re.sub ('verticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #-1', str)
576 str = re.sub ('verticalDirection[^=]*= *#?"?(0|(\\\\center))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #0', str)
578 str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\\\1Up', str)
579 str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\\\1Down', str)
580 str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\\\1Both', str)
582 # (lacks capitalisation slur -> Slur)
583 str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\1 \\\\override #\'direction = #1', str)
584 str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\1 \\override #\'direction = #-1', str)
585 str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\1 \\\\override #\'direction = #0', str)
588 str = re.sub ('\\\\property *[^ .]*[.]?dynamicDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\dynamicUp', str)
589 str = re.sub ('\\\\property *[^ .]*[.]?dyn[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\dynamicDown', str)
590 str = re.sub ('\\\\property *[^ .]*[.]?dyn[^=]*= *#?"?(0|(\\\\center))"?', '\\\\dynamicBoth', str)
592 str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)Dash[^=]*= *#?"?(0|(""))"?', '\\\\\\1NoDots', str)
593 str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)Dash[^=]*= *#?"?([1-9]+)"?', '\\\\\\1Dotted', str)
595 str = re.sub ('\\\\property *[^ .]*[.]?noAutoBeaming[^=]*= *#?"?(0|(""))"?', '\\\\autoBeamOn', str)
596 str = re.sub ('\\\\property *[^ .]*[.]?noAutoBeaming[^=]*= *#?"?([1-9]+)"?', '\\\\autoBeamOff', str)
602 conversions.append (((1,3,93), conv,
603 'property definiton case (eg. onevoice -> oneVoice)'))
608 str = re.sub ('ChordNames*', 'ChordNames', str)
609 if re.search ('\\\\textscript "[^"]* *"[^"]*"', str):
610 sys.stderr.write ('\nNot smart enough to convert to new \\textscript markup text')
612 str = re.sub ('\\textscript +("[^"]*")', '\\textscript #\\1', str)
616 conversions.append (((1,3,97), conv, 'ChordName -> ChordNames'))
619 # TODO: add lots of these
623 str = re.sub ('\\\\property *"?Voice"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Voice.TextScript \\\\set #\'font-style = #\'\\1', str)
624 str = re.sub ('\\\\property *"?Lyrics"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Lyrics.LyricText \\\\set #\'font-style = #\'\\1', str)
626 str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?timeSignatureStyle"? *= *"([^"]*)"', '\\\\property \\1.TimeSignature \\\\override #\'style = #\'\\2', str)
628 str = re.sub ('"?timeSignatureStyle"? *= *#?""', 'TimeSignature \\\\override #\'style = ##f', str)
630 str = re.sub ('"?timeSignatureStyle"? *= *#?"([^"]*)"', 'TimeSignature \\\\override #\'style = #\'\\1', str)
632 str = re.sub ('#\'style *= #*"([^"])"', '#\'style = #\'\\1', str)
634 str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?horizontalNoteShift"? *= *"?#?([-0-9]+)"?', '\\\\property \\1.NoteColumn \\\\override #\'horizontal-shift = #\\2', str)
637 str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *""', '\\\\property \\1.Stem \\\\override #\'flag-style = ##f', str)
639 str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *"([^"]*)"', '\\\\property \\1.Stem \\\\override #\'flag-style = #\'\\2', str)
642 conversions.append (((1,3,98), conv, 'CONTEXT.textStyle -> GROB.#font-style '))
646 str = re.sub ('"?beamAutoEnd_([0-9]*)"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(end 1 \\1 * *) = \\2', str)
647 str = re.sub ('"?beamAutoBegin_([0-9]*)"? *= *(#\\([^)]*\))', 'autoBeamSettings \\push #\'(begin 1 \\1 * *) = \\2', str)
648 str = re.sub ('"?beamAutoEnd"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(end * * * *) = \\1', str)
649 str = re.sub ('"?beamAutoBegin"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(begin * * * *) = \\1', str)
654 conversions.append (((1,3,102), conv, 'beamAutoEnd -> autoBeamSettings \\push (end * * * *)'))
659 str = re.sub ('\\\\push', '\\\\override', str)
660 str = re.sub ('\\\\pop', '\\\\revert', str)
664 conversions.append (((1,3,111), conv, '\\push -> \\override, \\pop -> \\revert'))
668 str = re.sub ('LyricVoice', 'LyricsVoice', str)
670 str = re.sub ('Chord[Nn]ames*.Chord[Nn]ames*', 'ChordNames.ChordName', str)
671 str = re.sub ('Chord[Nn]ames([ \t\n]+\\\\override)', 'ChordName\\1', str)
674 conversions.append (((1,3,113), conv, 'LyricVoice -> LyricsVoice'))
676 def regularize_id (str):
683 elif x in string.digits:
684 x = chr(ord (x) - ord ('0') +ord ('A'))
685 elif x not in string.letters:
687 elif x in string.lowercase and lastx == '_':
696 def regularize_dollar_reference (match):
697 return regularize_id (match.group (1))
698 def regularize_assignment (match):
699 return '\n' + regularize_id (match.group (1)) + ' = '
700 str = re.sub ('\$([^\t\n ]+)', regularize_dollar_reference, str)
701 str = re.sub ('\n([^ \t\n]+)[ \t]*= *', regularize_assignment, str)
704 conversions.append (((1,3,117), conv, 'identifier names: $!foo_bar_123 -> xfooBarABC'))
709 def regularize_paper (match):
710 return regularize_id (match.group (1))
712 str = re.sub ('(paper_[a-z]+)', regularize_paper, str)
713 str = re.sub ('sustainup', 'sustainUp', str)
714 str = re.sub ('nobreak', 'noBreak', str)
715 str = re.sub ('sustaindown', 'sustainDown', str)
716 str = re.sub ('sostenutoup', 'sostenutoUp', str)
717 str = re.sub ('sostenutodown', 'sostenutoDown', str)
718 str = re.sub ('unachorda', 'unaChorda', str)
719 str = re.sub ('trechorde', 'treChorde', str)
723 conversions.append (((1,3,120), conv, 'paper_xxx -> paperXxxx, pedalup -> pedalUp.'))
727 str = re.sub ('drarnChords', 'chordChanges', str)
728 str = re.sub ('\\musicalpitch', '\\pitch', str)
731 conversions.append (((1,3,122), conv, 'drarnChords -> chordChanges, \\musicalpitch -> \\pitch'))
735 str = re.sub ('ly-([sg])et-elt-property', 'ly-\\1et-grob-property', str)
738 conversions.append (((1,3,136), conv, 'ly-X-elt-property -> ly-X-grob-property'))
742 str = re.sub ('point-and-click +#t', 'point-and-click line-column-location', str)
745 conversions.append (((1,3,138), conv, 'point-and-click argument changed to procedure.'))
749 str = re.sub ('followThread', 'followVoice', str)
750 str = re.sub ('Thread.FollowThread', 'Voice.VoiceFollower', str)
751 str = re.sub ('FollowThread', 'VoiceFollower', str)
754 conversions.append (((1,3,138), conv, 'followThread -> followVoice.'))
758 str = re.sub ('font-point-size', 'font-design-size', str)
761 conversions.append (((1,3,139), conv, 'font-point-size -> font-design-size.'))
765 str = re.sub ('([a-zA-Z]*)NoDots', '\\1Solid', str)
768 conversions.append (((1,3,141), conv, 'xNoDots -> xSolid'))
772 str = re.sub ('([Cc])hord([ea])', '\\1ord\\2', str)
775 conversions.append (((1,3,144), conv, 'Chorda -> Corda'))
780 str = re.sub ('([A-Za-z]+)MinimumVerticalExtent', 'MinimumV@rticalExtent', str)
781 str = re.sub ('([A-Za-z]+)ExtraVerticalExtent', 'ExtraV@rticalExtent', str)
782 str = re.sub ('([A-Za-z]+)VerticalExtent', 'VerticalExtent', str)
783 str = re.sub ('ExtraV@rticalExtent', 'ExtraVerticalExtent', str)
784 str = re.sub ('MinimumV@rticalExtent', 'MinimumVerticalExtent', str)
787 conversions.append (((1,3,145), conv,
788 'ContextNameXxxxVerticalExtent -> XxxxVerticalExtent'))
792 str = re.sub ('\\\\key[ \t]*;', '\\key \\default;', str)
793 str = re.sub ('\\\\mark[ \t]*;', '\\mark \\default;', str)
795 # Make sure groups of more than one ; have space before
796 # them, so that non of them gets removed by next rule
797 str = re.sub ("([^ \n\t;]);(;+)", "\\1 ;\\2", str)
799 # Only remove ; that are not after spaces, # or ;
800 # Otherwise we interfere with Scheme comments,
801 # which is badbadbad.
802 str = re.sub ("([^ \t;#]);", "\\1", str)
805 conversions.append (((1,3,146), conv, 'semicolons removed'))
809 str = re.sub ('default-neutral-direction', 'neutral-direction',str)
811 conversions.append (((1,3,147), conv, 'default-neutral-direction -> neutral-direction'))
815 str = re.sub ('\(align', '(axis', str)
816 str = re.sub ('\(rows', '(columns', str)
818 conversions.append (((1,3,148), conv, '"(align" -> "(axis", "(rows" -> "(columns"'))
823 str = re.sub ('SystemStartDelimiter', 'systemStartDelimiter', str)
825 conversions.append (((1,5,33), conv, 'SystemStartDelimiter -> systemStartDelimiter'))
829 str = re.sub ('arithmetic-multiplier', 'spacing-increment', str)
830 str = re.sub ('arithmetic-basicspace', 'shortest-duration-space', str)
833 conversions.append (((1,5,38), conv, 'SystemStartDelimiter -> systemStartDelimiter'))
841 "Instrument_name": "instrument-name",
842 "Left_edge_item": "left-edge",
843 "Span_bar": "span-bar",
844 "Breathing_sign": "breathing-sign",
845 "Staff_bar": "staff-bar",
847 "Key_item": "key-signature",
848 "Time_signature": "time-signature",
851 props = match.group (1)
852 for (k,v) in break_dict.items():
853 props = re.sub (k, v, props)
854 return "breakAlignOrder = #'(%s)" % props
856 str = re.sub ("breakAlignOrder *= *#'\\(([a-z_\n\tA-Z ]+)\\)",
861 conversions.append (((1,5,40), conv, 'breakAlignOrder property names'))
866 str = re.sub ('noAutoBeaming *= *##f', 'autoBeaming = ##t', str)
867 str = re.sub ('noAutoBeaming *= *##t', 'autoBeaming = ##f', str)
870 conversions.append (((1,5,49), conv, 'noAutoBeaming -> autoBeaming'))
874 str = re.sub ('tuplet-bracket-visibility', 'bracket-visibility', str)
875 str = re.sub ('tuplet-number-visibility', 'number-visibility', str)
878 conversions.append (((1,5,52), conv, 'tuplet-X-visibility -> X-visibility'))
882 str = re.sub ('Pitch::transpose', 'ly-transpose-pitch', str)
886 conversions.append (((1,5,56), conv, 'Pitch::transpose -> ly-transpose-pitch'))
890 str = re.sub ('textNonEmpty *= *##t', "TextScript \\set #'no-spacing-rods = ##f", str)
891 str = re.sub ('textNonEmpty *= *##f', "TextScript \\set #'no-spacing-rods = ##t", str)
894 conversions.append (((1,5,58), conv, 'deprecate textNonEmpty'))
899 str = re.sub ('MinimumVerticalExtent', 'minimumV@rticalExtent', str)
900 str = re.sub ('minimumVerticalExtent', 'minimumV@rticalExtent', str)
901 str = re.sub ('ExtraVerticalExtent', 'extraV@rticalExtent', str)
902 str = re.sub ('extraVerticalExtent', 'extraV@rticalExtent', str)
903 str = re.sub ('VerticalExtent', 'verticalExtent', str)
904 str = re.sub ('extraV@rticalExtent', 'extraVerticalExtent', str)
905 str = re.sub ('minimumV@rticalExtent', 'minimumVerticalExtent', str)
908 conversions.append (((1,5,59), conv,
909 'XxxxVerticalExtent -> xxxVerticalExtent'))
913 str = re.sub ('visibility-lambda', 'break-visibility', str)
916 conversions.append (((1,5,62), conv,
917 'visibility-lambda -> break-visibility'))
922 if re.search (r'\addlyrics',str) \
923 and re.search ('automaticMelismata', str) == None:
924 sys.stderr.write ('automaticMelismata is turned on by default since 1.5.67. Please fix this by hand.')
925 raise FatalConversionError()
928 conversions.append (((1,5,67), conv,
929 'automaticMelismata turned on by default'))
933 str = re.sub ('ly-set-grob-property([^!])', 'ly-set-grob-property!\1', str)
934 str = re.sub ('ly-set-mus-property([^!])', 'ly-set-mus-property!\1', str)
937 conversions.append (((1,5,68), conv, 'ly-set-X-property -> ly-set-X-property!'))
941 str = re.sub ('extent-X', 'X-extent', str)
942 str = re.sub ('extent-Y', 'Y-extent', str)
945 conversions.append (((1,5,71), conv, 'extent-[XY] -> [XY]-extent'))
950 str = re.sub ("""#\(set! +point-and-click +line-column-location\)""",
951 """#(set-point-and-click! \'line-column)""", str)
952 str = re.sub ("""#\(set![ \t]+point-and-click +line-location\)""",
953 '#(set-point-and-click! \'line)', str)
954 str = re.sub ('#\(set! +point-and-click +#f\)',
955 '#(set-point-and-click! \'none)', str)
958 conversions.append (((1,5,72), conv, 'set! point-and-click -> set-point-and-click!'))
963 str = re.sub ('flag-style', 'stroke-style', str)
964 str = re.sub (r"""Stem([ ]+)\\override #'style""", r"""Stem \\override #'flag-style""", str);
965 str = re.sub (r"""Stem([ ]+)\\set([ ]+)#'style""", r"""Stem \\set #'flag-style""", str);
968 conversions.append (((1,6,5), conv, 'Stems: flag-style -> stroke-style; style -> flag-style'))
972 def subst_req_name (match):
973 return "(make-music-by-name \'%sEvent)" % regularize_id (match.group(1))
976 str = re.sub ('\\(ly-make-music *\"([A-Z][a-z_]+)_req\"\\)', subst_req_name, str)
977 str = re.sub ('Request_chord', 'EventChord', str)
980 conversions.append (((1,7,1), conv, 'ly-make-music foo_bar_req -> make-music-by-name FooBarEvent'))
985 "text" : 'TextSpanEvent',
986 "decrescendo" : 'DecrescendoEvent',
987 "crescendo" : 'CrescendoEvent',
988 "Sustain" : 'SustainPedalEvent',
989 "slur" : 'SlurEvent',
990 "UnaCorda" : 'UnaCordaEvent',
991 "Sostenuto" : 'SostenutoEvent',
993 def subst_ev_name (match):
995 if re.search ('start', match.group(1)):
998 mtype = spanner_subst[match.group(2)]
999 return "(make-span-event '%s %s)" % (mtype , stype)
1001 def subst_definition_ev_name(match):
1002 return ' = #%s' % subst_ev_name (match)
1003 def subst_inline_ev_name (match):
1004 s = subst_ev_name (match)
1005 return '#(ly-export %s)' % s
1006 def subst_csp_definition (match):
1007 return ' = #(make-event-chord (list %s))' % subst_ev_name (match)
1008 def subst_csp_inline (match):
1009 return '#(ly-export (make-event-chord (list %s)))' % subst_ev_name (match)
1012 str = re.sub (r' *= *\\spanrequest *([^ ]+) *"([^"]+)"', subst_definition_ev_name, str)
1013 str = re.sub (r'\\spanrequest *([^ ]+) *"([^"]+)"', subst_inline_ev_name, str)
1014 str = re.sub (r' *= *\\commandspanrequest *([^ ]+) *"([^"]+)"', subst_csp_definition, str)
1015 str = re.sub (r'\\commandspanrequest *([^ ]+) *"([^"]+)"', subst_csp_inline, str)
1016 str = re.sub (r'ly-id ', 'ly-import ', str)
1018 str = re.sub (r' *= *\\script "([^"]+)"', ' = #(make-articulation "\\1")', str)
1019 str = re.sub (r'\\script "([^"]+)"', '#(ly-export (make-articulation "\\1"))', str)
1022 conversions.append (((1,7,2), conv, '\\spanrequest -> #(make-span-event .. ), \script -> #(make-articulation .. )'))
1026 str = re.sub (r'\(ly-', '(ly:', str)
1036 'music-duration-length',
1038 'duration-dotcount',
1041 'transpose-key-alist',
1045 'set-point-and-click!',
1054 'music-duration-compress',
1055 'set-point-and-click!'
1058 origre = r'\b(%s)' % string.join (changed, '|')
1060 str = re.sub (origre, r'ly:\1',str)
1061 str = re.sub ('set-point-and-click!', 'set-point-and-click', str)
1065 conversions.append (((1,7,3), conv, 'ly- -> ly:'))
1069 if re.search ('new-chords-done',str):
1072 str = re.sub (r'<<', '< <', str)
1073 str = re.sub (r'>>', '> >', str)
1076 conversions.append (((1,7,4), conv, '<< >> -> < < > >'))
1080 str = re.sub (r"\\transpose", r"\\transpose c'", str)
1081 str = re.sub (r"\\transpose c' *([a-z]+)'", r"\\transpose c \1", str)
1083 conversions.append (((1,7,5), conv, '\\transpose TO -> \\transpose FROM TO'))
1101 origstr = string.join (kws, '|')
1102 str = re.sub (r'([^_^-])\\(%s)\b' % origstr, r'\1-\\\2', str)
1104 conversions.append (((1,7,6), conv, 'note\\script -> note-\script'))
1109 str = re.sub (r"\\property *ChordNames *\. *ChordName *\\(set|override) *#'style *= *#('[a-z]+)",
1110 r"#(set-chord-name-style \2)", str)
1111 str = re.sub (r"\\property *ChordNames *\. *ChordName *\\revert *#'style",
1114 conversions.append (((1,7,10), conv, "\property ChordName #'style -> #(set-chord-name-style 'style)"))
1120 str = re.sub (r"ly:transpose-pitch", "ly:pitch-transpose", str)
1123 conversions.append (((1,7,11), conv, "transpose-pitch -> pitch-transpose"))
1127 str = re.sub (r"ly:get-molecule-extent", "ly:molecule-get-extent", str)
1128 str = re.sub (r"ly:set-molecule-extent!", "ly:molecule-set-extent!", str)
1129 str = re.sub (r"ly:add-molecule", "ly:molecule-add", str)
1130 str = re.sub (r"ly:combine-molecule-at-edge", "ly:molecule-combine-at-edge", str)
1131 str = re.sub (r"ly:align-to!", "ly:molecule-align-to!", str)
1135 conversions.append (((1,7,13), conv, "ly:XX-molecule-YY -> ly:molecule-XX-YY"))
1139 str = re.sub (r"linewidth *= *-[0-9.]+ *(\\mm|\\cm|\\in|\\pt)?", 'raggedright = ##t', str )
1142 conversions.append (((1,7,15), conv, "linewidth = -1 -> raggedright = ##t"))
1146 str = re.sub ("divisiomaior",
1147 "divisioMaior", str)
1148 str = re.sub ("divisiominima",
1149 "divisioMinima", str)
1150 str = re.sub ("divisiomaxima",
1151 "divisioMaxima", str)
1154 conversions.append (((1,7,16), conv, "divisiomaior -> divisioMaior"))
1158 str = re.sub ("Skip_req_swallow_translator",
1159 "Skip_event_swallow_translator", str)
1162 conversions.append (((1,7,17), conv, "Skip_req -> Skip_event"))
1166 str = re.sub ("groupOpen",
1168 str = re.sub ("groupClose",
1170 str = re.sub ("#'outer",
1171 "#'enclose-bounds", str)
1175 conversions.append (((1,7,18), conv,
1176 """groupOpen/Close -> start/stopGroup,
1177 #'outer -> #'enclose-bounds
1182 if re.search( r'\\GraceContext', str):
1183 sys.stderr.write ("GraceContext has been removed")
1184 sys.stderr.write ("please use #(add-to-grace-init .. )")
1185 raise FatalConversionError()
1187 str = re.sub ('HaraKiriStaffContext', 'RemoveEmptyStaffContext', str)
1190 conversions.append (((1,7,19), conv,"remove GraceContext"))
1197 r"(set|override|revert) *#'type",
1202 conversions.append (((1,7,22), conv,"#'type -> #'style"))
1207 "barNonAuto *= *##t",
1208 "automaticBars = ##f",
1211 "barNonAuto *= *##f",
1212 "automaticBars = ##t",
1216 conversions.append (((1,7,23), conv,"barNonAuto -> automaticBars"))
1221 if re.search( r'-(start|stop)Cluster', str):
1222 sys.stderr.write ("""Cluster syntax has been changed.
1223 Please refer to the manual for details, and convert manually.
1226 raise FatalConversionError()
1230 conversions.append (((1,7,24), conv,"cluster syntax"))
1234 str = re.sub (r"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\(override|set) *#'pedal-type *",
1235 r"\property Staff.pedal\1Style ", str)
1236 str = re.sub (r"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\revert *#'pedal-type", '', str)
1239 conversions.append (((1,7,28), conv,"new Pedal style syntax"))
1248 origstr = '<%s>' % str
1249 if re.search (r'\\\\', str):
1252 if re.search (r'\\property', str):
1255 if re.match (r'^\s*\)?\s*\\[a-zA-Z]+', str):
1259 def sub_durs (m, durs = durs):
1260 durs.append(m.group(2))
1263 str = re.sub (r"([a-z]+[,'!? ]*)([0-9]+\.*)", sub_durs, str)
1270 return '<%s>' % m.group (1)
1277 while last_str <> str:
1280 def sub_tremolos (m, slur_strs = slur_strs):
1282 if tr not in slur_strs:
1283 slur_strs.append (tr)
1286 str = re.sub (r"([a-z]+[',!? ]*)(:[0-9]+)",
1289 def sub_dyn_end (m, dyns = dyns):
1291 return ' ' + m.group(2)
1293 str = re.sub (r'(\\!)\s*([a-z]+)', sub_dyn_end, str)
1294 def sub_slurs(m, slur_strs = slur_strs):
1295 if '-)' not in slur_strs:
1296 slur_strs.append (')')
1299 def sub_p_slurs(m, slur_strs = slur_strs):
1300 if '-\)' not in slur_strs:
1301 slur_strs.append ('\)')
1304 str = re.sub (r"\)[ ]*([a-z]+)", sub_slurs, str)
1305 str = re.sub (r"\\\)[ ]*([a-z]+)", sub_p_slurs, str)
1306 def sub_begin_slurs(m, slur_strs = slur_strs):
1307 if '-(' not in slur_strs:
1308 slur_strs.append ('(')
1311 str = re.sub (r"([a-z]+[,'!?0-9 ]*)\(",
1312 sub_begin_slurs, str)
1313 def sub_begin_p_slurs(m, slur_strs = slur_strs):
1314 if '-\(' not in slur_strs:
1315 slur_strs.append ('\(')
1318 str = re.sub (r"([a-z]+[,'!?0-9 ]*)\\\(",
1319 sub_begin_p_slurs, str)
1321 def sub_dyns (m, slur_strs = slur_strs):
1323 if s == '@STARTCRESC@':
1324 slur_strs.append ("\\<")
1325 elif s == '@STARTDECRESC@':
1326 slur_strs.append ("\\>")
1328 slur_strs.append ('\\!')
1331 str = re.sub (r'@STARTCRESC@', sub_dyns, str)
1332 str = re.sub (r'-?\\!', sub_dyns, str)
1334 def sub_articulations (m, slur_strs = slur_strs):
1336 if a not in slur_strs:
1337 slur_strs.append (a)
1340 str = re.sub (r"([_^-]\@ACCENT\@)", sub_articulations,
1342 str = re.sub (r"([_^-]\\[a-z]+)", sub_articulations,
1344 str = re.sub (r"([_^-][>_.+|^-])", sub_articulations,
1346 str = re.sub (r'([_^-]"[^"]+")', sub_articulations,
1349 def sub_pslurs(m, slur_strs = slur_strs):
1350 slur_strs.append (' \\)')
1352 str = re.sub (r"\\\)[ ]*([a-z]+)", sub_pslurs, str)
1356 suffix = string.join (slur_strs, '') + string.join (pslur_strs,
1358 + string.join (dyns, '')
1360 return '@STARTCHORD@%s@ENDCHORD@%s%s' % (str , dur_str, suffix)
1364 def sub_chords (str):
1369 marker_str = '%% new-chords-done %%'
1371 if re.search (marker_str,str):
1373 str = re.sub ('<<', '@STARTCHORD@', str)
1374 str = re.sub ('>>', '@ENDCHORD@', str)
1376 str = re.sub (r'\\<', '@STARTCRESC@', str)
1377 str = re.sub (r'\\>', '@STARTDECRESC@', str)
1378 str = re.sub (r'([_^-])>', r'\1@ACCENT@', str)
1379 str = re.sub (r'<([^<>{}]+)>', sub_chord, str)
1381 # add dash: -[, so that [<<a b>> c d] becomes
1383 # and gets skipped by articulation_substitute
1384 str = re.sub (r'\[ *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)',
1386 str = re.sub (r'\\! *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)',
1389 str = re.sub (r'<([^?])', r'%s\1' % simstart, str)
1390 str = re.sub (r'>([^?])', r'%s\1' % simend, str)
1391 str = re.sub ('@STARTCRESC@', r'\\<', str)
1392 str = re.sub ('@STARTDECRESC@', r'\\>' ,str)
1393 str = re.sub (r'\\context *Voice *@STARTCHORD@',
1394 '@STARTCHORD@', str)
1395 str = re.sub ('@STARTCHORD@', chordstart, str)
1396 str = re.sub ('@ENDCHORD@', chordend, str)
1397 str = re.sub (r'@ACCENT@', '>', str)
1400 def text_markup (str):
1401 str = re.sub (r"""([-_^]) *# *' *\( *music *(\"[^"]*\") *\)""",
1402 r"\1\\markup { \\musicglyph #\2 }", str)
1403 str = re.sub (r"""([-_^]) *# *' *\( *([a-z]+) *([^()]*)\)""",
1404 r"\1\\markup { \\\2 \3 }", str)
1405 str = re.sub (r"""\\mark *# *' *\( *music *(\"[^"]*\") *\)""",
1406 r"\\mark \\markup { \\musicglyph #\1 }", str)
1407 str = re.sub (r"""\\mark *# *' *\( *([a-z]+) *([^()]*)\)""",
1408 r"\\mark \\markup { \\\1 \2 }", str)
1411 def articulation_substitute (str):
1412 str = re.sub (r"""([^-])\[ *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
1414 str = re.sub (r"""([^-])\\\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
1416 str = re.sub (r"""([^-\\])\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
1418 str = re.sub (r"""([^-])\\! *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
1422 def conv_relative(str):
1423 if re.search (r"\\relative", str):
1424 str= "#(ly:set-option 'old-relative)\n" + str
1429 str = re.sub (r"#'\(\)", "@SCM_EOL@", str)
1430 str = conv_relative (str)
1431 str = sub_chords (str)
1433 str = text_markup (str)
1434 str = articulation_substitute (str)
1435 str = re.sub ("@SCM_EOL@", "#'()", str)
1439 conversions.append (((1,9,0), conv, """New relative mode,
1440 Postfix articulations, new text markup syntax, new chord syntax."""))
1444 if re.search ("font-style",str):
1445 sys.stderr.write ("font-style is deprecated. Please remove.")
1446 raise FatalConversionError()
1448 str = re.sub (r'-\\markup', r'@\\markup', str)
1449 str = re.sub (r'-\\', r'\\', str)
1450 str = re.sub (r'-\)', ')', str)
1451 str = re.sub (r'-\(', '(', str)
1452 str = re.sub ('-\[', '[', str)
1453 str = re.sub ('-\]', ']', str)
1454 str = re.sub ('-~', '~', str)
1455 str = re.sub (r'@\\markup', r'-\\markup', str)
1458 conversions.append (((1,9,1), conv, """Remove - before articulation"""))
1461 str = re.sub ('ly:set-context-property',
1462 'ly:set-context-property!', str)
1463 str = re.sub ('\\\\newcontext', '\\\\new', str)
1464 str = re.sub ('\\\\grace[\t\n ]*([^{ ]+)',
1465 r'\\grace { \1 }', str)
1466 str = re.sub ("\\\\grace[\t\n ]*{([^}]+)}",
1468 \\property Voice.Stem \\override #'stroke-style = #"grace"
1470 \\property Voice.Stem \\revert #'stroke-style }
1475 conversions.append (((1,9,2), conv, """\\newcontext -> \\new"""))
1479 str = re.sub ('accacciatura',
1480 'acciaccatura', str)
1482 if re.search ("context-spec-music", str):
1483 sys.stderr.write ("context-spec-music takes a symbol for the context now. Update by hand.")
1485 raise FatalConversionError()
1487 str = re.sub ('fingerHorizontalDirection *= *#(LEFT|-1)',
1488 "fingeringOrientations = #'(up down left)", str)
1489 str = re.sub ('fingerHorizontalDirection *= *#(RIGHT|1)',
1490 "fingeringOrientations = #'(up down right)", str)
1494 conversions.append (((1,9,3), conv,
1495 """\\acciaccatura misspelling, fingerHorizontalDirection -> fingeringOrientations"""))
1499 if re.search ('\\figures', str):
1500 sys.stderr.write ("Warning: attempting automatic \\figures conversion. Check results!");
1503 def figures_replace (m):
1505 s = re.sub ('<', '@FIGOPEN@',s)
1506 s = re.sub ('>', '@FIGCLOSE@',s)
1507 return '\\figures { %s }' % s
1509 str = re.sub (r'\\figures[ \t\n]*{([^}]+)}', figures_replace, str)
1510 str = re.sub (r'\\<', '@STARTCRESC@', str)
1511 str = re.sub (r'\\>', '@STARTDECRESC@', str)
1512 str = re.sub (r'([-^_])>', r'\1@ACCENT@', str)
1513 str = re.sub (r'<<', '@STARTCHORD@', str)
1514 str = re.sub (r'>>', '@ENDCHORD@', str)
1515 str = re.sub (r'>', '@ENDSIMUL@', str)
1516 str = re.sub (r'<', '@STARTSIMUL@', str)
1517 str = re.sub ('@STARTDECRESC@', '\\>', str)
1518 str = re.sub ('@STARTCRESC@', '\\<', str)
1519 str = re.sub ('@ACCENT@', '>', str)
1520 str = re.sub ('@ENDCHORD@', '>', str)
1521 str = re.sub ('@STARTCHORD@', '<', str)
1522 str = re.sub ('@STARTSIMUL@', '<<', str)
1523 str = re.sub ('@ENDSIMUL@', '>>', str)
1524 str = re.sub ('@FIGOPEN@', '<', str)
1525 str = re.sub ('@FIGCLOSE@', '>', str)
1529 conversions.append (((1,9,4), conv, 'Swap < > and << >>'))
1533 str = re.sub ('HaraKiriVerticalGroup', 'RemoveEmptyVerticalGroup', str)
1537 conversions.append (((1,9,5), conv, 'HaraKiriVerticalGroup -> RemoveEmptyVerticalGroup'))
1540 if re.search ("ly:get-font", str) :
1541 sys.stderr.write (r"(ly:get-font foo ..) has been replaced by" + \
1542 " (ly:paper-get-font (ly:grob-get-paper foo) .. ).\n" +\
1543 "please update manually.")
1545 raise FatalConversionError()
1547 if re.search ("\\pitch *#", str) :
1548 sys.stderr.write (r"\\pitch has been deprecated. " +\
1549 " Use Scheme code to construct arbitrary note events.")
1551 raise FatalConversionError()
1556 conversions.append (((1,9,6), conv, 'ly:get-font deprecated.'))
1559 def sub_alteration (m):
1563 '-2': 'DOUBLE-FLAT',
1566 '2': 'DOUBLE-SHARP',
1569 return '(ly:make-pitch %s %s %s)' % (m.group(1), m.group (2),
1572 str =re.sub ("\\(ly:make-pitch *([0-9-]+) *([0-9-]+) *([0-9-]+) *\\)",
1573 sub_alteration, str)
1576 str = re.sub ("ly:verbose", "ly:get-option 'verbose", str)
1578 m= re.search ("\\\\outputproperty #([^#]+)[\t\n ]*#'([^ ]+)", str)
1581 r"""\outputproperty found,
1582 Please hand-edit, using
1584 \applyoutput #(outputproperty-compatibility %s '%s <GROB PROPERTY VALUE>)
1586 as a substitution text.""" % (m.group (1), m.group (2)) )
1587 raise FatalConversionError ()
1589 if re.search ("ly:(make-pitch|pitch-alteration)", str) \
1590 or re.search ("keySignature", str):
1592 """The alteration field of Scheme pitches was multiplied by 2
1593 to support quarter tone accidentals. You have to edit the following constructs by hand:
1595 * calls of ly:make-pitch and ly:pitch-alteration
1596 * keySignature settings made with \property
1598 raise FatalConversionError ()
1601 conversions.append (((1,9,7), conv,
1602 '''use symbolic constants for alterations,
1603 remove \\outputproperty, move ly:verbose into ly:get-option'''))
1607 if re.search ("dash-length",str):
1608 sys.stderr.write ("""dash-length has been removed. Use dash-fraction instead.""")
1609 raise FatalConversionError()
1612 conversions.append (((1,9,8), conv, """dash-length -> dash-fraction"""))
1617 return "#'font-size = #%d" % (2*string.atoi (match.group (1)))
1619 str =re.sub (r"#'font-relative-size\s*=\s*#\+?([0-9-]+)", func, str)
1620 str =re.sub (r"#'font-family\s*=\s*#'ancient",
1621 r"#'font-family = #'music", str)
1625 conversions.append (((2,1,1), conv, """font-relative-size -> font-size"""))
1628 str =re.sub (r"ly:get-music-length", "ly:music-length", str)
1631 conversions.append (((2,1,2), conv, """ly:get-music-length -> ly:music-length"""))
1634 str =re.sub (r"\.\s+stz=", ". instr ", str)
1637 conversions.append (((2,1,3), conv, """stanza -> instrument"""))
1648 return r" \property %s.melismaBusyProperties \unset" % c
1650 return r"\property %s.melismaBusyProperties = #'(melismaBusy)" % c
1652 str = re.sub (r"\\property ([a-zA-Z]+)\s*\.\s*automaticMelismata\s*=\s*##([ft])", func, str)
1655 conversions.append (((2,1,4), conv, """removal of automaticMelismata; use melismaBusyProperties instead."""))
1660 str =re.sub (r"\\translator\s+([a-zA-Z]+)", r"\\change \1", str)
1663 conversions.append (((2,1,7), conv, """\\translator Staff -> \\change Staff"""))
1666 str =re.sub (r"\\newaddlyrics", r"\\lyricsto", str)
1669 conversions.append (((2,1,10), conv, """\\newaddlyrics -> \\lyricsto"""))
1672 str = re.sub (r'\\include\s*"paper([0-9]+)(-init)?.ly"',
1673 r"#(set-staff-size \1)", str)
1675 def sub_note (match):
1677 log = string.atoi (match.group (1))
1678 dots = string.atoi (match.group (2))
1681 dur = '%d' % (1 << log)
1683 dur = { -1 : 'breve',
1689 return r'\note #"%s" #%s' % (dur, match.group (3))
1691 str = re.sub (r'\\note\s+#([0-9-]+)\s+#([0-9]+)\s+#([0-9.-]+)',
1695 conversions.append (((2,1,11), conv, """\\include "paper16.ly" -> #(set-staff-size 16)
1696 \\note #3 #1 #1 -> \\note #"8." #1
1701 str =re.sub (r"OttavaSpanner", r"OttavaBracket", str)
1704 conversions.append (((2,1,12), conv, """OttavaSpanner -> OttavaBracket"""))
1708 str =re.sub (r"\(set-staff-size ", r"(set-global-staff-size ", str)
1711 conversions.append (((2,1,13), conv, """set-staff-size -> set-global-staff-size"""))
1714 str =re.sub (r"#'style\s*=\s*#'dotted-line",
1715 r"#'dash-fraction = #0.0 ", str)
1718 conversions.append (((2,1,14), conv, """style = dotted -> dash-fraction = 0"""))
1721 str =re.sub (r'LyricsVoice\s*\.\s*instrument\s*=\s*("[^"]*")',
1722 r'LyricsVoice . vocalName = \1', str)
1724 str =re.sub (r'LyricsVoice\s*\.\s*instr\s*=\s*("[^"]*")',
1725 r'LyricsVoice . vocNam = \1', str)
1728 conversions.append (((2,1,15), conv, """LyricsVoice . instr(ument) -> vocalName"""))
1742 return '\\%s' % d[m.group (1)]
1744 str = re.sub (r'\\musicglyph\s*#"accidentals-([0-9-]+)"',
1748 conversions.append (((2,1,16), conv, """\\musicglyph #"accidentals-NUM" -> \\sharp/flat/etc."""))
1753 if re.search (r'\\partcombine', str):
1754 sys.stderr.write ('Warning: \\partcombine has been changed. '
1755 +'Check conversion manually!')
1757 raise FatalConversionError()
1759 # this rule doesn't really work,
1760 # too lazy to figure out why.
1761 str = re.sub (r'\\context\s+Voice\s*=\s*one\s*\\partcombine\s+Voice\s*\\context\s+Thread\s*=\s*one(.*)\s*'
1762 + r'\\context\s+Thread\s*=\s*two',
1763 '\\\\newpartcombine\n\\1\n', str)
1768 conversions.append (((2,1,17), conv, """\\partcombine syntax change to \\newpartcombine"""))
1772 str = re.sub (r'\\newpartcombine', r'\\partcombine', str)
1773 str = re.sub (r'\\autochange\s+Staff', r'\\autochange ', str)
1776 conversions.append (((2,1,18), conv, """\\newpartcombine -> \\partcombine,
1777 \\autochange Staff -> \\autochange
1784 str = re.sub (r'\\include "drumpitch-init.ly"','', str)
1785 str = re.sub (r'\\pitchnames ','pitchnames = ', str)
1786 str = re.sub (r'\\chordmodifiers ','chordmodifiers = ', str)
1787 str = re.sub (r'\bdrums\b\s*=','drumContents = ', str)
1788 str = re.sub (r'\\drums\b','\\drumContents ', str)
1791 if re.search ('drums->paper', str):
1792 sys.stderr.write ("\nDrum notation found. Check file manually!")
1794 str = re.sub (r"""\\apply\s+#\(drums->paper\s+'([a-z]+)\)""",
1795 r"""\property DrumStaff.drumStyleTable = #\1-style""",
1798 if re.search ('Thread', str):
1799 sys.stderr.write ("\nThread found. Check file manually!\n");
1801 str = re.sub (r"""(\\once\s*)?\\property\s+Thread\s*\.\s*NoteHead\s*"""
1802 + r"""\\(set|override)\s*#'style\s*=\s*#'harmonic"""
1803 + r"""\s+([a-z]+[,'=]*)([0-9]*\.*)"""
1804 ,r"""<\3\\harmonic>\4""", str)
1806 str = re.sub (r"""\\new Thread""", """\context Voice""", str)
1807 str = re.sub (r"""Thread""", """Voice""", str)
1809 if re.search ('\bLyrics\b', str):
1810 sys.stderr.write ("\nLyrics found. Check file manually!\n");
1812 str = re.sub (r"""LyricsVoice""", r"""L@ricsVoice""", str)
1813 str = re.sub (r"""\bLyrics\b""", r"""LyricsVoice""", str)
1814 str = re.sub (r"""LyricsContext""", r"""LyricsVoiceContext""", str)
1815 str = re.sub (r"""L@ricsVoice""", r"""LyricsVoice""",str)
1820 conversions.append (((2,1,19), conv, """Drum notation changes, Removing \\chordmodifiers, \\notenames.
1821 Harmonic notes. Thread context removed. Lyrics context removed."""))
1824 str = re.sub (r'nonevent-skip', 'skip-music', str)
1827 conversions.append (((2,1,20), conv, """nonevent-skip -> skip-music""" ))
1830 str = re.sub (r'molecule-callback', 'print-function', str)
1831 str = re.sub (r'brew_molecule', 'print', str)
1832 str = re.sub (r'brew-new-markup-molecule', 'Text_item::print', str)
1833 str = re.sub (r'LyricsVoice', 'Lyrics', str)
1834 str = re.sub (r'tupletInvisible',
1835 r"TupletBracket \\set #'transparent", str)
1836 # str = re.sub (r'molecule', 'collage', str)
1837 #molecule -> collage
1838 str = re.sub (r"\\property\s+[a-zA-Z]+\s*\.\s*[a-zA-Z]+\s*"
1839 + r"\\set\s*#'X-extent-callback\s*=\s*#Grob::preset_extent",
1844 conversions.append (((2,1,21), conv, """molecule-callback -> print-function,
1845 brew_molecule -> print
1846 brew-new-markup-molecule -> Text_item::print
1847 LyricsVoice -> Lyrics
1848 tupletInvisible -> TupletBracket \set #'transparent
1849 Grob::preset_extent removed.
1854 str = re.sub (r'(\\property[^=]+)=\s*([-0-9]+)',
1856 str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\=]+)\s*\\(set|override)',
1857 r"\\overrid@ \1.\2 ", str)
1858 str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*=\s*',
1859 r'\\s@t \1.\2 = ', str)
1860 str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*\\unset',
1861 r'\\uns@t \1.\2 ', str)
1862 str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*\\revert'
1863 + r"\s*#'([-a-z0-9_]+)",
1864 r"\\rev@rt \1.\2 #'\3", str)
1865 str = re.sub (r'Voice\.', '', str)
1866 str = re.sub (r'Lyrics\.', '', str)
1867 str = re.sub (r'ChordNames\.', '', str)
1869 str = re.sub ('rev@rt', 'revert',str)
1870 str = re.sub ('s@t', 'set',str)
1871 str = re.sub ('overrid@', 'override',str)
1873 str = re.sub ('molecule', 'stencil', str)
1874 str = re.sub ('Molecule', 'Stencil', str)
1877 conversions.append (((2,1,22), conv, """new syntax for property settings:
1878 \\set A.B = #C , \\unset A.B
1879 \\override A.B #C = #D, \\revert A.B #C
1884 def subst_in_trans (match):
1886 s = re.sub (r'\s([a-zA-Z]+)\s*\\override',
1887 r' \\override \1', s)
1888 s = re.sub (r'\s([a-zA-Z]+)\s*\\set',
1889 r' \\override \1', s)
1890 s = re.sub (r'\s([a-zA-Z]+)\s*\\revert',
1893 str = re.sub (r'\\(translator|with)\s*{[^}]+}', subst_in_trans, str)
1897 context = m.group ('context')
1900 context = " '%s" % context[:-1] # -1: remove .
1904 d['context'] = context
1906 return r"""#(override-auto-beam-setting %(prop)s %(num)s %(den)s%(context)s)""" % d
1908 str = re.sub (r"""\\override\s*(?P<context>[a-zA-Z]+\s*\.\s*)?autoBeamSettings"""
1909 +r"""\s*#(?P<prop>[^=]+)\s*=\s*#\(ly:make-moment\s+(?P<num>\d+)\s+(?P<den>\d)\s*\)""",
1914 conversions.append (((2,1,23), conv, """Property setting syntax in \\translator{ }"""))
1916 str = re.sub (r'music-list\?', 'ly:music-list?', str)
1917 str = re.sub (r'\|\s*~', '~ |', str)
1920 conversions.append (((2,1,24), conv, """music-list? -> ly:music-list?"""))
1923 str = re.sub (r'ly:get-spanner-bound', 'ly:spanner-get-bound', str)
1924 str = re.sub (r'ly:get-extent', 'ly:grob-extent', str)
1925 str = re.sub (r'ly:get-system', 'ly:grob-system', str)
1926 str = re.sub (r'ly:get-original', 'ly:grob-original', str)
1927 str = re.sub (r'ly:get-parent', 'ly:grob-parent', str)
1928 str = re.sub (r'ly:get-broken-into', 'ly:spanner-broken-into', str)
1929 str = re.sub (r'Melisma_engraver', 'Melisma_translator', str)
1930 if re.search ("ly:get-paper-variable", str):
1931 sys.stderr.write ('use (ly:paper-lookup (ly:grob-paper ))')
1932 raise FatalConversionError()
1934 str = re.sub (r'\\defaultAccidentals', "#(set-accidental-style 'default)", str)
1935 str = re.sub (r'\\voiceAccidentals', "#(set-accidental-style 'voice)", str)
1936 str = re.sub (r'\\modernAccidentals', "#(set-accidental-style 'modern)", str)
1937 str = re.sub (r'\\modernCautionaries', "#(set-accidental-style 'modern-cautionary)", str)
1938 str = re.sub (r'\\modernVoiceAccidental', "#(set-accidental-style 'modern-voice)", str)
1939 str = re.sub (r'\\modernVoiceCautionaries', "#(set-accidental-style 'modern-voice-cautionary)", str)
1940 str = re.sub (r'\\pianoAccidentals', "#(set-accidental-style 'piano)", str)
1941 str = re.sub (r'\\pianoCautionaries', "#(set-accidental-style 'piano-cautionary)", str)
1942 str = re.sub (r'\\forgetAccidentals', "#(set-accidental-style 'forget)", str)
1943 str = re.sub (r'\\noResetKey', "#(set-accidental-style 'no-reset)", str)
1947 conversions.append (((2,1,25), conv, """Scheme grob function renaming"""))
1951 str = re.sub ('ly:set-grob-property!', 'ly:grob-set-property!',str)
1952 str = re.sub ('ly:set-mus-property!', 'ly:music-set-property!',str)
1953 str = re.sub ('ly:set-context-property!', 'ly:context-set-property!', str)
1954 str = re.sub ('ly:get-grob-property', 'ly:grob-property',str)
1955 str = re.sub ('ly:get-mus-property', 'ly:music-property',str)
1956 str = re.sub ('ly:get-context-property', 'ly:context-property',str)
1960 conversions.append (((2,1,26), conv, """More Scheme function renaming"""))
1964 g = string.atoi (m.group (2))
1972 lower_pitches = filter (lambda x : x <= g, [0, 2, 4, 5, 7, 9, 11, 12])
1973 s = len (lower_pitches) -1
1974 a = g - lower_pitches [-1]
1977 print s , lower_pitches, g, a, s
1979 str += ['eses', 'es', '', 'is', 'isis'][a + 2]
1981 str += ',' * (-o - 1)
1983 str += "'" * (o + 1)
1985 return '\\transposition %s ' % str
1988 str = re.sub (r"\\set ([A-Za-z]+\s*\.\s*)?transposing\s*=\s*#([-0-9]+)",
1992 conversions.append (((2,1,27), conv, """property transposing -> tuning"""))
1995 str = re.sub (r'make-music-by-name', 'make-music', str)
1996 str = re.sub (r"\\override\s+.*Arpeggio\s+#.print-function\s+=\s+\\arpeggioBracket", r"\\arpeggioBracket", str)
1999 conversions.append (((2,1,28), conv,
2000 """make-music-by-name -> make-music,
2001 new syntax for setting \\arpeggioBracket"""))
2004 str = re.sub (r'\\center([^-])', '\\center-align\\1', str)
2005 str = re.sub (r'\\translator', '\\context', str)
2008 conversions.append (((2,1,29), conv,
2009 '\\center -> \\center-align, \\translator -> \\context'))
2013 str = re.sub (r'\\threeq(flat|sharp)', r'\\sesqui\1', str)
2014 str = re.sub (r'ly:stencil-get-extent',
2015 'ly:stencil-extent', str)
2016 str = re.sub (r'ly:translator-find',
2017 'ly:context-find', str)
2018 str = re.sub ('ly:unset-context-property','ly:context-unset-property',
2021 str = re.sub (r'ly:get-mutable-properties',
2022 'ly:mutable-music-properties',str)
2023 str = re.sub (r'centralCPosition',
2024 'middleCPosition',str)
2027 conversions.append (((2,1,30), conv,
2028 '''\\threeq{flat,sharp} -> \\sesqui{flat,sharp}
2029 ly:get-mutable-properties -> ly:mutable-music-properties
2030 centralCPosition -> middleCPosition
2031 ly:unset-context-property -> ly:context-unset-property
2032 ly:translator-find -> ly:context-find
2033 ly:get-stencil-extent -> ly:stencil-extent
2038 str = re.sub (r'\\alias\s*"?Timing"?', '', str)
2041 conversions.append (((2,1,31), conv,
2042 '''remove \\alias Timing'''))
2045 str = re.sub (r"(\\set\s+)?(?P<context>(Score\.)?)breakAlignOrder\s*=\s*#'(?P<list>[^\)]+)",
2046 r"\n\\override \g<context>BreakAlignment #'break-align-orders = "
2047 + "#(make-vector 3 '\g<list>)", str)
2051 conversions.append (((2,1,33), conv,
2052 '''breakAlignOrder -> break-align-orders.'''))
2055 str = re.sub (r"\(set-paper-size",
2056 "(set-default-paper-size",str)
2059 conversions.append (((2,1,34), conv,
2060 '''set-paper-size -> set-default-paper-size.'''))
2063 str = re.sub (r"ly:mutable-music-properties",
2064 "ly:music-mutable-properties", str)
2067 conversions.append (((2,1, 36), conv,
2068 '''ly:mutable-music-properties -> ly:music-mutable-properties'''))
2075 conversions.append (((2, 2, 0), conv,
2076 '''clean up version. '''))
2079 return re.sub (r'\\apply\b', r'\\applymusic', str)
2081 conversions.append (((2, 3, 1), conv,
2082 '''\\apply -> \\applymusic'''))
2085 if re.search ('textheight', str):
2086 sys.stderr.write("\nWarning: tuning of page layout has changed. See reference manual.\n")
2088 str = re.sub (r'\\OrchestralScoreContext', '\\Score', str)
2090 if m.group(1) not in ['RemoveEmptyStaff',
2091 'AncientRemoveEmptyStaffContext',
2093 return '\\' + m.group (1)
2098 str = re.sub (r'\\([a-zA-Z]+)Context\b', func, str)
2100 str = re.sub ('ly:paper-lookup', 'ly:output-def-lookup', str)
2103 conversions.append (((2, 3, 2), conv,
2104 '''\\FooContext -> \\Foo'''))
2107 str = re.sub (r'\\notes\b', '', str)
2111 conversions.append (((2, 3, 4), conv,
2112 '''remove \\notes'''))
2117 str = re.sub (r'lastpagefill\s*=\s*"?1"', 'raggedlastbottom = ##t', str)
2120 conversions.append (((2, 3, 6), conv,
2121 '''lastpagefill -> raggedlastbottom'''))
2126 str = re.sub (r'\\consistsend', '\\consists', str)
2127 str = re.sub (r'\\lyricsto\s+("?[a-zA-Z]+"?)(\s*\\new Lyrics\s*)?\\lyrics',
2128 r'\\lyricsto \1 \2', str)
2131 conversions.append (((2, 3, 8), conv,
2132 '''remove \\consistsend, strip \\lyrics from \\lyricsto.'''))
2135 str = re.sub (r'neo_mensural', 'neomensural', str)
2136 str = re.sub (r'if-text-padding', 'bound-padding', str)
2139 conversions.append (((2, 3, 9), conv,
2140 '''neo_mensural -> neomensural, if-text-padding -> bound-padding'''))
2145 str = re.sub (r'\\addlyrics', r'\\oldaddlyrics', str)
2146 str = re.sub (r'\\newlyrics', r'\\addlyrics', str)
2147 if re.search (r"\\override\s*TextSpanner", str):
2148 sys.stderr.write ("\nWarning: TextSpanner has been split into DynamicTextSpanner and TextSpanner\n")
2151 conversions.append (((2, 3, 10), conv,
2152 '''\\addlyrics -> \\oldaddlyrics, \\newlyrics -> \\addlyrics'''))
2155 str = re.sub (r'\\setMmRestFermata\s+(R[0-9.*/]*)',
2156 r'\1^\\fermataMarkup', str)
2159 conversions.append (((2, 3, 11), conv,
2160 '''\\setMmRestFermata -> ^\\fermataMarkup'''))
2163 str = re.sub (r'\\newpage', r'\\pageBreak', str)
2164 str = re.sub (r'\\scriptUp', r"""{
2165 \\override TextScript #'direction = #1
2166 \\override Script #'direction = #1
2168 str = re.sub (r'\\scriptDown', r"""{
2169 \\override TextScript #'direction = #-1
2170 \\override Script #'direction = #-1
2172 str = re.sub (r'\\scriptBoth', r"""{
2173 \\revert TextScript #'direction
2174 \\revert Script #'direction
2176 str = re.sub ('soloADue', 'printPartCombineTexts', str)
2177 str = re.sub (r'\\applymusic\s*#notes-to-clusters',
2178 '\\makeClusters', str)
2180 str = re.sub (r'pagenumber\s*=', 'firstpagenumber', str)
2183 conversions.append (((2, 3, 12), conv,
2184 '''\\newpage -> \\pageBreak, junk \\script{up,down,both},
2185 soloADue -> printPartCombineTexts, #notes-to-clusters -> \\makeClusters
2190 str = re.sub (r'\\chords\b', r'\\chordmode', str)
2191 str = re.sub (r'\\lyrics\b', r'\\lyricmode', str)
2192 str = re.sub (r'\\figures\b', r'\\figuremode', str)
2193 str = re.sub (r'\\notes\b', r'\\notemode', str)
2194 str = re.sub (r'\\drums\b', r'\\drummode', str)
2195 str = re.sub (r'\\chordmode\s*\\new ChordNames', r'\\chords', str)
2196 str = re.sub (r'\\new ChordNames\s*\\chordmode', r'\\chords', str)
2197 str = re.sub (r'\\new FiguredBass\s*\\figuremode', r'\\figures', str)
2198 str = re.sub (r'\\figuremode\s*\new FiguredBass', r'\\figures', str)
2199 str = re.sub (r'\\new DrumStaff\s*\\drummode', r'\\drums', str)
2200 str = re.sub (r'\\drummode\s*\\new DrumStaff', r'\\drums', str)
2204 conversions.append (((2, 3, 16), conv,
2205 '''\foo -> \foomode (for chords, notes, etc.)
2206 fold \new FooContext \foomode into \foo.'''))
2209 str = re.sub (r'(slur|stem|phrasingSlur|tie|dynamic|dots|tuplet|arpeggio|)Both', r'\1Neutral', str)
2210 str = re.sub (r"\\applymusic\s*#\(remove-tag\s*'([a-z-0-9]+)\)",
2211 r"\\removeWithTag #'\1", str)
2214 conversions.append (((2, 3, 17), conv,
2215 '''\foo -> \foomode (for chords, notes, etc.)
2216 fold \new FooContext \foomode into \foo.'''))
2220 str = re.sub (r'Text_item', 'Text_interface', str)
2223 conversions.append (((2, 3, 18),
2225 '''Text_item -> Text_interface''' ))
2228 str = re.sub (r'\\paper', r'\\layout', str)
2229 str = re.sub (r'\\bookpaper', r'\\paper', str)
2230 if re.search ('paper-set-staff-size', str):
2231 sys.stderr.write ('''\nWarning: staff size should be changed at top-level
2234 #(set-global-staff-size <STAFF-HEIGHT-IN-POINT>)
2239 str = re.sub (r'#\(paper-set-staff-size', '%Use set-global-staff-size at toplevel\n% #(layout-set-staff-size', str)
2242 conversions.append (((2, 3, 22),
2245 bookpaper -> paper''' ))
2249 str = re.sub (r'\\context\s+([a-zA-Z]+)\s*=\s*([a-z]+)\s',
2250 r'\\context \1 = "\2" ',
2254 conversions.append (((2, 3, 23),
2256 '''\context Foo = NOTENAME -> \context Foo = "NOTENAME"'''))
2260 return regularize_id (m.group (1))
2261 str = re.sub (r'(maintainer_email|maintainer_web|midi_stuff|gourlay_maxmeasures)',
2265 conversions.append (((2, 3, 24),
2267 '''regularize other identifiers.'''))
2273 conversions.append (((2, 4, 0),
2279 str = re.sub (r'\\quote\s+"?([a-zA-Z0-9]+)"?\s+([0-9.*/]+)',
2280 r'\\quoteDuring #"\1" { \skip \2 }',
2285 conversions.append (((2, 5, 0),
2291 str = re.sub (r'ly:import-module',
2292 r'ly:module-copy', str)
2295 conversions.append (((2, 5, 1),
2297 'ly:import-module -> ly:module-copy'))
2300 str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<([^<]*)>',
2302 str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<([^<]*)>',
2304 str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<([^<]*)>',
2308 conversions.append (((2, 5, 2),
2310 '\markup .. < .. > .. -> \markup .. { .. } ..'))
2313 str = re.sub ('ly:find-glyph-by-name', 'ly:font-get-glyph', str)
2314 str = re.sub ('"(scripts|clefs|accidentals)-', r'"\1.', str)
2315 str = re.sub ("'hufnagel-do-fa", "'hufnagel.do.fa", str)
2316 str = re.sub ("'(vaticana|hufnagel|medicaea|petrucci|neomensural|mensural)-", r"'\1.", str)
2319 conversions.append (((2, 5, 3),
2321 'ly:find-glyph-by-name -> ly:font-get-glyph, remove - from glyphnames.'))
2325 str = re.sub (r"\\override\s+(Voice\.)?Slur #'dashed\s*=\s*#\d*(\.\d+)?",
2326 r"\\slurDashed", str)
2329 conversions.append (((2, 5, 12),
2331 '\set Slur #\'dashed = #X -> \slurDashed'))
2334 input_encoding = 'latin1'
2336 encoding = match.group (1)
2338 # FIXME: automatic recoding of other than latin1?
2339 if encoding == 'latin1':
2340 return match.group (2)
2342 sys.stderr.write ('\n')
2343 sys.stderr.write (_ ("found obsolete \\encoding: %s") \
2345 sys.stderr.write ('\n')
2346 sys.stderr.write (_ ("LilyPond source must be UTF-8"))
2347 sys.stderr.write ('\n')
2348 if encoding == 'TeX':
2349 sys.stderr.write (_ ("Try the texstrings backend"))
2350 sys.stderr.write ('\n')
2352 sys.stderr.write ( _("Do something like: %s") % \
2353 ("recode %s..utf-8 FILE" % encoding))
2354 sys.stderr.write ('\n')
2355 sys.stderr.write (_ ("Or save as UTF-8 in your editor"))
2356 sys.stderr.write ('\n')
2357 raise FatalConversionError ()
2359 return match.group (0)
2361 str = re.sub (r'\\encoding\s+"?([a-zA-Z0-9]+)"?(\s+)', func, str)
2364 de_ascii = codecs.getdecoder ('ascii')
2365 de_utf_8 = codecs.getdecoder ('utf_8')
2366 de_input = codecs.getdecoder (input_encoding)
2367 en_utf_8 = codecs.getencoder ('utf_8')
2370 except UnicodeDecodeError:
2371 # do not re-recode UTF-8 input
2374 except UnicodeDecodeError:
2375 str = en_utf_8 (de_input (str)[0])[0]
2378 conversions.append (((2, 5, 13),
2380 '\\encoding: smart recode latin1..utf-8'))
2383 ################################
2384 # END OF CONVERSIONS
2385 ################################
2387 def get_conversions (from_version, to_version):
2388 def version_b (v, f = from_version, t = to_version):
2389 return version_cmp (v[0], f) > 0 and version_cmp (v[0], t) <= 0
2390 return filter (version_b, conversions)
2393 def latest_version ():
2394 return conversions[-1][0]
2396 def do_conversion (infile, from_version, outfile, to_version):
2397 conv_list = get_conversions (from_version, to_version)
2399 sys.stderr.write (_ ("Applying conversions: "))
2400 str = infile.read ()
2401 last_conversion = ()
2404 sys.stderr.write (tup_to_str (x[0]) + ', ')
2406 last_conversion = x[0]
2408 except FatalConversionError:
2409 sys.stderr.write (_ ("%s: error while converting") \
2411 sys.stderr.write ('\n')
2412 sys.stderr.write (_ ("Aborting"))
2413 sys.stderr.write ('\n')
2416 sys.stderr.write ('\n')
2417 new_ver = '\\version \"%s\"' % tup_to_str (last_conversion)
2419 if re.search (lilypond_version_re_str, str):
2420 str = re.sub (lilypond_version_re_str,'\\'+new_ver, str)
2422 str = new_ver + '\n' + str
2426 return last_conversion
2428 class UnknownVersion:
2431 def do_one_file (infile_name):
2432 sys.stderr.write (_ ("Processing `%s\'... ") % infile_name)
2433 sys.stderr.write ('\n')
2436 outfile_name = infile_name + '.NEW'
2437 elif __main__.outfile_name:
2438 outfile_name = __main__.outfile_name
2440 if __main__.from_version:
2441 from_version = __main__.from_version
2443 guess = guess_lilypond_version (infile_name)
2445 raise UnknownVersion ()
2446 from_version = str_to_tuple (guess)
2448 if __main__.to_version:
2449 to_version = __main__.to_version
2451 to_version = latest_version ()
2455 infile = open (infile_name,'r')
2460 outfile = open (outfile_name, 'w')
2462 outfile = sys.stdout
2464 touched = do_conversion (infile, from_version, outfile, to_version)
2472 if __main__.edit and touched:
2474 os.remove(infile_name + '~')
2477 os.rename (infile_name, infile_name + '~')
2478 os.rename (infile_name + '.NEW', infile_name)
2480 sys.stderr.write ('\n')
2490 (options, files) = getopt.getopt (sys.argv[1:], 'ao:f:t:senh',
2491 ['no-version', 'version', 'output',
2492 'show-rules', 'help', 'edit',
2498 if o == '--help' or o == '-h':
2501 elif o == '--version' or o == '-v':
2504 elif o== '--from' or o=='-f':
2505 from_version = str_to_tuple (a)
2506 elif o== '--to' or o=='-t':
2507 to_version = str_to_tuple (a)
2508 elif o== '--edit' or o == '-e':
2510 elif o== '--show-rules' or o == '-s':
2512 elif o == '--output' or o == '-o':
2514 elif o == '--no-version' or o == '-n':
2520 # should parse files[] to read \version?
2522 show_rules (sys.stdout)
2529 elif not os.path.isfile (f):
2533 except UnknownVersion:
2534 sys.stderr.write ('\n')
2535 sys.stderr.write (_ ("%s: cannot determine version for `%s'") \
2536 % (program_name, f))
2537 sys.stderr.write ('\n')
2540 from_version = (0, 0, 0)
2544 sys.stderr.write (_ ("%s: skipping: `%s' ") \
2545 % (program_name, f))
2548 sys.stderr.write ('\n')