1 # (setq py-indent-offset 4)
12 NOT_SMART = "\n" + _ ("Not smart enough to convert %s")
13 UPDATE_MANUALLY = _ ("Please refer to the manual for details, and update manually.")
14 FROM_TO = _ ( "%s has been replaced by %s")
17 class FatalConversionError:
21 stderr_write = lilylib.stderr_write
24 stderr_write (_ ("warning: %s") % str)
26 # Decorator to make rule syntax simpler
27 def rule (version, message):
29 version: a LilyPond version tuple like (2, 11, 50)
30 message: the message that describes the conversion.
32 This decorator adds its function together with the version and the
33 message to the global conversions list. (It doesn't need to return
34 the function as it isn't used directly anyway.)
36 A conversion rule using this decorator looks like this:
38 @rule ((1, 2, 3), "convert foo to bar")
40 str = str.replace('foo', 'bar')
45 conversions.append ((version, f, message))
49 @rule ((0, 1, 9), _ ('\\header { key = concat + with + operator }'))
51 if re.search ('\\\\multi', str):
53 stderr_write (NOT_SMART % "\\multi")
58 @rule ((0, 1, 19), _ ('deprecated %s') % '\\octave')
60 if re.search ('\\\\octave', str):
62 stderr_write (NOT_SMART % "\\octave")
64 stderr_write (UPDATE_MANUALLY)
66 # raise FatalConversionError ()
70 @rule ((0, 1, 20), _ ('deprecated \\textstyle, new \\key syntax'))
72 str = re.sub ('\\\\textstyle([^;]+);',
73 '\\\\property Lyrics . textstyle = \\1', str)
74 # harmful to current .lys
75 # str = re.sub ('\\\\key([^;]+);', '\\\\accidentals \\1;', str)
79 @rule ((0, 1, 21), '\\musical_pitch -> \\musicalpitch, \\meter -> \\time')
81 str = re.sub ('\\\\musical_pitch', '\\\\musicalpitch',str)
82 str = re.sub ('\\\\meter', '\\\\time',str)
86 @rule ((1, 0, 0), _ ("bump version for release"))
91 @rule ((1, 0, 1), '\\accidentals -> \\keysignature, specialaccidentals -> keyoctaviation')
93 str = re.sub ('\\\\accidentals', '\\\\keysignature',str)
94 str = re.sub ('specialaccidentals *= *1', 'keyoctaviation = 0',str)
95 str = re.sub ('specialaccidentals *= *0', 'keyoctaviation = 1',str)
99 @rule ((1, 0, 2), _ ('\\header { key = concat + with + operator }'))
101 if re.search ('\\\\header', str):
103 stderr_write (NOT_SMART % _ ("new \\header format"))
108 @rule ((1, 0, 3), '\\melodic -> \\notes')
110 str = re.sub ('\\\\melodic([^a-zA-Z])', '\\\\notes\\1',str)
114 @rule ((1, 0, 4), 'default_{paper,midi}')
116 str = re.sub ('default_paper *=', '',str)
117 str = re.sub ('default_midi *=', '',str)
121 @rule ((1, 0, 5), 'ChoireStaff -> ChoirStaff')
123 str = re.sub ('ChoireStaff', 'ChoirStaff',str)
124 str = re.sub ('\\\\output', 'output = ',str)
128 @rule ((1, 0, 6), 'foo = \\translator {\\type .. } ->\\translator {\\type ..; foo; }')
130 if re.search ('[a-zA-Z]+ = *\\translator',str):
132 stderr_write (NOT_SMART % _ ("\\translator syntax"))
134 # raise FatalConversionError ()
138 @rule ((1, 0, 7), '\\lyric -> \\lyrics')
140 str = re.sub ('\\\\lyrics*', '\\\\lyrics',str)
144 @rule ((1, 0, 10), '[2/3 ]1/1 -> \\times 2/3 ')
146 str = re.sub ('\\\\\\[/3+', '\\\\times 2/3 { ',str)
147 str = re.sub ('\\[/3+', '\\\\times 2/3 { [',str)
148 str = re.sub ('\\\\\\[([0-9/]+)', '\\\\times \\1 {',str)
149 str = re.sub ('\\[([0-9/]+)', '\\\\times \\1 { [',str)
150 str = re.sub ('\\\\\\]([0-9/]+)', '}', str)
151 str = re.sub ('\\\\\\]', '}',str)
152 str = re.sub ('\\]([0-9/]+)', '] }', str)
156 @rule ((1, 0, 12), 'Chord syntax stuff')
161 @rule ((1, 0, 13), '<a ~ b> c -> <a b> ~ c')
163 str = re.sub ('<([^>~]+)~([^>]*)>','<\\1 \\2> ~', str)
167 @rule ((1, 0, 14), '<[a b> <a b]>c -> [<a b> <a b>]')
169 str = re.sub ('<\\[','[<', str)
170 str = re.sub ('\\]>','>]', str)
174 @rule ((1, 0, 16), '\\type -> \\context, textstyle -> textStyle')
176 str = re.sub ('\\\\type([^\n]*engraver)','\\\\TYPE\\1', str)
177 str = re.sub ('\\\\type([^\n]*performer)','\\\\TYPE\\1', str)
178 str = re.sub ('\\\\type','\\\\context', str)
179 str = re.sub ('\\\\TYPE','\\\\type', str)
180 str = re.sub ('textstyle','textStyle', str)
184 @rule ((1, 0, 18), _ ('\\repeat NUM Music Alternative -> \\repeat FOLDSTR Music Alternative'))
186 if re.search ('\\\\repeat',str):
188 stderr_write (NOT_SMART % "\\repeat")
190 # raise FatalConversionError ()
194 @rule ((1, 0, 19), 'fontsize -> fontSize, midi_instrument -> midiInstrument, SkipBars -> skipBars')
196 str = re.sub ('SkipBars','skipBars', str)
197 str = re.sub ('fontsize','fontSize', str)
198 str = re.sub ('midi_instrument','midiInstrument', str)
202 @rule ((1, 0, 20), '{,tie,slur}ydirection -> {v,tieV,slurV}erticalDirection')
204 str = re.sub ('tieydirection','tieVerticalDirection', str)
205 str = re.sub ('slurydirection','slurVerticalDirection', str)
206 str = re.sub ('ydirection','verticalDirection', str)
210 @rule ((1, 0, 21), 'hshift -> horizontalNoteShift')
212 str = re.sub ('hshift','horizontalNoteShift', str)
216 @rule ((1, 1, 52), _ ('deprecate %s') % '\\grouping')
218 str = re.sub ('\\\\grouping[^;]*;','', str)
222 @rule ((1, 1, 55), '\\wheel -> \\coda')
224 str = re.sub ('\\\\wheel','\\\\coda', str)
228 @rule ((1, 1, 65), 'slurdash -> slurDash, keyoctaviation -> keyOctaviation')
230 str = re.sub ('keyoctaviation','keyOctaviation', str)
231 str = re.sub ('slurdash','slurDash', str)
235 @rule ((1, 1, 66), 'semi -> volta')
237 str = re.sub ('\\\\repeat *\"?semi\"?','\\\\repeat "volta"', str)
241 @rule ((1, 1, 67), 'beamAuto -> noAutoBeaming')
243 str = re.sub ('\"?beamAuto\"? *= *\"?0?\"?','noAutoBeaming = "1"', str)
247 @rule ((1, 2, 0), 'automaticMelismas -> automaticMelismata')
249 str = re.sub ('automaticMelismas', 'automaticMelismata', str)
253 @rule ((1, 2, 1), 'dynamicDir -> dynamicDirection')
255 str = re.sub ('dynamicDir\\b', 'dynamicDirection', str)
259 @rule ((1, 3, 4), '\\cadenza -> \\cadenza{On|Off}')
261 str = re.sub ('\\\\cadenza *0 *;', '\\\\cadenzaOff', str)
262 str = re.sub ('\\\\cadenza *1 *;', '\\\\cadenzaOn', str)
266 @rule ((1, 3, 5), 'beamAuto moment properties')
268 str = re.sub ('"?beamAuto([^"=]+)"? *= *"([0-9]+)/([0-9]+)" *;*',
269 'beamAuto\\1 = #(make-moment \\2 \\3)',
274 @rule ((1, 3, 17), 'stemStyle -> flagStyle')
276 str = re.sub ('stemStyle',
282 @rule ((1, 3, 18), 'staffLineLeading -> staffSpace')
284 str = re.sub ('staffLineLeading',
290 @rule ((1, 3, 23), _ ('deprecate %s ') % '\\repetitions')
292 if re.search ('\\\\repetitions',str):
294 stderr_write (NOT_SMART % "\\repetitions")
296 # raise FatalConversionError ()
300 @rule ((1, 3, 35), 'textEmptyDimension -> textNonEmpty')
302 str = re.sub ('textEmptyDimension *= *##t',
303 'textNonEmpty = ##f',
305 str = re.sub ('textEmptyDimension *= *##f',
306 'textNonEmpty = ##t',
311 @rule ((1, 3, 38), '\musicalpitch { a b c } -> #\'(a b c)')
313 str = re.sub ("([a-z]+)[ \t]*=[ \t]*\\\\musicalpitch *{([- 0-9]+)} *\n",
314 "(\\1 . (\\2))\n", str)
315 str = re.sub ("\\\\musicalpitch *{([0-9 -]+)}",
316 "\\\\musicalpitch #'(\\1)", str)
317 if re.search ('\\\\notenames',str):
319 stderr_write (NOT_SMART % _ ("new \\notenames format"))
324 @rule ((1, 3, 39), '\\key A ; ->\\key a;')
327 return '\\key %s;' % match.group (1).lower ()
329 str = re.sub ("\\\\key ([^;]+);", replace, str)
333 @rule ((1, 3, 41), '[:16 c4 d4 ] -> \\repeat "tremolo" 2 { c16 d16 }')
335 if re.search ('\\[:',str):
337 stderr_write (NOT_SMART % _ ("new tremolo format"))
342 @rule ((1, 3, 42), _ ('Staff_margin_engraver deprecated, use Instrument_name_engraver'))
344 str = re.sub ('Staff_margin_engraver' , 'Instrument_name_engraver', str)
348 @rule ((1, 3, 49), 'noteHeadStyle value: string -> symbol')
350 str = re.sub ('note[hH]eadStyle\\s*=\\s*"?(\\w+)"?' , "noteHeadStyle = #'\\1", str)
354 @rule ((1, 3, 58), 'noteHeadStyle value: string -> symbol')
356 if re.search ('\\\\keysignature', str):
358 stderr_write (NOT_SMART % '\\keysignature')
363 @rule ((1, 3, 59), '\key X ; -> \key X major; ')
365 str = re.sub (r"""\\key *([a-z]+) *;""", r"""\\key \1 \major;""",str);
369 @rule ((1, 3, 68), 'latexheaders = "\\input global" -> latexheaders = "global"')
371 str = re.sub (r'latexheaders *= *"\\\\input ',
377 # TODO: lots of other syntax changes should be done here as well
378 @rule ((1, 3, 92), 'basicXXXProperties -> XXX, Repeat_engraver -> Volta_engraver')
380 str = re.sub ('basicCollisionProperties', 'NoteCollision', str)
381 str = re.sub ('basicVoltaSpannerProperties' , "VoltaBracket", str)
382 str = re.sub ('basicKeyProperties' , "KeySignature", str)
384 str = re.sub ('basicClefItemProperties' ,"Clef", str)
387 str = re.sub ('basicLocalKeyProperties' ,"Accidentals", str)
388 str = re.sub ('basicMarkProperties' ,"Accidentals", str)
389 str = re.sub ('basic([A-Za-z_]+)Properties', '\\1', str)
391 str = re.sub ('Repeat_engraver' ,'Volta_engraver', str)
395 @rule ((1, 3, 93), _ ('change property definiton case (eg. onevoice -> oneVoice)'))
397 # Ugh, but meaning of \stemup changed too
398 # maybe we should do \stemup -> \stemUp\slurUp\tieUp ?
399 str = re.sub ('\\\\stemup', '\\\\stemUp', str)
400 str = re.sub ('\\\\stemdown', '\\\\stemDown', str)
401 str = re.sub ('\\\\stemboth', '\\\\stemBoth', str)
403 str = re.sub ('\\\\slurup', '\\\\slurUp', str)
404 str = re.sub ('\\\\slurboth', '\\\\slurBoth', str)
405 str = re.sub ('\\\\slurdown', '\\\\slurDown', str)
406 str = re.sub ('\\\\slurdotted', '\\\\slurDotted', str)
407 str = re.sub ('\\\\slurnormal', '\\\\slurNoDots', str)
409 str = re.sub ('\\\\shiftoff', '\\\\shiftOff', str)
410 str = re.sub ('\\\\shifton', '\\\\shiftOn', str)
411 str = re.sub ('\\\\shiftonn', '\\\\shiftOnn', str)
412 str = re.sub ('\\\\shiftonnn', '\\\\shiftOnnn', str)
414 str = re.sub ('\\\\onevoice', '\\\\oneVoice', str)
415 str = re.sub ('\\\\voiceone', '\\\\voiceOne', str)
416 str = re.sub ('\\\\voicetwo', '\\\\voiceTwo', str)
417 str = re.sub ('\\\\voicethree', '\\\\voiceThree', str)
418 str = re.sub ('\\\\voicefour', '\\\\voiceFour', str)
420 # I don't know exactly when these happened...
421 # ugh, we lose context setting here...
422 str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\stemUp\\\\slurUp\\\\tieUp', str)
423 str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\stemDown\\\\slurDown\\\\tieDown', str)
424 str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\stemBoth\\\\slurBoth\\\\tieBoth', str)
426 str = re.sub ('verticalDirection[^=]*= *#?"?(1|(\\\\up))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #1', str)
427 str = re.sub ('verticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #-1', str)
428 str = re.sub ('verticalDirection[^=]*= *#?"?(0|(\\\\center))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #0', str)
430 str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\\\1Up', str)
431 str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\\\1Down', str)
432 str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\\\1Both', str)
434 # (lacks capitalization slur -> Slur)
435 str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\1 \\\\override #\'direction = #1', str)
436 str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\1 \\override #\'direction = #-1', str)
437 str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\1 \\\\override #\'direction = #0', str)
440 str = re.sub ('\\\\property *[^ .]*[.]?dynamicDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\dynamicUp', str)
441 str = re.sub ('\\\\property *[^ .]*[.]?dyn[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\dynamicDown', str)
442 str = re.sub ('\\\\property *[^ .]*[.]?dyn[^=]*= *#?"?(0|(\\\\center))"?', '\\\\dynamicBoth', str)
444 str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)Dash[^=]*= *#?"?(0|(""))"?', '\\\\\\1NoDots', str)
445 str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)Dash[^=]*= *#?"?([1-9]+)"?', '\\\\\\1Dotted', str)
447 str = re.sub ('\\\\property *[^ .]*[.]?noAutoBeaming[^=]*= *#?"?(0|(""))"?', '\\\\autoBeamOn', str)
448 str = re.sub ('\\\\property *[^ .]*[.]?noAutoBeaming[^=]*= *#?"?([1-9]+)"?', '\\\\autoBeamOff', str)
452 @rule ((1, 3, 97), 'ChordName -> ChordNames')
454 str = re.sub ('ChordNames*', 'ChordNames', str)
455 if re.search ('\\\\textscript "[^"]* *"[^"]*"', str):
457 stderr_write (NOT_SMART % _ ("new \\textscript markup text"))
460 str = re.sub ('\\textscript +("[^"]*")', '\\textscript #\\1', str)
463 # TODO: add lots of these
465 @rule ((1, 3, 98), 'CONTEXT.textStyle -> GROB.#font-style ')
467 str = re.sub ('\\\\property *"?Voice"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Voice.TextScript \\\\set #\'font-style = #\'\\1', str)
468 str = re.sub ('\\\\property *"?Lyrics"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Lyrics.LyricText \\\\set #\'font-style = #\'\\1', str)
470 str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?timeSignatureStyle"? *= *"([^"]*)"', '\\\\property \\1.TimeSignature \\\\override #\'style = #\'\\2', str)
472 str = re.sub ('"?timeSignatureStyle"? *= *#?""', 'TimeSignature \\\\override #\'style = ##f', str)
474 str = re.sub ('"?timeSignatureStyle"? *= *#?"([^"]*)"', 'TimeSignature \\\\override #\'style = #\'\\1', str)
476 str = re.sub ('#\'style *= #*"([^"])"', '#\'style = #\'\\1', str)
478 str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?horizontalNoteShift"? *= *"?#?([-0-9]+)"?', '\\\\property \\1.NoteColumn \\\\override #\'horizontal-shift = #\\2', str)
481 str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *""', '\\\\property \\1.Stem \\\\override #\'flag-style = ##f', str)
483 str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *"([^"]*)"', '\\\\property \\1.Stem \\\\override #\'flag-style = #\'\\2', str)
487 @rule ((1, 3, 102), 'beamAutoEnd -> autoBeamSettings \\push (end * * * *)')
489 str = re.sub ('"?beamAutoEnd_([0-9]*)"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(end 1 \\1 * *) = \\2', str)
490 str = re.sub ('"?beamAutoBegin_([0-9]*)"? *= *(#\\([^)]*\))', 'autoBeamSettings \\push #\'(begin 1 \\1 * *) = \\2', str)
491 str = re.sub ('"?beamAutoEnd"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(end * * * *) = \\1', str)
492 str = re.sub ('"?beamAutoBegin"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(begin * * * *) = \\1', str)
496 @rule ((1, 3, 111), '\\push -> \\override, \\pop -> \\revert')
498 str = re.sub ('\\\\push', '\\\\override', str)
499 str = re.sub ('\\\\pop', '\\\\revert', str)
503 @rule ((1, 3, 113), 'LyricVoice -> LyricsVoice')
505 str = re.sub ('LyricVoice', 'LyricsVoice', str)
507 str = re.sub ('Chord[Nn]ames*.Chord[Nn]ames*', 'ChordNames.ChordName', str)
508 str = re.sub ('Chord[Nn]ames([ \t\n]+\\\\override)', 'ChordName\\1', str)
512 def regularize_id (str):
519 elif x in string.digits:
520 x = chr(ord (x) - ord ('0') +ord ('A'))
521 elif x not in string.letters:
523 elif x in string.lowercase and lastx == '_':
530 @rule ((1, 3, 117), _ ('identifier names: %s') % '$!foo_bar_123 -> xfooBarABC')
532 def regularize_dollar_reference (match):
533 return regularize_id (match.group (1))
534 def regularize_assignment (match):
535 return '\n' + regularize_id (match.group (1)) + ' = '
536 str = re.sub ('\$([^\t\n ]+)', regularize_dollar_reference, str)
537 str = re.sub ('\n([^ \t\n]+)[ \t]*= *', regularize_assignment, str)
541 @rule ((1, 3, 120), 'paper_xxx -> paperXxxx, pedalup -> pedalUp.')
543 def regularize_paper (match):
544 return regularize_id (match.group (1))
545 str = re.sub ('(paper_[a-z]+)', regularize_paper, str)
546 str = re.sub ('sustainup', 'sustainUp', str)
547 str = re.sub ('nobreak', 'noBreak', str)
548 str = re.sub ('sustaindown', 'sustainDown', str)
549 str = re.sub ('sostenutoup', 'sostenutoUp', str)
550 str = re.sub ('sostenutodown', 'sostenutoDown', str)
551 str = re.sub ('unachorda', 'unaChorda', str)
552 str = re.sub ('trechorde', 'treChorde', str)
556 @rule ((1, 3, 122), 'drarnChords -> chordChanges, \\musicalpitch -> \\pitch')
558 str = re.sub ('drarnChords', 'chordChanges', str)
559 str = re.sub ('\\musicalpitch', '\\pitch', str)
563 @rule ((1, 3, 136), 'ly-X-elt-property -> ly-X-grob-property')
565 str = re.sub ('ly-([sg])et-elt-property', 'ly-\\1et-grob-property', str)
569 @rule ((1, 3, 138), _ ('point-and-click argument changed to procedure.'))
571 str = re.sub ('point-and-click +#t', 'point-and-click line-column-location', str)
575 @rule ((1, 3, 138), 'followThread -> followVoice.')
577 str = re.sub ('followThread', 'followVoice', str)
578 str = re.sub ('Thread.FollowThread', 'Voice.VoiceFollower', str)
579 str = re.sub ('FollowThread', 'VoiceFollower', str)
583 @rule ((1, 3, 139), 'font-point-size -> font-design-size.')
585 str = re.sub ('font-point-size', 'font-design-size', str)
589 @rule ((1, 3, 141), 'xNoDots -> xSolid')
591 str = re.sub ('([a-zA-Z]*)NoDots', '\\1Solid', str)
595 @rule ((1, 3, 144), 'Chorda -> Corda')
597 str = re.sub ('([Cc])hord([ea])', '\\1ord\\2', str)
601 @rule ((1, 3, 145), 'ContextNameXxxxVerticalExtent -> XxxxVerticalExtent')
603 str = re.sub ('([A-Za-z]+)MinimumVerticalExtent', 'MinimumV@rticalExtent', str)
604 str = re.sub ('([A-Za-z]+)ExtraVerticalExtent', 'ExtraV@rticalExtent', str)
605 str = re.sub ('([A-Za-z]+)VerticalExtent', 'VerticalExtent', str)
606 str = re.sub ('ExtraV@rticalExtent', 'ExtraVerticalExtent', str)
607 str = re.sub ('MinimumV@rticalExtent', 'MinimumVerticalExtent', str)
611 @rule ((1, 3, 146), _('semicolons removed'))
613 str = re.sub ('\\\\key[ \t]*;', '\\key \\default;', str)
614 str = re.sub ('\\\\mark[ \t]*;', '\\mark \\default;', str)
616 # Make sure groups of more than one ; have space before
617 # them, so that non of them gets removed by next rule
618 str = re.sub ("([^ \n\t;]);(;+)", "\\1 ;\\2", str)
620 # Only remove ; that are not after spaces, # or ;
621 # Otherwise we interfere with Scheme comments,
622 # which is badbadbad.
623 str = re.sub ("([^ \t;#]);", "\\1", str)
627 @rule ((1, 3, 147), 'default-neutral-direction -> neutral-direction')
629 str = re.sub ('default-neutral-direction', 'neutral-direction',str)
633 @rule ((1, 3, 148), '"(align" -> "(axis", "(rows" -> "(columns"')
635 str = re.sub ('\(align', '(axis', str)
636 str = re.sub ('\(rows', '(columns', str)
640 @rule ((1, 5, 33), 'SystemStartDelimiter -> systemStartDelimiter')
642 str = re.sub ('SystemStartDelimiter', 'systemStartDelimiter', str)
646 @rule ((1, 5, 38), 'arithmetic... -> spacing...')
648 str = re.sub ('arithmetic-multiplier', 'spacing-increment', str)
649 str = re.sub ('arithmetic-basicspace', 'shortest-duration-space', str)
654 @rule ((1, 5, 40), _ ('%s property names') % 'breakAlignOrder')
659 "Instrument_name": "instrument-name",
660 "Left_edge_item": "left-edge",
661 "Span_bar": "span-bar",
662 "Breathing_sign": "breathing-sign",
663 "Staff_bar": "staff-bar",
665 "Key_item": "key-signature",
666 "Time_signature": "time-signature",
669 props = match.group (1)
670 for (k,v) in break_dict.items():
671 props = re.sub (k, v, props)
672 return "breakAlignOrder = #'(%s)" % props
674 str = re.sub ("breakAlignOrder *= *#'\\(([a-z_\n\tA-Z ]+)\\)",
679 @rule ((1, 5, 49), 'noAutoBeaming -> autoBeaming')
681 str = re.sub ('noAutoBeaming *= *##f', 'autoBeaming = ##t', str)
682 str = re.sub ('noAutoBeaming *= *##t', 'autoBeaming = ##f', str)
686 @rule ((1, 5, 52), 'tuplet-X-visibility -> X-visibility')
688 str = re.sub ('tuplet-bracket-visibility', 'bracket-visibility', str)
689 str = re.sub ('tuplet-number-visibility', 'number-visibility', str)
693 @rule ((1, 5, 56), 'Pitch::transpose -> ly-transpose-pitch')
695 str = re.sub ('Pitch::transpose', 'ly-transpose-pitch', str)
699 @rule ((1, 5, 58), _ ('deprecate %s') % 'textNonEmpty')
701 str = re.sub ('textNonEmpty *= *##t', "TextScript \\set #'no-spacing-rods = ##f", str)
702 str = re.sub ('textNonEmpty *= *##f', "TextScript \\set #'no-spacing-rods = ##t", str)
706 @rule ((1, 5, 59), 'XxxxVerticalExtent -> xxxVerticalExtent')
708 str = re.sub ('MinimumVerticalExtent', 'minimumV@rticalExtent', str)
709 str = re.sub ('minimumVerticalExtent', 'minimumV@rticalExtent', str)
710 str = re.sub ('ExtraVerticalExtent', 'extraV@rticalExtent', str)
711 str = re.sub ('extraVerticalExtent', 'extraV@rticalExtent', str)
712 str = re.sub ('VerticalExtent', 'verticalExtent', str)
713 str = re.sub ('extraV@rticalExtent', 'extraVerticalExtent', str)
714 str = re.sub ('minimumV@rticalExtent', 'minimumVerticalExtent', str)
718 @rule ((1, 5, 62), 'visibility-lambda -> break-visibility')
720 str = re.sub ('visibility-lambda', 'break-visibility', str)
724 @rule ((1, 5, 67), _ ('automaticMelismata turned on by default'))
726 if re.search (r'\addlyrics',str) \
727 and re.search ('automaticMelismata', str) == None:
729 stderr_write (NOT_SMART % "automaticMelismata; turned on by default since 1.5.67.")
731 raise FatalConversionError ()
735 @rule ((1, 5, 68), 'ly-set-X-property -> ly-set-X-property!')
737 str = re.sub ('ly-set-grob-property([^!])', 'ly-set-grob-property!\1', str)
738 str = re.sub ('ly-set-mus-property([^!])', 'ly-set-mus-property!\1', str)
742 @rule ((1, 5, 71), 'extent-[XY] -> [XY]-extent')
744 str = re.sub ('extent-X', 'X-extent', str)
745 str = re.sub ('extent-Y', 'Y-extent', str)
749 @rule ((1, 5, 72), 'set! point-and-click -> set-point-and-click!')
751 str = re.sub ("""#\(set! +point-and-click +line-column-location\)""",
752 """#(set-point-and-click! \'line-column)""", str)
753 str = re.sub ("""#\(set![ \t]+point-and-click +line-location\)""",
754 '#(set-point-and-click! \'line)', str)
755 str = re.sub ('#\(set! +point-and-click +#f\)',
756 '#(set-point-and-click! \'none)', str)
760 @rule ((1, 6, 5), 'Stems: flag-style -> stroke-style; style -> flag-style')
762 str = re.sub ('flag-style', 'stroke-style', str)
763 str = re.sub (r"""Stem([ ]+)\\override #'style""", r"""Stem \\override #'flag-style""", str);
764 str = re.sub (r"""Stem([ ]+)\\set([ ]+)#'style""", r"""Stem \\set #'flag-style""", str);
768 def subst_req_name (match):
769 return "(make-music-by-name \'%sEvent)" % regularize_id (match.group(1))
772 @rule ((1, 7, 1), 'ly-make-music foo_bar_req -> make-music-by-name FooBarEvent')
774 str = re.sub ('\\(ly-make-music *\"([A-Z][a-z_]+)_req\"\\)', subst_req_name, str)
775 str = re.sub ('Request_chord', 'EventChord', str)
780 "text" : 'TextSpanEvent',
781 "decrescendo" : 'DecrescendoEvent',
782 "crescendo" : 'CrescendoEvent',
783 "Sustain" : 'SustainPedalEvent',
784 "slur" : 'SlurEvent',
785 "UnaCorda" : 'UnaCordaEvent',
786 "Sostenuto" : 'SostenutoEvent',
789 def subst_ev_name (match):
791 if re.search ('start', match.group(1)):
793 mtype = spanner_subst[match.group(2)]
794 return "(make-span-event '%s %s)" % (mtype , stype)
796 def subst_definition_ev_name(match):
797 return ' = #%s' % subst_ev_name (match)
799 def subst_inline_ev_name (match):
800 s = subst_ev_name (match)
801 return '#(ly-export %s)' % s
803 def subst_csp_definition (match):
804 return ' = #(make-event-chord (list %s))' % subst_ev_name (match)
806 def subst_csp_inline (match):
807 return '#(ly-export (make-event-chord (list %s)))' % subst_ev_name (match)
810 @rule ((1, 7, 2), '\\spanrequest -> #(make-span-event .. ), \script -> #(make-articulation .. )')
812 str = re.sub (r' *= *\\spanrequest *([^ ]+) *"([^"]+)"', subst_definition_ev_name, str)
813 str = re.sub (r'\\spanrequest *([^ ]+) *"([^"]+)"', subst_inline_ev_name, str)
814 str = re.sub (r' *= *\\commandspanrequest *([^ ]+) *"([^"]+)"', subst_csp_definition, str)
815 str = re.sub (r'\\commandspanrequest *([^ ]+) *"([^"]+)"', subst_csp_inline, str)
816 str = re.sub (r'ly-id ', 'ly-import ', str)
818 str = re.sub (r' *= *\\script "([^"]+)"', ' = #(make-articulation "\\1")', str)
819 str = re.sub (r'\\script "([^"]+)"', '#(ly-export (make-articulation "\\1"))', str)
823 @rule ((1, 7, 3), 'ly- -> ly:')
825 str = re.sub (r'\(ly-', '(ly:', str)
835 'music-duration-length',
840 'transpose-key-alist',
844 'set-point-and-click!',
853 'music-duration-compress',
854 'set-point-and-click!'
857 origre = r'\b(%s)' % '|'.join (changed)
859 str = re.sub (origre, r'ly:\1',str)
860 str = re.sub ('set-point-and-click!', 'set-point-and-click', str)
864 @rule ((1, 7, 4), '<< >> -> < < > >')
866 if re.search ('new-chords-done',str):
869 str = re.sub (r'<<', '< <', str)
870 str = re.sub (r'>>', '> >', str)
874 @rule ((1, 7, 5), '\\transpose TO -> \\transpose FROM TO')
876 str = re.sub (r"\\transpose", r"\\transpose c'", str)
877 str = re.sub (r"\\transpose c' *([a-z]+)'", r"\\transpose c \1", str)
881 @rule ((1, 7, 6), 'note\\script -> note-\script')
897 origstr = '|'.join (kws)
898 str = re.sub (r'([^_^-])\\(%s)\b' % origstr, r'\1-\\\2', str)
902 @rule ((1, 7, 10), "\property ChordName #'style -> #(set-chord-name-style 'style)")
904 str = re.sub (r"\\property *ChordNames *\. *ChordName *\\(set|override) *#'style *= *#('[a-z]+)",
905 r"#(set-chord-name-style \2)", str)
906 str = re.sub (r"\\property *ChordNames *\. *ChordName *\\revert *#'style",
911 @rule ((1, 7, 11), "transpose-pitch -> pitch-transpose")
913 str = re.sub (r"ly:transpose-pitch", "ly:pitch-transpose", str)
917 @rule ((1, 7, 13), "ly:XX-molecule-YY -> ly:molecule-XX-YY")
919 str = re.sub (r"ly:get-molecule-extent", "ly:molecule-get-extent", str)
920 str = re.sub (r"ly:set-molecule-extent!", "ly:molecule-set-extent!", str)
921 str = re.sub (r"ly:add-molecule", "ly:molecule-add", str)
922 str = re.sub (r"ly:combine-molecule-at-edge", "ly:molecule-combine-at-edge", str)
923 str = re.sub (r"ly:align-to!", "ly:molecule-align-to!", str)
927 @rule ((1, 7, 15), "linewidth = -1 -> raggedright = ##t")
929 str = re.sub (r"linewidth *= *-[0-9.]+ *(\\mm|\\cm|\\in|\\pt)?", 'raggedright = ##t', str )
933 @rule ((1, 7, 16), "divisiomaior -> divisioMaior")
935 str = re.sub ("divisiomaior",
937 str = re.sub ("divisiominima",
938 "divisioMinima", str)
939 str = re.sub ("divisiomaxima",
940 "divisioMaxima", str)
944 @rule ((1, 7, 17), "Skip_req -> Skip_event")
946 str = re.sub ("Skip_req_swallow_translator",
947 "Skip_event_swallow_translator", str)
951 @rule ((1, 7, 18), "groupOpen/Close -> start/stopGroup, #'outer -> #'enclose-bounds")
953 str = re.sub ("groupOpen",
955 str = re.sub ("groupClose",
957 str = re.sub ("#'outer",
958 "#'enclose-bounds", str)
963 @rule ((1, 7, 19), _ ("remove %s") % "GraceContext")
965 if re.search( r'\\GraceContext', str):
967 stderr_write (NOT_SMART % "GraceContext")
968 stderr_write (FROM_TO \
969 % ("GraceContext", "#(add-to-grace-init .. )"))
971 stderr_write (UPDATE_MANUALLY)
973 raise FatalConversionError ()
975 str = re.sub ('HaraKiriStaffContext', 'RemoveEmptyStaffContext', str)
979 @rule ((1, 7, 22), "#'type -> #'style")
982 r"(set|override|revert) *#'type",
988 @rule ((1, 7, 23), "barNonAuto -> automaticBars")
991 "barNonAuto *= *##t",
992 "automaticBars = ##f",
995 "barNonAuto *= *##f",
996 "automaticBars = ##t",
1001 @rule ((1, 7, 24), _ ("cluster syntax"))
1003 if re.search( r'-(start|stop)Cluster', str):
1005 stderr_write (NOT_SMART % _ ("cluster syntax"))
1007 stderr_write (UPDATE_MANUALLY)
1010 raise FatalConversionError ()
1014 @rule ((1, 7, 28), _ ("new Pedal style syntax"))
1016 str = re.sub (r"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\(override|set) *#'pedal-type *",
1017 r"\property Staff.pedal\1Style ", str)
1018 str = re.sub (r"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\revert *#'pedal-type", '', str)
1025 origstr = '<%s>' % str
1026 if re.search (r'\\\\', str):
1029 if re.search (r'\\property', str):
1032 if re.match (r'^\s*\)?\s*\\[a-zA-Z]+', str):
1036 def sub_durs (m, durs = durs):
1037 durs.append(m.group(2))
1040 str = re.sub (r"([a-z]+[,'!? ]*)([0-9]+\.*)", sub_durs, str)
1047 return '<%s>' % m.group (1)
1054 while last_str <> str:
1057 def sub_tremolos (m, slur_strs = slur_strs):
1059 if tr not in slur_strs:
1060 slur_strs.append (tr)
1063 str = re.sub (r"([a-z]+[',!? ]*)(:[0-9]+)",
1066 def sub_dyn_end (m, dyns = dyns):
1068 return ' ' + m.group(2)
1070 str = re.sub (r'(\\!)\s*([a-z]+)', sub_dyn_end, str)
1071 def sub_slurs(m, slur_strs = slur_strs):
1072 if '-)' not in slur_strs:
1073 slur_strs.append (')')
1076 def sub_p_slurs(m, slur_strs = slur_strs):
1077 if '-\)' not in slur_strs:
1078 slur_strs.append ('\)')
1081 str = re.sub (r"\)[ ]*([a-z]+)", sub_slurs, str)
1082 str = re.sub (r"\\\)[ ]*([a-z]+)", sub_p_slurs, str)
1083 def sub_begin_slurs(m, slur_strs = slur_strs):
1084 if '-(' not in slur_strs:
1085 slur_strs.append ('(')
1088 str = re.sub (r"([a-z]+[,'!?0-9 ]*)\(",
1089 sub_begin_slurs, str)
1090 def sub_begin_p_slurs(m, slur_strs = slur_strs):
1091 if '-\(' not in slur_strs:
1092 slur_strs.append ('\(')
1095 str = re.sub (r"([a-z]+[,'!?0-9 ]*)\\\(",
1096 sub_begin_p_slurs, str)
1098 def sub_dyns (m, slur_strs = slur_strs):
1100 if s == '@STARTCRESC@':
1101 slur_strs.append ("\\<")
1102 elif s == '@STARTDECRESC@':
1103 slur_strs.append ("\\>")
1105 slur_strs.append ('\\!')
1108 str = re.sub (r'@STARTCRESC@', sub_dyns, str)
1109 str = re.sub (r'-?\\!', sub_dyns, str)
1111 def sub_articulations (m, slur_strs = slur_strs):
1113 if a not in slur_strs:
1114 slur_strs.append (a)
1117 str = re.sub (r"([_^-]\@ACCENT\@)", sub_articulations,
1119 str = re.sub (r"([_^-]\\[a-z]+)", sub_articulations,
1121 str = re.sub (r"([_^-][>_.+|^-])", sub_articulations,
1123 str = re.sub (r'([_^-]"[^"]+")', sub_articulations,
1126 def sub_pslurs(m, slur_strs = slur_strs):
1127 slur_strs.append (' \\)')
1129 str = re.sub (r"\\\)[ ]*([a-z]+)", sub_pslurs, str)
1133 suffix = ''.join (slur_strs) + ''.join (pslur_strs) \
1136 return '@STARTCHORD@%s@ENDCHORD@%s%s' % (str , dur_str, suffix)
1140 def sub_chords (str):
1145 marker_str = '%% new-chords-done %%'
1147 if re.search (marker_str,str):
1149 str = re.sub ('<<', '@STARTCHORD@', str)
1150 str = re.sub ('>>', '@ENDCHORD@', str)
1152 str = re.sub (r'\\<', '@STARTCRESC@', str)
1153 str = re.sub (r'\\>', '@STARTDECRESC@', str)
1154 str = re.sub (r'([_^-])>', r'\1@ACCENT@', str)
1155 str = re.sub (r'<([^<>{}]+)>', sub_chord, str)
1157 # add dash: -[, so that [<<a b>> c d] becomes
1159 # and gets skipped by articulation_substitute
1160 str = re.sub (r'\[ *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)',
1162 str = re.sub (r'\\! *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)',
1165 str = re.sub (r'<([^?])', r'%s\1' % simstart, str)
1166 str = re.sub (r'>([^?])', r'%s\1' % simend, str)
1167 str = re.sub ('@STARTCRESC@', r'\\<', str)
1168 str = re.sub ('@STARTDECRESC@', r'\\>' ,str)
1169 str = re.sub (r'\\context *Voice *@STARTCHORD@',
1170 '@STARTCHORD@', str)
1171 str = re.sub ('@STARTCHORD@', chordstart, str)
1172 str = re.sub ('@ENDCHORD@', chordend, str)
1173 str = re.sub (r'@ACCENT@', '>', str)
1176 markup_start = re.compile(r"([-^_]|\\mark)\s*(#\s*'\s*)\(")
1177 musicglyph = re.compile(r"\(\s*music\b")
1178 columns = re.compile(r"\(\s*columns\b")
1179 submarkup_start = re.compile(r"\(\s*([a-zA-Z]+)")
1180 leftpar = re.compile(r"\(")
1181 rightpar = re.compile(r"\)")
1183 def text_markup (str):
1185 # Find the beginning of each markup:
1186 match = markup_start.search (str)
1188 result = result + str[:match.end (1)] + " \markup"
1189 str = str[match.end( 2):]
1190 # Count matching parentheses to find the end of the
1193 pars = re.finditer(r"[()]",str)
1195 if par.group () == '(':
1196 nesting_level = nesting_level + 1
1198 nesting_level = nesting_level - 1
1199 if nesting_level == 0:
1200 markup_end = par.end ()
1202 # The full markup in old syntax:
1203 markup = str[:markup_end]
1204 # Modify to new syntax:
1205 markup = musicglyph.sub (r"{\\musicglyph", markup)
1206 markup = columns.sub (r"{", markup)
1207 markup = submarkup_start.sub (r"{\\\1", markup)
1208 markup = leftpar.sub ("{", markup)
1209 markup = rightpar.sub ("}", markup)
1211 result = result + markup
1213 str = str[markup_end:]
1214 match = markup_start.search(str)
1215 result = result + str
1218 def articulation_substitute (str):
1219 str = re.sub (r"""([^-])\[ *(\\?\)?[a-z]+[,']*[!?]?[0-9:]*\.*)""",
1221 str = re.sub (r"""([^-])\\\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
1223 str = re.sub (r"""([^-\\])\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
1225 str = re.sub (r"""([^-])\\! *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
1229 string_or_scheme = re.compile ('("(?:[^"\\\\]|\\\\.)*")|(#\\s*\'?\\s*\\()')
1231 # Only apply articulation_substitute () outside strings and
1232 # Scheme expressions:
1233 def smarter_articulation_subst (str):
1235 # Find the beginning of next string or Scheme expr.:
1236 match = string_or_scheme.search (str)
1238 # Convert the preceding LilyPond code:
1239 previous_chunk = str[:match.start()]
1240 result = result + articulation_substitute (previous_chunk)
1241 if match.group (1): # Found a string
1242 # Copy the string to output:
1243 result = result + match.group (1)
1244 str = str[match.end(1):]
1245 else: # Found a Scheme expression. Count
1246 # matching parentheses to find its end
1247 str = str[match.start ():]
1249 pars = re.finditer(r"[()]",str)
1251 if par.group () == '(':
1252 nesting_level = nesting_level + 1
1254 nesting_level = nesting_level - 1
1255 if nesting_level == 0:
1256 scheme_end = par.end ()
1258 # Copy the Scheme expression to output:
1259 result = result + str[:scheme_end]
1260 str = str[scheme_end:]
1261 # Find next string or Scheme expression:
1262 match = string_or_scheme.search (str)
1263 # Convert the remainder of the file
1264 result = result + articulation_substitute (str)
1267 def conv_relative(str):
1268 if re.search (r"\\relative", str):
1269 str= "#(ly:set-option 'old-relative)\n" + str
1273 @rule ((1, 9, 0), _ ("""New relative mode,
1274 Postfix articulations, new text markup syntax, new chord syntax."""))
1276 str = re.sub (r"#'\(\)", "@SCM_EOL@", str)
1277 str = conv_relative (str)
1278 str = sub_chords (str)
1280 str = text_markup (str)
1281 str = smarter_articulation_subst (str)
1282 str = re.sub ("@SCM_EOL@", "#'()", str)
1286 @rule ((1, 9, 1), _ ("Remove - before articulation"))
1288 if re.search ("font-style",str):
1290 stderr_write (NOT_SMART % "font-style")
1292 stderr_write (UPDATE_MANUALLY)
1295 raise FatalConversionError ()
1297 str = re.sub (r'-\\markup', r'@\\markup', str)
1298 str = re.sub (r'-\\', r'\\', str)
1299 str = re.sub (r'-\)', ')', str)
1300 str = re.sub (r'-\(', '(', str)
1301 str = re.sub ('-\[', '[', str)
1302 str = re.sub ('-\]', ']', str)
1303 str = re.sub ('-~', '~', str)
1304 str = re.sub (r'@\\markup', r'-\\markup', str)
1308 @rule ((1, 9, 2), "\\newcontext -> \\new")
1310 str = re.sub ('ly:set-context-property',
1311 'ly:set-context-property!', str)
1312 str = re.sub ('\\\\newcontext', '\\\\new', str)
1313 str = re.sub ('\\\\grace[\t\n ]*([^{ ]+)',
1314 r'\\grace { \1 }', str)
1315 str = re.sub ("\\\\grace[\t\n ]*{([^}]+)}",
1317 \\property Voice.Stem \\override #'stroke-style = #"grace"
1319 \\property Voice.Stem \\revert #'stroke-style }
1324 @rule ((1, 9, 3), (_ ("%s misspelling") % "\\acciaccatura") +
1325 ", fingerHorizontalDirection -> fingeringOrientations")
1327 str = re.sub ('accacciatura',
1328 'acciaccatura', str)
1330 if re.search ("context-spec-music", str):
1332 stderr_write (NOT_SMART % "context-spec-music")
1334 stderr_write (UPDATE_MANUALLY)
1337 raise FatalConversionError ()
1339 str = re.sub ('fingerHorizontalDirection *= *#(LEFT|-1)',
1340 "fingeringOrientations = #'(up down left)", str)
1341 str = re.sub ('fingerHorizontalDirection *= *#(RIGHT|1)',
1342 "fingeringOrientations = #'(up down right)", str)
1346 @rule ((1, 9, 4), _ ('Swap < > and << >>'))
1348 if re.search ('\\figures', str):
1349 warning (_ ("attempting automatic \\figures conversion. Check results!"));
1351 def figures_replace (m):
1353 s = re.sub ('<', '@FIGOPEN@',s)
1354 s = re.sub ('>', '@FIGCLOSE@',s)
1355 return '\\figures { %s }' % s
1357 str = re.sub (r'\\figures[ \t\n]*{([^}]+)}', figures_replace, str)
1358 str = re.sub (r'\\<', '@STARTCRESC@', str)
1359 str = re.sub (r'\\>', '@STARTDECRESC@', str)
1360 str = re.sub (r'([-^_])>', r'\1@ACCENT@', str)
1361 str = re.sub (r'<<', '@STARTCHORD@', str)
1362 str = re.sub (r'>>', '@ENDCHORD@', str)
1363 str = re.sub (r'>', '@ENDSIMUL@', str)
1364 str = re.sub (r'<', '@STARTSIMUL@', str)
1365 str = re.sub ('@STARTDECRESC@', '\\>', str)
1366 str = re.sub ('@STARTCRESC@', '\\<', str)
1367 str = re.sub ('@ACCENT@', '>', str)
1368 str = re.sub ('@ENDCHORD@', '>', str)
1369 str = re.sub ('@STARTCHORD@', '<', str)
1370 str = re.sub ('@STARTSIMUL@', '<<', str)
1371 str = re.sub ('@ENDSIMUL@', '>>', str)
1372 str = re.sub ('@FIGOPEN@', '<', str)
1373 str = re.sub ('@FIGCLOSE@', '>', str)
1377 @rule ((1, 9, 5), 'HaraKiriVerticalGroup -> RemoveEmptyVerticalGroup')
1379 str = re.sub ('HaraKiriVerticalGroup', 'RemoveEmptyVerticalGroup', str)
1383 @rule ((1, 9, 6), _ ('deprecate %s') % 'ly:get-font')
1385 if re.search ("ly:get-font", str) :
1387 stderr_write (NOT_SMART % "(ly:-get-font")
1389 stderr_write (FROM_TO \
1390 % ("(ly:paper-get-font (ly:grob-get-paper foo) .. )",
1391 "(ly:paper-get-font (ly:grob-get-paper foo) .. )"))
1392 stderr_write (UPDATE_MANUALLY)
1394 raise FatalConversionError ()
1396 if re.search ("\\pitch *#", str) :
1398 stderr_write (NOT_SMART % "\\pitch")
1400 stderr_write (_ ("Use Scheme code to construct arbitrary note events."))
1403 raise FatalConversionError ()
1407 @rule ((1, 9, 7), _ ('''use symbolic constants for alterations,
1408 remove \\outputproperty, move ly:verbose into ly:get-option'''))
1410 def sub_alteration (m):
1414 '-2': 'DOUBLE-FLAT',
1417 '2': 'DOUBLE-SHARP',
1420 return '(ly:make-pitch %s %s %s)' % (m.group(1), m.group (2),
1423 str =re.sub ("\\(ly:make-pitch *([0-9-]+) *([0-9-]+) *([0-9-]+) *\\)",
1424 sub_alteration, str)
1427 str = re.sub ("ly:verbose", "ly:get-option 'verbose", str)
1429 m= re.search ("\\\\outputproperty #([^#]+)[\t\n ]*#'([^ ]+)", str)
1432 r"""\outputproperty found,
1433 Please hand-edit, using
1435 \applyoutput #(outputproperty-compatibility %s '%s <GROB PROPERTY VALUE>)
1437 as a substitution text.""") % (m.group (1), m.group (2)) )
1438 raise FatalConversionError ()
1440 if re.search ("ly:(make-pitch|pitch-alteration)", str) \
1441 or re.search ("keySignature", str):
1443 stderr_write (NOT_SMART % "pitches")
1446 _ ("""The alteration field of Scheme pitches was multiplied by 2
1447 to support quarter tone accidentals. You must update the following constructs manually:
1449 * calls of ly:make-pitch and ly:pitch-alteration
1450 * keySignature settings made with \property
1452 raise FatalConversionError ()
1456 @rule ((1, 9, 8), "dash-length -> dash-fraction")
1458 if re.search ("dash-length",str):
1460 stderr_write (NOT_SMART % "dash-length")
1462 stderr_write (FROM_TO % ("dash-length", "dash-fraction"))
1464 stderr_write (UPDATE_MANUALLY)
1466 raise FatalConversionError ()
1470 @rule ((2, 1, 1), "font-relative-size -> font-size")
1473 return "#'font-size = #%d" % (2*int (match.group (1)))
1475 str =re.sub (r"#'font-relative-size\s*=\s*#\+?([0-9-]+)", func, str)
1476 str =re.sub (r"#'font-family\s*=\s*#'ancient",
1477 r"#'font-family = #'music", str)
1481 @rule ((2, 1, 2), "ly:get-music-length -> ly:music-length")
1483 str =re.sub (r"ly:get-music-length", "ly:music-length", str)
1487 @rule ((2, 1, 3), "stanza -> instrument")
1489 str =re.sub (r"\.\s+stz=", ". instr ", str)
1493 @rule ((2, 1, 4), _ ("removal of automaticMelismata; use melismaBusyProperties instead."))
1503 return r" \property %s.melismaBusyProperties \unset" % c
1505 return r"\property %s.melismaBusyProperties = #'(melismaBusy)" % c
1507 str = re.sub (r"\\property ([a-zA-Z]+)\s*\.\s*automaticMelismata\s*=\s*##([ft])", func, str)
1511 @rule ((2, 1, 7), "\\translator Staff -> \\change Staff")
1513 str =re.sub (r"\\translator\s+([a-zA-Z]+)", r"\\change \1", str)
1517 @rule ((2, 1, 10), "\\newaddlyrics -> \\lyricsto")
1519 str =re.sub (r"\\newaddlyrics", r"\\lyricsto", str)
1523 @rule ((2, 1, 11), """\\include "paper16.ly" -> #(set-staff-size 16)
1524 \\note #3 #1 #1 -> \\note #"8." #1
1527 str = re.sub (r'\\include\s*"paper([0-9]+)(-init)?.ly"',
1528 r"#(set-staff-size \1)", str)
1530 def sub_note (match):
1532 log = int (match.group (1))
1533 dots = int (match.group (2))
1536 dur = '%d' % (1 << log)
1538 dur = { -1 : 'breve',
1544 return r'\note #"%s" #%s' % (dur, match.group (3))
1546 str = re.sub (r'\\note\s+#([0-9-]+)\s+#([0-9]+)\s+#([0-9.-]+)',
1551 @rule ((2, 1, 12), "OttavaSpanner -> OttavaBracket")
1553 str = re.sub (r"OttavaSpanner", r"OttavaBracket", str)
1557 @rule ((2, 1, 13), "set-staff-size -> set-global-staff-size")
1559 str = re.sub (r"\(set-staff-size ", r"(set-global-staff-size ", str)
1563 @rule ((2, 1, 14), "style = dotted -> dash-fraction = 0")
1565 str = re.sub (r"#'style\s*=\s*#'dotted-line",
1566 r"#'dash-fraction = #0.0 ", str)
1570 @rule ((2, 1, 15), "LyricsVoice . instr(ument) -> vocalName")
1572 str = re.sub (r'LyricsVoice\s*\.\s*instrument\s*=\s*("[^"]*")',
1573 r'LyricsVoice . vocalName = \1', str)
1575 str = re.sub (r'LyricsVoice\s*\.\s*instr\s*=\s*("[^"]*")',
1576 r'LyricsVoice . vocNam = \1', str)
1580 @rule ((2, 1, 16), '\\musicglyph #"accidentals-NUM" -> \\sharp/flat/etc.')
1593 return '\\%s' % d[m.group (1)]
1595 str = re.sub (r'\\musicglyph\s*#"accidentals-([0-9-]+)"',
1600 @rule ((2, 1, 17), _ ("\\partcombine syntax change to \\newpartcombine"))
1603 if re.search (r'\\partcombine', str):
1605 stderr_write (NOT_SMART % "\\partcombine")
1607 stderr_write (UPDATE_MANUALLY)
1609 raise FatalConversionError ()
1611 # this rule doesn't really work,
1612 # too lazy to figure out why.
1613 str = re.sub (r'\\context\s+Voice\s*=\s*one\s*\\partcombine\s+Voice\s*\\context\s+Thread\s*=\s*one(.*)\s*'
1614 + r'\\context\s+Thread\s*=\s*two',
1615 '\\\\newpartcombine\n\\1\n', str)
1619 @rule ((2, 1, 18), """\\newpartcombine -> \\partcombine,
1620 \\autochange Staff -> \\autochange
1623 str = re.sub (r'\\newpartcombine', r'\\partcombine', str)
1624 str = re.sub (r'\\autochange\s+Staff', r'\\autochange ', str)
1628 @rule ((2, 1, 19), _ ("""Drum notation changes, Removing \\chordmodifiers, \\notenames.
1629 Harmonic notes. Thread context removed. Lyrics context removed."""))
1631 if re.search ('include "drumpitch', str):
1632 stderr_write (_ ("Drums found. Enclose drum notes in \\drummode"))
1634 str = re.sub (r'\\include "drumpitch-init.ly"','', str)
1636 str = re.sub (r'\\pitchnames ','pitchnames = ', str)
1637 str = re.sub (r'\\chordmodifiers ','chordmodifiers = ', str)
1638 str = re.sub (r'\bdrums\b\s*=','drumContents = ', str)
1639 str = re.sub (r'\\drums\b','\\drumContents ', str)
1642 if re.search ('drums->paper', str):
1643 stderr_write (_ ("\n%s found. Check file manually!\n") % _("Drum notation"))
1645 str = re.sub (r"""\\apply\s+#\(drums->paper\s+'([a-z]+)\)""",
1646 r"""\property DrumStaff.drumStyleTable = #\1-style""",
1649 if re.search ('Thread', str):
1650 stderr_write (_ ("\n%s found. Check file manually!\n") % "Thread");
1652 str = re.sub (r"""(\\once\s*)?\\property\s+Thread\s*\.\s*NoteHead\s*"""
1653 + r"""\\(set|override)\s*#'style\s*=\s*#'harmonic"""
1654 + r"""\s+([a-z]+[,'=]*)([0-9]*\.*)"""
1655 ,r"""<\3\\harmonic>\4""", str)
1657 str = re.sub (r"""\\new Thread""", """\context Voice""", str)
1658 str = re.sub (r"""Thread""", """Voice""", str)
1660 if re.search ('\bLyrics\b', str):
1661 stderr_write (_ ("\n%s found. Check file manually!\n") % "Lyrics");
1663 str = re.sub (r"""LyricsVoice""", r"""L@ricsVoice""", str)
1664 str = re.sub (r"""\bLyrics\b""", r"""LyricsVoice""", str)
1665 str = re.sub (r"""LyricsContext""", r"""LyricsVoiceContext""", str)
1666 str = re.sub (r"""L@ricsVoice""", r"""LyricsVoice""",str)
1670 @rule ((2, 1, 20), "nonevent-skip -> skip-music")
1672 str = re.sub (r'nonevent-skip', 'skip-music', str)
1676 @rule ((2, 1, 21), """molecule-callback -> print-function,
1677 brew_molecule -> print
1678 brew-new-markup-molecule -> Text_item::print
1679 LyricsVoice -> Lyrics
1680 tupletInvisible -> TupletBracket \set #'transparent
1682 """ % (_ ("remove %s") % "Grob::preset_extent"))
1684 str = re.sub (r'molecule-callback', 'print-function', str)
1685 str = re.sub (r'brew_molecule', 'print', str)
1686 str = re.sub (r'brew-new-markup-molecule', 'Text_item::print', str)
1687 str = re.sub (r'LyricsVoice', 'Lyrics', str)
1688 str = re.sub (r'tupletInvisible',
1689 r"TupletBracket \\set #'transparent", str)
1690 # str = re.sub (r'molecule', 'collage', str)
1691 #molecule -> collage
1692 str = re.sub (r"\\property\s+[a-zA-Z]+\s*\.\s*[a-zA-Z]+\s*"
1693 + r"\\set\s*#'X-extent-callback\s*=\s*#Grob::preset_extent",
1698 @rule ((2, 1, 22), """%s
1699 \\set A.B = #C , \\unset A.B
1700 \\override A.B #C = #D, \\revert A.B #C
1702 """ % _ ("new syntax for property settings:"))
1704 str = re.sub (r'(\\property[^=]+)=\s*([-0-9]+)',
1706 str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\=]+)\s*\\(set|override)',
1707 r"\\overrid@ \1.\2 ", str)
1708 str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*=\s*',
1709 r'\\s@t \1.\2 = ', str)
1710 str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*\\unset',
1711 r'\\uns@t \1.\2 ', str)
1712 str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*\\revert'
1713 + r"\s*#'([-a-z0-9_]+)",
1714 r"\\rev@rt \1.\2 #'\3", str)
1715 str = re.sub (r'Voice\.', '', str)
1716 str = re.sub (r'Lyrics\.', '', str)
1717 str = re.sub (r'ChordNames\.', '', str)
1719 str = re.sub ('rev@rt', 'revert',str)
1720 str = re.sub ('s@t', 'set',str)
1721 str = re.sub ('overrid@', 'override',str)
1723 str = re.sub ('molecule', 'stencil', str)
1724 str = re.sub ('Molecule', 'Stencil', str)
1728 @rule ((2, 1, 23), _ ("Property setting syntax in \\translator{ }"))
1730 def subst_in_trans (match):
1732 s = re.sub (r'\s([a-zA-Z]+)\s*\\override',
1733 r' \\override \1', s)
1734 s = re.sub (r'\s([a-zA-Z]+)\s*\\set',
1735 r' \\override \1', s)
1736 s = re.sub (r'\s([a-zA-Z]+)\s*\\revert',
1739 str = re.sub (r'\\(translator|with)\s*{[^}]+}', subst_in_trans, str)
1743 context = m.group ('context')
1746 context = " '%s" % context[:-1] # -1: remove .
1750 d['context'] = context
1752 return r"""#(override-auto-beam-setting %(prop)s %(num)s %(den)s%(context)s)""" % d
1754 str = re.sub (r"""\\override\s*(?P<context>[a-zA-Z]+\s*\.\s*)?autoBeamSettings"""
1755 +r"""\s*#(?P<prop>[^=]+)\s*=\s*#\(ly:make-moment\s+(?P<num>\d+)\s+(?P<den>\d)\s*\)""",
1760 @rule ((2, 1, 24), "music-list? -> ly:music-list?")
1762 str = re.sub (r'music-list\?', 'ly:music-list?', str)
1763 str = re.sub (r'\|\s*~', '~ |', str)
1767 @rule ((2, 1, 25), _ ("Scheme grob function renaming"))
1769 str = re.sub (r'ly:get-spanner-bound', 'ly:spanner-get-bound', str)
1770 str = re.sub (r'ly:get-extent', 'ly:grob-extent', str)
1771 str = re.sub (r'ly:get-system', 'ly:grob-system', str)
1772 str = re.sub (r'ly:get-original', 'ly:grob-original', str)
1773 str = re.sub (r'ly:get-parent', 'ly:grob-parent', str)
1774 str = re.sub (r'ly:get-broken-into', 'ly:spanner-broken-into', str)
1775 str = re.sub (r'Melisma_engraver', 'Melisma_translator', str)
1776 if re.search ("ly:get-paper-variable", str):
1778 stderr_write (NOT_SMART % "ly:paper-get-variable")
1780 stderr_write (_ ('use %s') % '(ly:paper-lookup (ly:grob-paper ))')
1782 raise FatalConversionError ()
1784 str = re.sub (r'\\defaultAccidentals', "#(set-accidental-style 'default)", str)
1785 str = re.sub (r'\\voiceAccidentals', "#(set-accidental-style 'voice)", str)
1786 str = re.sub (r'\\modernAccidentals', "#(set-accidental-style 'modern)", str)
1787 str = re.sub (r'\\modernCautionaries', "#(set-accidental-style 'modern-cautionary)", str)
1788 str = re.sub (r'\\modernVoiceAccidental', "#(set-accidental-style 'modern-voice)", str)
1789 str = re.sub (r'\\modernVoiceCautionaries', "#(set-accidental-style 'modern-voice-cautionary)", str)
1790 str = re.sub (r'\\pianoAccidentals', "#(set-accidental-style 'piano)", str)
1791 str = re.sub (r'\\pianoCautionaries', "#(set-accidental-style 'piano-cautionary)", str)
1792 str = re.sub (r'\\forgetAccidentals', "#(set-accidental-style 'forget)", str)
1793 str = re.sub (r'\\noResetKey', "#(set-accidental-style 'no-reset)", str)
1797 @rule ((2, 1, 26), _ ("More Scheme function renaming"))
1799 str = re.sub ('ly:set-grob-property!', 'ly:grob-set-property!',str)
1800 str = re.sub ('ly:set-mus-property!', 'ly:music-set-property!',str)
1801 str = re.sub ('ly:set-context-property!', 'ly:context-set-property!', str)
1802 str = re.sub ('ly:get-grob-property', 'ly:grob-property',str)
1803 str = re.sub ('ly:get-mus-property', 'ly:music-property',str)
1804 str = re.sub ('ly:get-context-property', 'ly:context-property',str)
1808 @rule ((2, 1, 27), "property transposing -> tuning")
1811 g = int (m.group (2))
1819 lower_pitches = filter (lambda x : x <= g, [0, 2, 4, 5, 7, 9, 11, 12])
1820 s = len (lower_pitches) -1
1821 a = g - lower_pitches [-1]
1825 str += ['eses', 'es', '', 'is', 'isis'][a + 2]
1827 str += ',' * (-o - 1)
1829 str += "'" * (o + 1)
1831 return '\\transposition %s ' % str
1834 str = re.sub (r"\\set ([A-Za-z]+\s*\.\s*)?transposing\s*=\s*#([-0-9]+)",
1839 @rule ((2, 1, 28), """make-music-by-name -> make-music,
1840 new syntax for setting \\arpeggioBracket""")
1842 str = re.sub (r'make-music-by-name', 'make-music', str)
1843 str = re.sub (r"\\override\s+.*Arpeggio\s+#.print-function\s+=\s+\\arpeggioBracket", r"\\arpeggioBracket", str)
1847 @rule ((2, 1, 29), '\\center -> \\center-align, \\translator -> \\context')
1849 str = re.sub (r'\\center([^-])', '\\center-align\\1', str)
1850 str = re.sub (r'\\translator', '\\context', str)
1854 @rule ((2, 1, 30), '''\\threeq{flat,sharp} -> \\sesqui{flat,sharp}
1855 ly:get-mutable-properties -> ly:mutable-music-properties
1856 centralCPosition -> middleCPosition
1857 ly:unset-context-property -> ly:context-unset-property
1858 ly:translator-find -> ly:context-find
1859 ly:get-stencil-extent -> ly:stencil-extent
1862 str = re.sub (r'\\threeq(flat|sharp)', r'\\sesqui\1', str)
1863 str = re.sub (r'ly:stencil-get-extent',
1864 'ly:stencil-extent', str)
1865 str = re.sub (r'ly:translator-find',
1866 'ly:context-find', str)
1867 str = re.sub ('ly:unset-context-property','ly:context-unset-property',
1870 str = re.sub (r'ly:get-mutable-properties',
1871 'ly:mutable-music-properties',str)
1872 str = re.sub (r'centralCPosition',
1873 'middleCPosition',str)
1877 @rule ((2, 1, 31), 'remove \\alias Timing')
1879 str = re.sub (r'\\alias\s*"?Timing"?', '', str)
1883 @rule ((2, 1, 33), 'breakAlignOrder -> break-align-orders.')
1885 str = re.sub (r"(\\set\s+)?(?P<context>(Score\.)?)breakAlignOrder\s*=\s*#'(?P<list>[^\)]+)",
1886 r"\n\\override \g<context>BreakAlignment #'break-align-orders = "
1887 + "#(make-vector 3 '\g<list>)", str)
1891 @rule ((2, 1, 34), 'set-paper-size -> set-default-paper-size.')
1893 str = re.sub (r"\(set-paper-size",
1894 "(set-default-paper-size",str)
1898 @rule ((2, 1, 36), 'ly:mutable-music-properties -> ly:music-mutable-properties')
1900 str = re.sub (r"ly:mutable-music-properties",
1901 "ly:music-mutable-properties", str)
1905 @rule ((2, 2, 0), _ ("bump version for release"))
1910 @rule ((2, 3, 1), '\\apply -> \\applymusic')
1912 return re.sub (r'\\apply\b', r'\\applymusic', str)
1915 @rule ((2, 3, 2), '\\FooContext -> \\Foo')
1917 if re.search ('textheight', str):
1919 stderr_write (NOT_SMART % "textheight")
1921 stderr_write (UPDATE_MANUALLY)
1924 _ ("""Page layout has been changed, using paper size and margins.
1925 textheight is no longer used.
1927 str = re.sub (r'\\OrchestralScoreContext', '\\Score', str)
1929 if m.group(1) not in ['RemoveEmptyStaff',
1930 'AncientRemoveEmptyStaffContext',
1932 return '\\' + m.group (1)
1937 str = re.sub (r'\\([a-zA-Z]+)Context\b', func, str)
1938 str = re.sub ('ly:paper-lookup', 'ly:output-def-lookup', str)
1942 @rule ((2, 3, 4), _ ('remove %s') % '\\notes')
1944 str = re.sub (r'\\notes\b', '', str)
1948 @rule ((2, 3, 6), 'lastpagefill -> raggedlastbottom')
1950 str = re.sub (r'lastpagefill\s*=\s*"?1"', 'raggedlastbottom = ##t', str)
1954 @rule ((2, 3, 8), 'remove \\consistsend, strip \\lyrics from \\lyricsto.')
1956 str = re.sub (r'\\consistsend', '\\consists', str)
1957 str = re.sub (r'\\lyricsto\s+("?[a-zA-Z]+"?)(\s*\\new Lyrics\s*)?\\lyrics',
1958 r'\\lyricsto \1 \2', str)
1962 @rule ((2, 3, 9), 'neo_mensural -> neomensural, if-text-padding -> bound-padding')
1964 str = re.sub (r'neo_mensural', 'neomensural', str)
1965 str = re.sub (r'if-text-padding', 'bound-padding', str)
1969 @rule ((2, 3, 10), '\\addlyrics -> \\oldaddlyrics, \\newlyrics -> \\addlyrics')
1971 str = re.sub (r'\\addlyrics', r'\\oldaddlyrics', str)
1972 str = re.sub (r'\\newlyrics', r'\\addlyrics', str)
1973 if re.search (r"\\override\s*TextSpanner", str):
1974 stderr_write ("\nWarning: TextSpanner has been split into DynamicTextSpanner and TextSpanner\n")
1978 @rule ((2, 3, 11), '\\setMmRestFermata -> ^\\fermataMarkup')
1980 str = re.sub (r'\\setMmRestFermata\s+(R[0-9.*/]*)',
1981 r'\1^\\fermataMarkup', str)
1985 @rule ((2, 3, 12), '''\\newpage -> \\pageBreak, junk \\script{up,down,both},
1986 soloADue -> printPartCombineTexts, #notes-to-clusters -> \\makeClusters
1989 str = re.sub (r'\\newpage', r'\\pageBreak', str)
1990 str = re.sub (r'\\scriptUp', r"""{
1991 \\override TextScript #'direction = #1
1992 \\override Script #'direction = #1
1994 str = re.sub (r'\\scriptDown', r"""{
1995 \\override TextScript #'direction = #-1
1996 \\override Script #'direction = #-1
1998 str = re.sub (r'\\scriptBoth', r"""{
1999 \\revert TextScript #'direction
2000 \\revert Script #'direction
2002 str = re.sub ('soloADue', 'printPartCombineTexts', str)
2003 str = re.sub (r'\\applymusic\s*#notes-to-clusters',
2004 '\\makeClusters', str)
2006 str = re.sub (r'pagenumber\s*=', 'firstpagenumber = ', str)
2010 @rule ((2, 3, 16), _ ('''\\foo -> \\foomode (for chords, notes, etc.)
2011 fold \\new FooContext \\foomode into \\foo.'''))
2013 str = re.sub (r'\\chords\b', r'\\chordmode', str)
2014 str = re.sub (r'\\lyrics\b', r'\\lyricmode', str)
2015 str = re.sub (r'\\figures\b', r'\\figuremode', str)
2016 str = re.sub (r'\\notes\b', r'\\notemode', str)
2017 str = re.sub (r'\\drums\b', r'\\drummode', str)
2018 str = re.sub (r'\\chordmode\s*\\new ChordNames', r'\\chords', str)
2019 str = re.sub (r'\\new ChordNames\s*\\chordmode', r'\\chords', str)
2020 str = re.sub (r'\\new FiguredBass\s*\\figuremode', r'\\figures', str)
2021 str = re.sub (r'\\figuremode\s*\new FiguredBass', r'\\figures', str)
2022 str = re.sub (r'\\new DrumStaff\s*\\drummode', r'\\drums', str)
2023 str = re.sub (r'\\drummode\s*\\new DrumStaff', r'\\drums', str)
2028 @rule ((2, 3, 17), '''slurBoth -> slurNeutral, stemBoth -> stemNeutral, etc.
2029 \\applymusic #(remove-tag 'foo) -> \\removeWithTag 'foo''')
2031 str = re.sub (r'(slur|stem|phrasingSlur|tie|dynamic|dots|tuplet|arpeggio|)Both', r'\1Neutral', str)
2032 str = re.sub (r"\\applymusic\s*#\(remove-tag\s*'([a-z-0-9]+)\)",
2033 r"\\removeWithTag #'\1", str)
2037 @rule ((2, 3, 18), 'Text_item -> Text_interface')
2039 str = re.sub (r'Text_item', 'Text_interface', str)
2043 @rule ((2, 3, 22), 'paper -> layout, bookpaper -> paper')
2045 str = re.sub (r'\\paper', r'\\layout', str)
2046 str = re.sub (r'\\bookpaper', r'\\paper', str)
2047 if re.search ('paper-set-staff-size', str):
2048 warning (_ ('''staff size should be changed at top-level
2051 #(set-global-staff-size <STAFF-HEIGHT-IN-POINT>)
2056 str = re.sub (r'#\(paper-set-staff-size', '%Use set-global-staff-size at toplevel\n% #(layout-set-staff-size', str)
2060 @rule ((2, 3, 23), r'\context Foo = NOTENAME -> \context Foo = "NOTENAME"')
2062 str = re.sub (r'\\context\s+([a-zA-Z]+)\s*=\s*([a-z]+)\s',
2063 r'\\context \1 = "\2" ',
2068 @rule ((2, 3, 24), _ ('''regularize other identifiers'''))
2071 return regularize_id (m.group (1))
2072 str = re.sub (r'(maintainer_email|maintainer_web|midi_stuff|gourlay_maxmeasures)',
2077 @rule ((2, 3, 25), 'petrucci_c1 -> petrucci-c1, 1style -> single-digit')
2079 str = re.sub ('petrucci_c1', 'petrucci-c1', str)
2080 str = re.sub ('1style', 'single-digit', str)
2084 @rule ((2, 4, 0), _ ("bump version for release"))
2089 @rule ((2, 5, 0), '\\quote -> \\quoteDuring')
2091 str = re.sub (r'\\quote\s+"?([a-zA-Z0-9]+)"?\s+([0-9.*/]+)',
2092 r'\\quoteDuring #"\1" { \skip \2 }',
2097 @rule ((2, 5, 1), 'ly:import-module -> ly:module-copy')
2099 str = re.sub (r'ly:import-module',
2100 r'ly:module-copy', str)
2104 @rule ((2, 5, 2), '\markup .. < .. > .. -> \markup .. { .. } ..')
2106 str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<(([^>]|<[^>]*>)*)>',
2108 str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<(([^>]|<[^>]*>)*)>',
2110 str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<(([^>]|<[^>]*>)*)>',
2114 s = re.sub (r'''((\\"|})\s*){''', '\2 \\line {', s)
2116 str = re.sub (r'\\markup\s*{([^}]|{[^}]*})*}', get_markup, str)
2120 @rule ((2, 5, 3), 'ly:find-glyph-by-name -> ly:font-get-glyph, remove - from glyphnames.')
2122 str = re.sub ('ly:find-glyph-by-name', 'ly:font-get-glyph', str)
2123 str = re.sub ('"(scripts|clefs|accidentals)-', r'"\1.', str)
2124 str = re.sub ("'hufnagel-do-fa", "'hufnagel.do.fa", str)
2125 str = re.sub ("'(vaticana|hufnagel|medicaea|petrucci|neomensural|mensural)-", r"'\1.", str)
2129 @rule ((2, 5, 12), '\set Slur #\'dashed = #X -> \slurDashed')
2131 str = re.sub (r"\\override\s+(Voice\.)?Slur #'dashed\s*=\s*#\d*(\.\d+)?",
2132 r"\\slurDashed", str)
2136 @rule ((2, 5, 13), _ ('\\encoding: smart recode latin1..utf-8. Remove ly:point-and-click'))
2138 input_encoding = 'latin1'
2140 encoding = match.group (1)
2142 # FIXME: automatic recoding of other than latin1?
2143 if encoding == 'latin1':
2144 return match.group (2)
2147 stderr_write (NOT_SMART % ("\\encoding: %s" % encoding))
2149 stderr_write (_ ("LilyPond source must be UTF-8"))
2151 if encoding == 'TeX':
2152 stderr_write (_ ("Try the texstrings backend"))
2155 stderr_write ( _("Do something like: %s") % \
2156 ("recode %s..utf-8 FILE" % encoding))
2158 stderr_write (_ ("Or save as UTF-8 in your editor"))
2160 raise FatalConversionError ()
2162 return match.group (0)
2164 str = re.sub (r'\\encoding\s+"?([a-zA-Z0-9]+)"?(\s+)', func, str)
2167 de_ascii = codecs.getdecoder ('ascii')
2168 de_utf_8 = codecs.getdecoder ('utf_8')
2169 de_input = codecs.getdecoder (input_encoding)
2170 en_utf_8 = codecs.getencoder ('utf_8')
2173 # only in python >= 2.3
2174 # except UnicodeDecodeError:
2175 except UnicodeError:
2176 # do not re-recode UTF-8 input
2179 #except UnicodeDecodeError:
2180 except UnicodeError:
2181 str = en_utf_8 (de_input (str)[0])[0]
2185 str = re.sub (r"#\(ly:set-point-and-click '[a-z-]+\)", '', str)
2189 @rule ((2, 5, 17), _ ('remove %s') % 'ly:stencil-set-extent!')
2191 if re.search ("ly:stencil-set-extent!", str):
2193 stderr_write (NOT_SMART % "ly:stencil-set-extent!")
2195 stderr_write ('use (set! VAR (ly:make-stencil (ly:stencil-expr VAR) X-EXT Y-EXT))\n')
2196 raise FatalConversionError ()
2197 if re.search ("ly:stencil-align-to!", str):
2199 stderr_write (NOT_SMART % "ly:stencil-align-to!")
2201 stderr_write ('use (set! VAR (ly:stencil-aligned-to VAR AXIS DIR))\n')
2202 raise FatalConversionError ()
2206 @rule ((2, 5, 18), 'ly:warn -> ly:warning')
2208 str = re.sub (r"ly:warn\b", 'ly:warning', str)
2212 @rule ((2, 5, 21), _ ('warn about auto beam settings'))
2214 if re.search ("(override-|revert-)auto-beam-setting", str)\
2215 or re.search ("autoBeamSettings", str):
2217 stderr_write (NOT_SMART % _ ("auto beam settings"))
2219 stderr_write (_ ('''
2220 Auto beam settings must now specify each interesting moment in a measure
2221 explicitly; 1/4 is no longer multiplied to cover moments 1/2 and 3/4 too.
2223 stderr_write (UPDATE_MANUALLY)
2225 raise FatalConversionError ()
2229 @rule ((2, 5, 25), 'unfoldrepeats -> unfoldRepeats, compressmusic -> compressMusic')
2231 str = re.sub (r"unfoldrepeats", 'unfoldRepeats', str)
2232 str = re.sub (r"compressmusic", 'compressMusic', str)
2236 @rule ((2, 6, 0), _ ("bump version for release"))
2241 @rule ((2, 7, 0), 'ly:get-default-font -> ly:grob-default-font')
2243 return re.sub('ly:get-default-font', 'ly:grob-default-font', str)
2246 @rule ((2, 7, 1), '''ly:parser-define -> ly:parser-define!
2247 excentricity -> eccentricity
2248 Timing_engraver -> Timing_translator + Default_bar_line_engraver
2251 str = re.sub('ly:parser-define', 'ly:parser-define!', str)
2252 str = re.sub('excentricity', 'eccentricity', str)
2253 str = re.sub(r'\\(consists|remove) *"?Timing_engraver"?',
2254 r'\\\1 "Timing_translator" \\\1 "Default_bar_line_engraver"',
2259 @rule ((2, 7, 2), 'ly:X-moment -> ly:moment-X')
2261 str = re.sub('ly:(add|mul|mod|div)-moment', r'ly:moment-\1', str)
2265 @rule ((2, 7, 4), 'keyAccidentalOrder -> keyAlterationOrder')
2267 str = re.sub('keyAccidentalOrder', 'keyAlterationOrder', str)
2271 @rule ((2, 7, 6), '''Performer_group_performer -> Performer_group, Engraver_group_engraver -> Engraver_group,
2272 inside-slur -> avoid-slur''')
2274 str = re.sub('Performer_group_performer', 'Performer_group', str)
2275 str = re.sub('Engraver_group_engraver', 'Engraver_group', str)
2276 str = re.sub (r"#'inside-slur\s*=\s*##t *",
2277 r"#'avoid-slur = #'inside ", str)
2278 str = re.sub (r"#'inside-slur\s*=\s*##f *",
2279 r"#'avoid-slur = #'around ", str)
2280 str = re.sub (r"#'inside-slur",
2281 r"#'avoid-slur", str)
2285 @rule ((2, 7, 10), '\\applyxxx -> \\applyXxx')
2287 str = re.sub(r'\\applyoutput', r'\\applyOutput', str)
2288 str = re.sub(r'\\applycontext', r'\\applyContext', str)
2289 str = re.sub(r'\\applymusic', r'\\applyMusic', str)
2290 str = re.sub(r'ly:grob-suicide', 'ly:grob-suicide!', str)
2294 @rule ((2, 7, 11), '"tabloid" -> "11x17"')
2296 str = re.sub(r'\"tabloid\"', '"11x17"', str)
2300 @rule ((2, 7, 12), 'outputProperty -> overrideProperty')
2302 str = re.sub(r'outputProperty' , 'overrideProperty', str)
2306 @rule ((2, 7, 13), 'layout engine refactoring [FIXME]')
2309 newkey = {'spacing-procedure': 'springs-and-rods',
2310 'after-line-breaking-callback' : 'after-line-breaking',
2311 'before-line-breaking-callback' : 'before-line-breaking',
2312 'print-function' : 'stencil'} [match.group(3)]
2313 what = match.group (1)
2314 grob = match.group (2)
2316 if what == 'revert':
2317 return "revert %s #'callbacks %% %s\n" % (grob, newkey)
2318 elif what == 'override':
2319 return "override %s #'callbacks #'%s" % (grob, newkey)
2324 str = re.sub(r"(override|revert)\s*([a-zA-Z.]+)\s*#'(spacing-procedure|after-line-breaking-callback"
2325 + r"|before-line-breaking-callback|print-function)",
2328 if re.search ('bar-size-procedure', str):
2329 stderr_write (NOT_SMART % "bar-size-procedure")
2330 if re.search ('space-function', str):
2331 stderr_write (NOT_SMART % "space-function")
2332 if re.search ('verticalAlignmentChildCallback', str):
2333 stderr_write (_ ('verticalAlignmentChildCallback has been deprecated'))
2337 @rule ((2, 7, 14), _ ('Remove callbacks property, deprecate XY-extent-callback.'))
2339 str = re.sub (r"\\override +([A-Z.a-z]+) #'callbacks",
2340 r"\\override \1", str)
2341 str = re.sub (r"\\revert ([A-Z.a-z]+) #'callbacks % ([a-zA-Z]+)",
2342 r"\\revert \1 #'\2", str)
2343 str = re.sub (r"([XY]-extent)-callback", r'\1', str)
2344 str = re.sub (r"RemoveEmptyVerticalGroup", "VerticalAxisGroup", str)
2345 str = re.sub (r"\\set ([a-zA-Z]*\.?)minimumVerticalExtent",
2346 r"\\override \1VerticalAxisGroup #'minimum-Y-extent",
2348 str = re.sub (r"minimumVerticalExtent",
2349 r"\\override VerticalAxisGroup #'minimum-Y-extent",
2351 str = re.sub (r"\\set ([a-zA-Z]*\.?)extraVerticalExtent",
2352 r"\\override \1VerticalAxisGroup #'extra-Y-extent", str)
2353 str = re.sub (r"\\set ([a-zA-Z]*\.?)verticalExtent",
2354 r"\\override \1VerticalAxisGroup #'Y-extent", str)
2358 @rule ((2, 7, 15), _ ('Use grob closures iso. XY-offset-callbacks.'))
2360 if re.search ('[XY]-offset-callbacks', str):
2361 stderr_write (NOT_SMART % "[XY]-offset-callbacks")
2362 if re.search ('position-callbacks', str):
2363 stderr_write (NOT_SMART % "position-callbacks")
2367 @rule ((2, 7, 22), r"\tag #'(a b) -> \tag #'a \tag #'b")
2370 syms = m.group (1).split ()
2371 tags = ["\\tag #'%s" % s for s in syms]
2372 return ' '.join (tags)
2374 str = re.sub (r"\\tag #'\(([^)]+)\)", sub_syms, str)
2378 @rule ((2, 7, 24), _ ('deprecate %s') % 'number-visibility')
2380 str = re.sub (r"#'number-visibility",
2381 "#'number-visibility % number-visibility is deprecated. Tune the TupletNumber instead\n",
2386 @rule ((2, 7, 28), "ly:spanner-get-bound -> ly:spanner-bound")
2388 str = re.sub (r"ly:spanner-get-bound", "ly:spanner-bound", str)
2392 @rule ((2, 7, 29), "override Stem #'beamed-* -> #'details #'beamed-*")
2394 for a in ['beamed-lengths', 'beamed-minimum-free-lengths',
2396 'beamed-extreme-minimum-free-lengths']:
2397 str = re.sub (r"\\override\s+Stem\s+#'%s" % a,
2398 r"\\override Stem #'details #'%s" % a,
2403 @rule ((2, 7, 30), "\\epsfile")
2405 str = re.sub (r'\\epsfile *#"', r'\\epsfile #X #10 #"', str)
2409 @rule ((2, 7, 31), "Foo_bar::bla_bla -> ly:foo-bar::bla-bla")
2413 return 'ly:' + str.lower ().replace ('_','-')
2415 str = re.sub (r'([A-Z][a-z_0-9]+::[a-z_0-9]+)',
2420 @rule ((2, 7, 32), _ ("foobar -> foo-bar for \paper, \layout"))
2423 ('inputencoding', 'input-encoding'),
2424 ('printpagenumber', 'print-page-number'),
2425 ('outputscale', 'output-scale'),
2426 ('betweensystemspace', 'between-system-space'),
2427 ('betweensystempadding', 'between-system-padding'),
2428 ('pagetopspace', 'page-top-space'),
2429 ('raggedlastbottom', 'ragged-last-bottom'),
2430 ('raggedright', 'ragged-right'),
2431 ('raggedlast', 'ragged-last'),
2432 ('raggedbottom', 'ragged-bottom'),
2433 ('aftertitlespace', 'after-title-space'),
2434 ('beforetitlespace', 'before-title-space'),
2435 ('betweentitlespace', 'between-title-space'),
2436 ('topmargin', 'top-margin'),
2437 ('bottommargin', 'bottom-margin'),
2438 ('headsep', 'head-separation'),
2439 ('footsep', 'foot-separation'),
2440 ('rightmargin', 'right-margin'),
2441 ('leftmargin', 'left-margin'),
2442 ('printfirstpagenumber', 'print-first-page-number'),
2443 ('firstpagenumber', 'first-page-number'),
2444 ('hsize', 'paper-width'),
2445 ('vsize', 'paper-height'),
2446 ('horizontalshift', 'horizontal-shift'),
2447 ('staffspace', 'staff-space'),
2448 ('linethickness', 'line-thickness'),
2449 ('ledgerlinethickness', 'ledger-line-thickness'),
2450 ('blotdiameter', 'blot-diameter'),
2451 ('staffheight', 'staff-height'),
2452 ('linewidth', 'line-width'),
2453 ('annotatespacing', 'annotate-spacing')
2456 for (a,b) in identifier_subs:
2458 ## str = re.sub ('"%s"' % a, '"%s"' b, str)
2460 str = re.sub (a, b, str)
2464 @rule ((2, 7, 32), "debug-beam-quanting -> debug-beam-scoring")
2466 str = re.sub ('debug-beam-quanting', 'debug-beam-scoring', str)
2470 @rule ((2, 7, 36), "def-(music-function|markup-command) -> define-(music-function|markup-command)")
2472 str = re.sub ('def-music-function', 'define-music-function', str)
2473 str = re.sub ('def-markup-command', 'define-markup-command', str)
2477 @rule ((2, 7, 40), "rehearsalMarkAlignSymbol/barNumberAlignSymbol -> break-align-symbol")
2479 str = re.sub (r'\\set\s+Score\s*\.\s*barNumberAlignSymbol\s*=',
2480 r"\\override Score.BarNumber #'break-align-symbol = ", str)
2481 str = re.sub (r'\\set\s*Score\s*\.\s*rehearsalMarkAlignSymbol\s*=',
2482 r"\\override Score.RehearsalMark #'break-align-symbol = ", str)
2486 @rule ((2, 9, 4), "(page-)penalty -> (page-)break-penalty")
2488 str = re.sub ('page-penalty', 'page-break-penalty', str)
2489 str = re.sub ('([^-])penalty', '\1break-penalty', str)
2493 @rule ((2, 9, 6), "\\context Foo \\applyOutput #bla -> \\applyOutput #'Foo #bla ")
2495 str = re.sub (r'\\context\s+\"?([a-zA-Z]+)\"?\s*\\applyOutput', r"\\applyOutput #'\1", str)
2499 @rule ((2, 9, 9), "annotatefoo -> annotate-foo")
2501 str = re.sub ('annotatepage', 'annotate-page', str)
2502 str = re.sub ('annotateheaders', 'annotate-headers', str)
2503 str = re.sub ('annotatesystems', 'annotate-systems', str)
2507 @rule ((2, 9, 11), "\\set tupletNumberFormatFunction -> \\override #'text = ")
2509 str = re.sub (r"""(\\set\s)?(?P<context>[a-zA-Z]*.?)tupletNumberFormatFunction\s*=\s*#denominator-tuplet-formatter""",
2510 r"""\\override \g<context>TupletNumber #'text = #tuplet-number::calc-denominator-text""", str)
2512 str = re.sub (r"""(\\set\s+)?(?P<context>[a-zA-Z]*.?)tupletNumberFormatFunction\s*=\s*#fraction-tuplet-formatter""",
2513 r"""\\override \g<context>TupletNumber #'text = #tuplet-number::calc-fraction-text""", str)
2515 if re.search ('tupletNumberFormatFunction', str):
2517 stderr_write ("tupletNumberFormatFunction has been removed. Use #'text property on TupletNumber")
2522 @rule ((2, 9, 13), "instrument -> instrumentName, instr -> shortInstrumentName, vocNam -> shortVocalName")
2524 str = re.sub ('vocNam', 'shortVocalName', str)
2525 str = re.sub (r'\.instr\s*=', r'.shortInstrumentName =', str)
2526 str = re.sub (r'\.instrument\s*=', r'.instrumentName =', str)
2530 @rule ((2, 9, 16), _ ("deprecate \\tempo in \\midi"))
2534 dur = int (m.group (1))
2535 dots = len (m.group (2))
2536 count = int (m.group (3))
2543 den = (1 << dots) * (1 << log2)
2544 num = ((1 << (dots+1)) - 1)
2550 tempoWholesPerMinute = #(ly:make-moment %d %d)
2554 """ % (num*count, den)
2556 str = re.sub (r'\\midi\s*{\s*\\tempo ([0-9]+)\s*([.]*)\s*=\s*([0-9]+)\s*}', sub_tempo, str)
2560 @rule ((2, 9, 19), "printfirst-page-number -> print-first-page-number")
2562 str = re.sub ('printfirst-page-number', 'print-first-page-number', str)
2566 @rule ((2, 10, 0), _ ("bump version for release"))
2571 @rule ((2, 11, 2), "ly:clone-parser -> ly:parser-clone")
2573 return re.sub ('ly:clone-parser',
2574 'ly:parser-clone', str)
2576 @rule ((2, 11, 3), "no-spacing-rods -> extra-spacing-width")
2578 str = re.sub (r"no-spacing-rods\s+=\s+##t", r"extra-spacing-width = #'(+inf.0 . -inf.0)", str)
2579 str = re.sub (r"no-spacing-rods\s+=\s+##f", r"extra-spacing-width = #'(0 . 0)", str)
2583 @rule ((2, 11, 5), _ ("deprecate cautionary-style. Use AccidentalCautionary properties"))
2585 str = re.sub ("Accidental\s*#'cautionary-style\s*=\s*#'smaller",
2586 "AccidentalCautionary #'font-size = #-2", str)
2587 str = re.sub ("Accidental\s*#'cautionary-style\s*=\s*#'parentheses",
2588 "AccidentalCautionary #'parenthesized = ##t", str)
2589 str = re.sub ("([A-Za-z]+)\s*#'cautionary-style\s*=\s*#'parentheses",
2590 r"\1 #'parenthesized = ##t", str)
2591 str = re.sub ("([A-Za-z]+)\s*#'cautionary-style\s*=\s*#'smaller",
2592 r"\1 #'font-size = #-2", str)
2596 @rule ((2, 11, 6), _ ("Rename accidental glyphs, use glyph-name-alist."))
2599 def sub_acc_name (m):
2600 idx = int (m.group (1).replace ('M','-'))
2602 return ["accidentals.doublesharp",
2603 "accidentals.sharp.slashslash.stemstemstem",
2604 "accidentals.sharp",
2605 "accidentals.sharp.slashslash.stem",
2606 "accidentals.natural",
2607 "accidentals.mirroredflat",
2609 "accidentals.mirroredflat.flat",
2610 "accidentals.flatflat"][4-idx]
2612 str = re.sub (r"accidentals[.](M?[-0-9]+)",
2614 str = re.sub (r"(KeySignature|Accidental[A-Za-z]*)\s*#'style\s*=\s*#'([a-z]+)",
2615 r"\1 #'glyph-name-alist = #alteration-\2-glyph-name-alist", str)
2616 ## FIXME: standard vs default, alteration-FOO vs FOO-alteration
2617 str = str.replace ('alteration-default-glyph-name-alist',
2618 'standard-alteration-glyph-name-alist')
2622 @rule ((2, 11, 10), """allowBeamBreak -> Beam #'breakable = ##t
2623 addquote -> addQuote
2626 str = re.sub (r'(\\set\s+)?([A-Z][a-zA-Z]+\s*\.\s*)allowBeamBreak',
2627 r"\override \2Beam #'breakable", str)
2628 str = re.sub (r'(\\set\s+)?allowBeamBreak',
2629 r"\override Beam #'breakable", str)
2630 str = re.sub (r'addquote', 'addQuote', str)
2631 if re.search ("Span_dynamic_performer", str):
2632 stderr_write ("Span_dynamic_performer has been merged into Dynamic_performer")
2637 @rule ((2, 11, 11), "layout-set-staff-size -> layout-set-absolute-staff-size")
2639 str = re.sub (r'\(layout-set-staff-size \(\*\s*([0-9.]+)\s*(pt|mm|cm)\)\)',
2640 r'(layout-set-absolute-staff-size (* \1 \2))', str)
2644 @rule ((2, 11, 13), "#'arrow = ##t -> #'bound-details #'right #'arrow = ##t")
2646 str = re.sub (r"\\override\s*([a-zA-Z.]+)\s*#'arrow\s*=\s*##t",
2647 r"\\override \1 #'bound-details #'right #'arrow = ##t",
2650 if re.search ('edge-text', str):
2651 stderr_write (NOT_SMART % _ ("edge-text settings for TextSpanner."))
2652 stderr_write (_ ("Use\n\n%s") %
2653 "\t\\override TextSpanner #'bound-details #'right #'text = <right-text>\n"
2654 "\t\\override TextSpanner #'bound-details #'left #'text = <left-text>\n")
2658 @rule ((2, 11, 15), "TextSpanner #'edge-height -> #'bound-details #'right/left #'text = ...\n\
2659 Remove 'forced-distance for fixed spacing between staves in a PianoStaff.")
2661 def sub_edge_height (m):
2663 for (var, h) in [('left', m.group (3)),
2664 ('right', m.group (4))]:
2670 context = m.group (2)
2674 s += (r"%s \override %sTextSpanner #'bound-details #'%s #'text = \markup { \draw-line #'(0 . %s) }"
2675 % (once, context, var, h))
2682 str = re.sub (r"(\\once)?\s*\\override\s*([a-zA-Z]+\s*[.]\s*)?TextSpanner\s*#'edge-height\s*=\s*#'\(\s*([0-9.-]+)\s+[.]\s+([0-9.-]+)\s*\)", sub_edge_height, str)
2683 if re.search (r"#'forced-distance", str):
2684 stderr_write (NOT_SMART % ("VerticalAlignment #'forced-distance.\n"))
2685 stderr_write (_ ("Use the `alignment-offsets' sub-property of\n"))
2686 stderr_write (_ ("NonMusicalPaperColumn #'line-break-system-details\n"))
2687 stderr_write (_ ("to set fixed distances between staves.\n"))
2691 @rule ((2, 11, 23), "#'break-align-symbol -> #'break-align-symbols")
2693 str = re.sub (r"\\override\s*([a-zA-Z.]+)\s*#'break-align-symbol\s*=\s*#'([a-z-]+)",
2694 r"\\override \1 #'break-align-symbols = #'(\2)", str)
2698 @rule ((2, 11, 35), """scripts.caesura -> scripts.caesura.curved.
2699 """ + _ ("Use #'style not #'dash-fraction to select solid/dashed lines."))
2701 str = re.sub (r"scripts\.caesura",
2702 r"scripts.caesura.curved", str)
2704 if re.search ('dash-fraction', str):
2705 stderr_write (NOT_SMART % _ ("all settings related to dashed lines.\n"))
2706 stderr_write (_ ("Use \\override ... #'style = #'line for solid lines and\n"))
2707 stderr_write (_ ("\t\\override ... #'style = #'dashed-line for dashed lines."))
2711 @rule ((2, 11, 38), """\\setEasyHeads -> \\easyHeadsOn, \\fatText -> \\textLengthOn,
2712 \\emptyText -> \\textLengthOff""")
2714 str = re.sub (r"setEasyHeads", r"easyHeadsOn", str)
2715 str = re.sub (r"fatText", r"textLengthOn", str)
2716 str = re.sub (r"emptyText", r"textLengthOff", str)
2720 @rule ((2, 11, 46), "\\set hairpinToBarline -> \\override Hairpin #'to-barline")
2722 str = re.sub (r"\\set\s+([a-zA-Z]+)\s*.\s*hairpinToBarline\s*=\s*##([tf]+)",
2723 r"\\override \1.Hairpin #'to-barline = ##\2", str)
2724 str = re.sub (r"\\set\s+hairpinToBarline\s*=\s*##([tf]+)",
2725 r"\\override Hairpin #'to-barline = ##\1", str)
2726 str = re.sub (r"\\unset\s+([a-zA-Z]+)\s*.\s*hairpinToBarline",
2727 r"\\revert \1.Hairpin #'to-barline", str)
2728 str = re.sub (r"\\unset\s+hairpinToBarline",
2729 r"\\revert Hairpin #'to-barline", str)
2730 str = re.sub (r"hairpinToBarline\s*=\s*##([tf]+)",
2731 r"\\override Hairpin #'to-barline = ##\1", str)
2732 str = re.sub (r"\\set (de|)crescendoSpanner = #'dashed-line",
2733 r"\\set \1crescendoSpanner = #'text", str)
2737 @rule ((2, 11, 48), "\\compressMusic -> \\scaleDurations")
2739 str = re.sub (r"compressMusic", r"scaleDurations", str)
2743 @rule ((2, 11, 50), _ ("metronomeMarkFormatter uses text markup as second argument,\n\
2744 fret diagram properties moved to fret-diagram-details."))
2746 ## warning 1/2: metronomeMarkFormatter uses text markup as second argument
2747 if re.search ('metronomeMarkFormatter', str):
2748 stderr_write (NOT_SMART % _ ("metronomeMarkFormatter got an additional text argument.\n"))
2749 stderr_write (_ ("The function assigned to Score.metronomeMarkFunction now uses the signature\n%s") %
2750 "\t(format-metronome-markup text dur count context)\n")
2752 ## warning 2/2: fret diagram properties moved to fret-diagram-details
2753 fret_props = ['barre-type',
2761 'xo-font-magnification',
2765 for prop in fret_props:
2766 if re.search (prop, str):
2767 stderr_write (NOT_SMART %
2768 prop + " in fret-diagram properties. Use fret-diagram-details.")
2772 @rule ((2, 11, 51), "\\octave -> \\octaveCheck, \\arpeggioUp -> \\arpeggioArrowUp,\n\
2773 \\arpeggioDown -> \\arpeggioArrowDown, \\arpeggioNeutral -> \\arpeggioNormal,\n\
2774 \\setTextCresc -> \\crescTextCresc, \\setTextDecresc -> \\dimTextDecresc,\n\
2775 \\setTextDecr -> \\dimTextDecr, \\setTextDim -> \\dimTextDim,\n\
2776 \\setHairpinCresc -> \\crescHairpin, \\setHairpinDecresc -> \\dimHairpin,\n\
2777 \\sustainUp -> \\sustainOff, \\sustainDown -> \\sustainOn\n\
2778 \\sostenutoDown -> \\sostenutoOn, \\sostenutoUp -> \\sostenutoOff")
2780 str = re.sub (r"\\octave(?![a-zA-Z])", r"\\octaveCheck", str)
2781 str = re.sub (r"arpeggioUp", r"arpeggioArrowUp", str)
2782 str = re.sub (r"arpeggioDown", r"arpeggioArrowDown", str)
2783 str = re.sub (r"arpeggioNeutral", r"arpeggioNormal", str)
2784 str = re.sub (r"setTextCresc", r"crescTextCresc", str)
2785 str = re.sub (r"setTextDecresc", r"dimTextDecresc", str)
2786 str = re.sub (r"setTextDecr", r"dimTextDecr", str)
2787 str = re.sub (r"setTextDim", r"dimTextDim", str)
2788 str = re.sub (r"setHairpinCresc", r"crescHairpin", str)
2789 str = re.sub (r"setHairpinDecresc", r"dimHairpin", str)
2790 str = re.sub (r"sustainUp", r"sustainOff", str)
2791 str = re.sub (r"sustainDown", r"sustainOn", str)
2792 str = re.sub (r"sostenutoDown", r"sostenutoOn", str)
2793 str = re.sub (r"sostenutoUp", r"sostenutoOff", str)
2796 @rule ((2, 11, 52), "\\setHairpinDim -> \\dimHairpin")
2798 str = str.replace ("setHairpinDim", "dimHairpin")
2801 @rule ((2, 11, 53), "infinite-spacing-height -> extra-spacing-height")
2803 str = re.sub (r"infinite-spacing-height\s+=\s+##t", r"extra-spacing-height = #'(-inf.0 . +inf.0)", str)
2804 str = re.sub (r"infinite-spacing-height\s+=\s+##f", r"extra-spacing-height = #'(0 . 0)", str)
2807 @rule ((2, 11, 55), "#(set-octavation oct) -> \\ottava #oct,\n\
2808 \\put-adjacent markup axis dir markup -> \\put-adjacent axis dir markup markup")
2810 str = re.sub (r"#\(set-octavation (-*[0-9]+)\)", r"\\ottava #\1", str)
2811 if re.search ('put-adjacent', str):
2812 stderr_write (NOT_SMART % _ ("\\put-adjacent argument order.\n"))
2813 stderr_write (_ ("Axis and direction now come before markups:\n"))
2814 stderr_write (_ ("\\put-adjacent axis dir markup markup."))
2817 @rule ((2, 11, 57), "\\center-align -> \\center-column, \\hcenter -> \\center-align")
2819 str = re.sub (r"([\\:]+)center-align", r"\1center-column", str)
2820 str = re.sub (r"hcenter(\s+)", r"center-align\1", str)
2823 @rule ((2, 11, 60), "printallheaders -> print-all-headers")
2825 str = re.sub (r"printallheaders", r"print-all-headers", str)
2828 @rule ((2, 11, 61), "gregorian-init.ly -> gregorian.ly")
2830 str = re.sub (r'\\include(\s+)"gregorian-init.ly"', r'\\include\1"gregorian.ly"', str)
2833 @rule ((2, 11, 62), "makam-init.ly -> makam.ly, \\bigger -> \\larger")
2835 str = re.sub (r'\\include(\s+)"makam-init.ly"', r'\\include\1"makam.ly"', str)
2836 str = re.sub (r"([\\:])bigger", r"\1larger", str)
2839 @rule ((2, 11, 64), "systemSeparatorMarkup -> system-separator-markup,\n\
2840 InnerStaffGroup -> StaffGroup, InnerChoirStaff -> ChoirStaff")
2842 str = re.sub (r'systemSeparatorMarkup', r'system-separator-markup', str)
2843 if re.search (r'\\InnerStaffGroup', str):
2845 stderr_write (NOT_SMART % _("re-definition of InnerStaffGroup.\n"))
2846 stderr_write (FROM_TO % ("InnerStaffGroup", "StaffGroup.\n"))
2847 stderr_write (UPDATE_MANUALLY)
2848 raise FatalConversionError ()
2849 if re.search (r'\\InnerChoirStaff', str):
2851 stderr_write (NOT_SMART % _("re-definition of InnerChoirStaff.\n"))
2852 stderr_write (FROM_TO % ("InnerChoirStaff", "ChoirStaff.\n"))
2853 stderr_write (UPDATE_MANUALLY)
2854 raise FatalConversionError ()
2856 str = re.sub ('InnerStaffGroup', 'StaffGroup', str)
2857 str = re.sub ('InnerChoirStaff', 'ChoirStaff', str)
2861 _ ("Syntax changes for \\addChordShape and \\chord-shape") + "\n" + \
2862 _ ("bump version for release"))
2864 if re.search(r'\\addChordShape', str):
2866 stderr_write (NOT_SMART % _("stringTuning must be added to \
2867 addChordShape call.\n"))
2868 stderr_write (UPDATE_MANUALLY)
2869 raise FatalConversionError ()
2870 if re.search (r'\\chord-shape', str):
2872 stderr_write (NOT_SMART % _("stringTuning must be added to \
2873 chord-shape call.\n"))
2874 stderr_write (UPDATE_MANUALLY)
2875 raise FatalConversionError ()
2879 _ ("Remove oldaddlyrics"))
2881 if re.search(r'\\oldaddlyrics', str):
2883 stderr_write (NOT_SMART % _("oldaddlyrics is no longer supported. \n \
2884 Use addlyrics or lyrsicsto instead.\n"))
2885 stderr_write (UPDATE_MANUALLY)
2886 raise FatalConversionError ()
2889 @rule ((2, 13, 0), _ ("keySignature property not reversed any more\n\
2890 MIDI 47: orchestral strings -> orchestral harp"))
2892 if re.search(r'\set Staff.keySignature', str):
2894 stderr_write (NOT_SMART % _("The alist for Staff.keySignature is no \
2895 longer in reversed order.\n"))
2896 str = str.replace('"orchestral strings"', '"orchestral harp"')
2900 _ ("\\bar \".\" now produces a thick barline\n\
2901 ly:hairpin::after-line-breaking -> ly:spanner::kill-zero-spanned-time\n\
2902 Dash parameters for slurs and ties are now in dash-definition"))
2904 if re.search(r'\\bar\s*"."', str):
2906 stderr_write (NOT_SMART % _("\\bar \".\" now produces a thick barline.\n"))
2907 stderr_write (UPDATE_MANUALLY)
2908 str = re.sub (r'ly:hairpin::after-line-breaking', r'ly:spanner::kill-zero-spanned-time', str)
2909 if re.search("(Slur|Tie)\w+#\'dash-fraction", str) \
2910 or re.search("(Slur|Tie)\w+#\'dash-period", str):
2912 stderr_write (NOT_SMART % _("Dash parameters for slurs and ties are now in \'dash-details.\n"))
2913 stderr_write (UPDATE_MANUALLY)
2917 _ ("Autobeaming rules have changed. override-auto-beam-setting and\n\
2918 revert-auto-beam-setting have been eliminated. \\overrideBeamSettings has been\n\
2919 added. beatGrouping has been eliminated.\n\
2920 Different settings for vertical layout.\n\
2921 ly:system-start-text::print -> system-start-text::print\n\
2922 Beam #'thickness -> Beam #'beam-thickness\n\
2923 ly:note-head::brew-ez-stencil -> note-head::brew-ez-stencil\n\
2924 ly:ambitus::print -> ambitus::print\n\
2925 Explicit dynamics context definition from `Piano centered dynamics'\n\
2926 template replaced by new `Dynamics' context."))
2928 if re.search("override-auto-beam-setting", str):
2930 stderr_write (NOT_SMART % _("override-auto-beam-setting.\n\
2931 Autobeam settings are now overriden with \\overrideBeamSettings.\n"))
2932 stderr_write (UPDATE_MANUALLY)
2933 if re.search("revert-auto-beam-setting", str):
2935 stderr_write (NOT_SMART % _("override-auto-beam-setting.\n\
2936 Autobeam settings are now reverted with \\revertBeamSettings.\n"))
2937 stderr_write (UPDATE_MANUALLY)
2938 str = re.sub(r"\\set\s+beatGrouping", r"\\setBeatGrouping", str)
2939 if re.search(r"\w+\s*.\s*beatGrouping", str):
2940 stderr_write (NOT_SMART % _("beatGrouping. \n\
2941 beatGrouping with a specified context must now be accomplished with\n\
2942 \\overrideBeamSettings.\n"))
2943 stderr_write (UPDATE_MANUALLY)
2944 if re.search(r'alignment-offsets', str):
2946 stderr_write(NOT_SMART % _("alignment-offsets has been changed to alignment-distances: \
2947 you must now specify the distances between staves rather than the offset of staves.\n"))
2948 stderr_write(UPDATE_MANUALLY)
2949 str = re.sub ('ly:(system-start-text::print|note-head::brew-ez-stencil|ambitus::print)',
2951 str = re.sub ('(\\bBeam\\s+#\')(?=thickness\\b)', '\\1beam-', str)
2952 str = re.sub (r'(\\context\s*\{{1}[^\}]+\\name\s+"*Dynamics"*[^\}]*\}{1})',
2957 _ ("Remove obsolete engravers/translators: Note_swallow_translator,\n\
2958 Rest_swallow_translator, Skip_event_swallow_translator, Swallow_engraver,\n\
2959 Swallow_performer and String_number_engraver.\n\
2960 New vertical spacing variables."))
2962 str = re.sub (r'\\(consists|remove)\s+"*(Swallow_(engraver|performer)|'
2963 '(Note|Rest|Skip_event)_swallow_translator|String_number_engraver)"*',
2966 str = re.sub (r"page-top-space\s*=\s*#([0-9.]+)",
2967 r"top-system-spacing #'space = #\1",
2969 str = re.sub (r"between-system-space\s*=\s*#([0-9.]+)",
2970 r"between-system-spacing #'space = #\1\nbetween-scores-system-spacing #'space = #\1",
2972 str = re.sub (r"between-system-padding\s*=\s*#([0-9.]+)",
2973 r"between-system-spacing #'padding = #\1\nbetween-scores-system-spacing #'padding = #\1",
2975 str = re.sub (r"(after|between|before)-title-space\s*=\s*#([0-9.]+)",
2976 r"\1-title-spacing #'space = #\2",
2979 if re.search(r'minimum-Y-extent', str):
2981 stderr_write(NOT_SMART % _("vertical spacing has been changed; minimum-Y-extent is obsolete.\n"))
2982 stderr_write(UPDATE_MANUALLY)
2987 _ ("Unify fetaNumber and fetaDynamic encodings"))
2989 return re.sub(r'\bfeta(Number|Dynamic)', 'fetaText', str)
2992 _ ("\RemoveEmpty*StaffContext -> \*Staff \RemoveEmptyStaves"))
2994 str = re.sub (r"\\RemoveEmpty(|Drum|Rhythmic|Tab)StaffContext",
2995 r"\\\1Staff \\RemoveEmptyStaves",
2997 str = re.sub (r"\\AncientRemoveEmptyStaffContext",
2998 r"\\VaticanaStaff \\RemoveEmptyStaves",
3002 # Guidelines to write rules (please keep this at the end of this file)
3004 # - keep at most one rule per version; if several conversions should be done,
3005 # concatenate them into a single "conv" function;
3007 # - enclose strings to be localized with `_(' and `)';
3009 # - write rule for bumping major stable version with
3011 # _ ("bump version for release")
3013 # as exact description.