1 # (setq py-indent-offset 4)
12 NOT_SMART = "\n" + _ ("Not smart enough to convert %s.") + "\n"
13 UPDATE_MANUALLY = _ ("Please refer to the manual for details, and update manually.") + "\n"
14 FROM_TO = _ ("%s has been replaced by %s") + "\n"
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):
52 stderr_write (NOT_SMART % "\\multi")
56 @rule ((0, 1, 19), _ ('deprecated %s') % '\\octave')
58 if re.search ('\\\\octave', str):
59 stderr_write (NOT_SMART % "\\octave")
60 stderr_write (UPDATE_MANUALLY)
61 # raise FatalConversionError ()
65 @rule ((0, 1, 20), _ ('deprecated \\textstyle, new \\key syntax'))
67 str = re.sub ('\\\\textstyle([^;]+);',
68 '\\\\property Lyrics . textstyle = \\1', str)
69 # harmful to current .lys
70 # str = re.sub ('\\\\key([^;]+);', '\\\\accidentals \\1;', str)
74 @rule ((0, 1, 21), '\\musical_pitch -> \\musicalpitch, \\meter -> \\time')
76 str = re.sub ('\\\\musical_pitch', '\\\\musicalpitch',str)
77 str = re.sub ('\\\\meter', '\\\\time',str)
81 @rule ((1, 0, 0), _ ("bump version for release"))
86 @rule ((1, 0, 1), '\\accidentals -> \\keysignature, specialaccidentals -> keyoctaviation')
88 str = re.sub ('\\\\accidentals', '\\\\keysignature',str)
89 str = re.sub ('specialaccidentals *= *1', 'keyoctaviation = 0',str)
90 str = re.sub ('specialaccidentals *= *0', 'keyoctaviation = 1',str)
94 @rule ((1, 0, 2), _ ('\\header { key = concat + with + operator }'))
96 if re.search ('\\\\header', str):
97 stderr_write (NOT_SMART % _ ("new \\header format"))
101 @rule ((1, 0, 3), '\\melodic -> \\notes')
103 str = re.sub ('\\\\melodic([^a-zA-Z])', '\\\\notes\\1',str)
107 @rule ((1, 0, 4), 'default_{paper,midi}')
109 str = re.sub ('default_paper *=', '',str)
110 str = re.sub ('default_midi *=', '',str)
114 @rule ((1, 0, 5), 'ChoireStaff -> ChoirStaff')
116 str = re.sub ('ChoireStaff', 'ChoirStaff',str)
117 str = re.sub ('\\\\output', 'output = ',str)
121 @rule ((1, 0, 6), 'foo = \\translator {\\type .. } ->\\translator {\\type ..; foo; }')
123 if re.search ('[a-zA-Z]+ = *\\translator',str):
124 stderr_write (NOT_SMART % _ ("\\translator syntax"))
125 # raise FatalConversionError ()
129 @rule ((1, 0, 7), '\\lyric -> \\lyrics')
131 str = re.sub ('\\\\lyrics*', '\\\\lyrics',str)
135 @rule ((1, 0, 10), '[2/3 ]1/1 -> \\times 2/3 ')
137 str = re.sub ('\\\\\\[/3+', '\\\\times 2/3 { ',str)
138 str = re.sub ('\\[/3+', '\\\\times 2/3 { [',str)
139 str = re.sub ('\\\\\\[([0-9/]+)', '\\\\times \\1 {',str)
140 str = re.sub ('\\[([0-9/]+)', '\\\\times \\1 { [',str)
141 str = re.sub ('\\\\\\]([0-9/]+)', '}', str)
142 str = re.sub ('\\\\\\]', '}',str)
143 str = re.sub ('\\]([0-9/]+)', '] }', str)
147 @rule ((1, 0, 12), 'Chord syntax stuff')
152 @rule ((1, 0, 13), '<a ~ b> c -> <a b> ~ c')
154 str = re.sub ('<([^>~]+)~([^>]*)>','<\\1 \\2> ~', str)
158 @rule ((1, 0, 14), '<[a b> <a b]>c -> [<a b> <a b>]')
160 str = re.sub ('<\\[','[<', str)
161 str = re.sub ('\\]>','>]', str)
165 @rule ((1, 0, 16), '\\type -> \\context, textstyle -> textStyle')
167 str = re.sub ('\\\\type([^\n]*engraver)','\\\\TYPE\\1', str)
168 str = re.sub ('\\\\type([^\n]*performer)','\\\\TYPE\\1', str)
169 str = re.sub ('\\\\type','\\\\context', str)
170 str = re.sub ('\\\\TYPE','\\\\type', str)
171 str = re.sub ('textstyle','textStyle', str)
175 @rule ((1, 0, 18), _ ('\\repeat NUM Music Alternative -> \\repeat FOLDSTR Music Alternative'))
177 if re.search ('\\\\repeat',str):
178 stderr_write (NOT_SMART % "\\repeat")
179 # raise FatalConversionError ()
183 @rule ((1, 0, 19), 'fontsize -> fontSize, midi_instrument -> midiInstrument, SkipBars -> skipBars')
185 str = re.sub ('SkipBars','skipBars', str)
186 str = re.sub ('fontsize','fontSize', str)
187 str = re.sub ('midi_instrument','midiInstrument', str)
191 @rule ((1, 0, 20), '{,tie,slur}ydirection -> {v,tieV,slurV}erticalDirection')
193 str = re.sub ('tieydirection','tieVerticalDirection', str)
194 str = re.sub ('slurydirection','slurVerticalDirection', str)
195 str = re.sub ('ydirection','verticalDirection', str)
199 @rule ((1, 0, 21), 'hshift -> horizontalNoteShift')
201 str = re.sub ('hshift','horizontalNoteShift', str)
205 @rule ((1, 1, 52), _ ('deprecate %s') % '\\grouping')
207 str = re.sub ('\\\\grouping[^;]*;','', str)
211 @rule ((1, 1, 55), '\\wheel -> \\coda')
213 str = re.sub ('\\\\wheel','\\\\coda', str)
217 @rule ((1, 1, 65), 'slurdash -> slurDash, keyoctaviation -> keyOctaviation')
219 str = re.sub ('keyoctaviation','keyOctaviation', str)
220 str = re.sub ('slurdash','slurDash', str)
224 @rule ((1, 1, 66), 'semi -> volta')
226 str = re.sub ('\\\\repeat *\"?semi\"?','\\\\repeat "volta"', str)
230 @rule ((1, 1, 67), 'beamAuto -> noAutoBeaming')
232 str = re.sub ('\"?beamAuto\"? *= *\"?0?\"?','noAutoBeaming = "1"', str)
236 @rule ((1, 2, 0), 'automaticMelismas -> automaticMelismata')
238 str = re.sub ('automaticMelismas', 'automaticMelismata', str)
242 @rule ((1, 2, 1), 'dynamicDir -> dynamicDirection')
244 str = re.sub ('dynamicDir\\b', 'dynamicDirection', str)
248 @rule ((1, 3, 4), '\\cadenza -> \\cadenza{On|Off}')
250 str = re.sub ('\\\\cadenza *0 *;', '\\\\cadenzaOff', str)
251 str = re.sub ('\\\\cadenza *1 *;', '\\\\cadenzaOn', str)
255 @rule ((1, 3, 5), 'beamAuto moment properties')
257 str = re.sub ('"?beamAuto([^"=]+)"? *= *"([0-9]+)/([0-9]+)" *;*',
258 'beamAuto\\1 = #(make-moment \\2 \\3)',
263 @rule ((1, 3, 17), 'stemStyle -> flagStyle')
265 str = re.sub ('stemStyle',
271 @rule ((1, 3, 18), 'staffLineLeading -> staffSpace')
273 str = re.sub ('staffLineLeading',
279 @rule ((1, 3, 23), _ ('deprecate %s ') % '\\repetitions')
281 if re.search ('\\\\repetitions',str):
282 stderr_write (NOT_SMART % "\\repetitions")
283 # raise FatalConversionError ()
287 @rule ((1, 3, 35), 'textEmptyDimension -> textNonEmpty')
289 str = re.sub ('textEmptyDimension *= *##t',
290 'textNonEmpty = ##f',
292 str = re.sub ('textEmptyDimension *= *##f',
293 'textNonEmpty = ##t',
298 @rule ((1, 3, 38), '\musicalpitch { a b c } -> #\'(a b c)')
300 str = re.sub ("([a-z]+)[ \t]*=[ \t]*\\\\musicalpitch *{([- 0-9]+)} *\n",
301 "(\\1 . (\\2))\n", str)
302 str = re.sub ("\\\\musicalpitch *{([0-9 -]+)}",
303 "\\\\musicalpitch #'(\\1)", str)
304 if re.search ('\\\\notenames',str):
305 stderr_write (NOT_SMART % _ ("new \\notenames format"))
309 @rule ((1, 3, 39), '\\key A ; ->\\key a;')
312 return '\\key %s;' % match.group (1).lower ()
314 str = re.sub ("\\\\key ([^;]+);", replace, str)
318 @rule ((1, 3, 41), '[:16 c4 d4 ] -> \\repeat "tremolo" 2 { c16 d16 }')
320 if re.search ('\\[:',str):
321 stderr_write (NOT_SMART % _ ("new tremolo format"))
325 @rule ((1, 3, 42), _ ('Staff_margin_engraver deprecated, use Instrument_name_engraver'))
327 str = re.sub ('Staff_margin_engraver' , 'Instrument_name_engraver', str)
331 @rule ((1, 3, 49), 'noteHeadStyle value: string -> symbol')
333 str = re.sub ('note[hH]eadStyle\\s*=\\s*"?(\\w+)"?' , "noteHeadStyle = #'\\1", str)
337 @rule ((1, 3, 58), 'noteHeadStyle value: string -> symbol')
339 if re.search ('\\\\keysignature', str):
340 stderr_write (NOT_SMART % '\\keysignature')
344 @rule ((1, 3, 59), '\key X ; -> \key X major; ')
346 str = re.sub (r"""\\key *([a-z]+) *;""", r"""\\key \1 \major;""",str);
350 @rule ((1, 3, 68), 'latexheaders = "\\input global" -> latexheaders = "global"')
352 str = re.sub (r'latexheaders *= *"\\\\input ',
358 # TODO: lots of other syntax changes should be done here as well
359 @rule ((1, 3, 92), 'basicXXXProperties -> XXX, Repeat_engraver -> Volta_engraver')
361 str = re.sub ('basicCollisionProperties', 'NoteCollision', str)
362 str = re.sub ('basicVoltaSpannerProperties' , "VoltaBracket", str)
363 str = re.sub ('basicKeyProperties' , "KeySignature", str)
365 str = re.sub ('basicClefItemProperties' ,"Clef", str)
368 str = re.sub ('basicLocalKeyProperties' ,"Accidentals", str)
369 str = re.sub ('basicMarkProperties' ,"Accidentals", str)
370 str = re.sub ('basic([A-Za-z_]+)Properties', '\\1', str)
372 str = re.sub ('Repeat_engraver' ,'Volta_engraver', str)
376 @rule ((1, 3, 93), _ ('change property definition case (eg. onevoice -> oneVoice)'))
378 # Ugh, but meaning of \stemup changed too
379 # maybe we should do \stemup -> \stemUp\slurUp\tieUp ?
380 str = re.sub ('\\\\stemup', '\\\\stemUp', str)
381 str = re.sub ('\\\\stemdown', '\\\\stemDown', str)
382 str = re.sub ('\\\\stemboth', '\\\\stemBoth', str)
384 str = re.sub ('\\\\slurup', '\\\\slurUp', str)
385 str = re.sub ('\\\\slurboth', '\\\\slurBoth', str)
386 str = re.sub ('\\\\slurdown', '\\\\slurDown', str)
387 str = re.sub ('\\\\slurdotted', '\\\\slurDotted', str)
388 str = re.sub ('\\\\slurnormal', '\\\\slurNoDots', str)
390 str = re.sub ('\\\\shiftoff', '\\\\shiftOff', str)
391 str = re.sub ('\\\\shifton', '\\\\shiftOn', str)
392 str = re.sub ('\\\\shiftonn', '\\\\shiftOnn', str)
393 str = re.sub ('\\\\shiftonnn', '\\\\shiftOnnn', str)
395 str = re.sub ('\\\\onevoice', '\\\\oneVoice', str)
396 str = re.sub ('\\\\voiceone', '\\\\voiceOne', str)
397 str = re.sub ('\\\\voicetwo', '\\\\voiceTwo', str)
398 str = re.sub ('\\\\voicethree', '\\\\voiceThree', str)
399 str = re.sub ('\\\\voicefour', '\\\\voiceFour', str)
401 # I don't know exactly when these happened...
402 # ugh, we lose context setting here...
403 str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\stemUp\\\\slurUp\\\\tieUp', str)
404 str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\stemDown\\\\slurDown\\\\tieDown', str)
405 str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\stemBoth\\\\slurBoth\\\\tieBoth', str)
407 str = re.sub ('verticalDirection[^=]*= *#?"?(1|(\\\\up))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #1', str)
408 str = re.sub ('verticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #-1', str)
409 str = re.sub ('verticalDirection[^=]*= *#?"?(0|(\\\\center))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #0', str)
411 str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\\\1Up', str)
412 str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\\\1Down', str)
413 str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\\\1Both', str)
415 # (lacks capitalization slur -> Slur)
416 str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\1 \\\\override #\'direction = #1', str)
417 str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\1 \\override #\'direction = #-1', str)
418 str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\1 \\\\override #\'direction = #0', str)
421 str = re.sub ('\\\\property *[^ .]*[.]?dynamicDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\dynamicUp', str)
422 str = re.sub ('\\\\property *[^ .]*[.]?dyn[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\dynamicDown', str)
423 str = re.sub ('\\\\property *[^ .]*[.]?dyn[^=]*= *#?"?(0|(\\\\center))"?', '\\\\dynamicBoth', str)
425 str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)Dash[^=]*= *#?"?(0|(""))"?', '\\\\\\1NoDots', str)
426 str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)Dash[^=]*= *#?"?([1-9]+)"?', '\\\\\\1Dotted', str)
428 str = re.sub ('\\\\property *[^ .]*[.]?noAutoBeaming[^=]*= *#?"?(0|(""))"?', '\\\\autoBeamOn', str)
429 str = re.sub ('\\\\property *[^ .]*[.]?noAutoBeaming[^=]*= *#?"?([1-9]+)"?', '\\\\autoBeamOff', str)
433 @rule ((1, 3, 97), 'ChordName -> ChordNames')
435 str = re.sub ('ChordNames*', 'ChordNames', str)
436 if re.search ('\\\\textscript "[^"]* *"[^"]*"', str):
437 stderr_write (NOT_SMART % _ ("new \\textscript markup text"))
439 str = re.sub ('\\textscript +("[^"]*")', '\\textscript #\\1', str)
442 # TODO: add lots of these
444 @rule ((1, 3, 98), 'CONTEXT.textStyle -> GROB.#font-style ')
446 str = re.sub ('\\\\property *"?Voice"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Voice.TextScript \\\\set #\'font-style = #\'\\1', str)
447 str = re.sub ('\\\\property *"?Lyrics"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Lyrics.LyricText \\\\set #\'font-style = #\'\\1', str)
449 str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?timeSignatureStyle"? *= *"([^"]*)"', '\\\\property \\1.TimeSignature \\\\override #\'style = #\'\\2', str)
451 str = re.sub ('"?timeSignatureStyle"? *= *#?""', 'TimeSignature \\\\override #\'style = ##f', str)
453 str = re.sub ('"?timeSignatureStyle"? *= *#?"([^"]*)"', 'TimeSignature \\\\override #\'style = #\'\\1', str)
455 str = re.sub ('#\'style *= #*"([^"])"', '#\'style = #\'\\1', str)
457 str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?horizontalNoteShift"? *= *"?#?([-0-9]+)"?', '\\\\property \\1.NoteColumn \\\\override #\'horizontal-shift = #\\2', str)
460 str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *""', '\\\\property \\1.Stem \\\\override #\'flag-style = ##f', str)
462 str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *"([^"]*)"', '\\\\property \\1.Stem \\\\override #\'flag-style = #\'\\2', str)
466 @rule ((1, 3, 102), 'beamAutoEnd -> autoBeamSettings \\push (end * * * *)')
468 str = re.sub ('"?beamAutoEnd_([0-9]*)"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(end 1 \\1 * *) = \\2', str)
469 str = re.sub ('"?beamAutoBegin_([0-9]*)"? *= *(#\\([^)]*\))', 'autoBeamSettings \\push #\'(begin 1 \\1 * *) = \\2', str)
470 str = re.sub ('"?beamAutoEnd"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(end * * * *) = \\1', str)
471 str = re.sub ('"?beamAutoBegin"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(begin * * * *) = \\1', str)
475 @rule ((1, 3, 111), '\\push -> \\override, \\pop -> \\revert')
477 str = re.sub ('\\\\push', '\\\\override', str)
478 str = re.sub ('\\\\pop', '\\\\revert', str)
482 @rule ((1, 3, 113), 'LyricVoice -> LyricsVoice')
484 str = re.sub ('LyricVoice', 'LyricsVoice', str)
486 str = re.sub ('Chord[Nn]ames*.Chord[Nn]ames*', 'ChordNames.ChordName', str)
487 str = re.sub ('Chord[Nn]ames([ \t\n]+\\\\override)', 'ChordName\\1', str)
491 def regularize_id (str):
498 elif x in string.digits:
499 x = chr(ord (x) - ord ('0') +ord ('A'))
500 elif x not in string.letters:
502 elif x in string.lowercase and lastx == '_':
509 @rule ((1, 3, 117), _ ('identifier names: %s') % '$!foo_bar_123 -> xfooBarABC')
511 def regularize_dollar_reference (match):
512 return regularize_id (match.group (1))
513 def regularize_assignment (match):
514 return '\n' + regularize_id (match.group (1)) + ' = '
515 str = re.sub ('\$([^\t\n ]+)', regularize_dollar_reference, str)
516 str = re.sub ('\n([^ \t\n]+)[ \t]*= *', regularize_assignment, str)
520 @rule ((1, 3, 120), 'paper_xxx -> paperXxxx, pedalup -> pedalUp.')
522 def regularize_paper (match):
523 return regularize_id (match.group (1))
524 str = re.sub ('(paper_[a-z]+)', regularize_paper, str)
525 str = re.sub ('sustainup', 'sustainUp', str)
526 str = re.sub ('nobreak', 'noBreak', str)
527 str = re.sub ('sustaindown', 'sustainDown', str)
528 str = re.sub ('sostenutoup', 'sostenutoUp', str)
529 str = re.sub ('sostenutodown', 'sostenutoDown', str)
530 str = re.sub ('unachorda', 'unaChorda', str)
531 str = re.sub ('trechorde', 'treChorde', str)
535 @rule ((1, 3, 122), 'drarnChords -> chordChanges, \\musicalpitch -> \\pitch')
537 str = re.sub ('drarnChords', 'chordChanges', str)
538 str = re.sub ('\\musicalpitch', '\\pitch', str)
542 @rule ((1, 3, 136), 'ly-X-elt-property -> ly-X-grob-property')
544 str = re.sub ('ly-([sg])et-elt-property', 'ly-\\1et-grob-property', str)
548 @rule ((1, 3, 138), _ ('point-and-click argument changed to procedure.'))
550 str = re.sub ('point-and-click +#t', 'point-and-click line-column-location', str)
554 @rule ((1, 3, 138), 'followThread -> followVoice.')
556 str = re.sub ('followThread', 'followVoice', str)
557 str = re.sub ('Thread.FollowThread', 'Voice.VoiceFollower', str)
558 str = re.sub ('FollowThread', 'VoiceFollower', str)
562 @rule ((1, 3, 139), 'font-point-size -> font-design-size.')
564 str = re.sub ('font-point-size', 'font-design-size', str)
568 @rule ((1, 3, 141), 'xNoDots -> xSolid')
570 str = re.sub ('([a-zA-Z]*)NoDots', '\\1Solid', str)
574 @rule ((1, 3, 144), 'Chorda -> Corda')
576 str = re.sub ('([Cc])hord([ea])', '\\1ord\\2', str)
580 @rule ((1, 3, 145), 'ContextNameXxxxVerticalExtent -> XxxxVerticalExtent')
582 str = re.sub ('([A-Za-z]+)MinimumVerticalExtent', 'MinimumV@rticalExtent', str)
583 str = re.sub ('([A-Za-z]+)ExtraVerticalExtent', 'ExtraV@rticalExtent', str)
584 str = re.sub ('([A-Za-z]+)VerticalExtent', 'VerticalExtent', str)
585 str = re.sub ('ExtraV@rticalExtent', 'ExtraVerticalExtent', str)
586 str = re.sub ('MinimumV@rticalExtent', 'MinimumVerticalExtent', str)
590 @rule ((1, 3, 146), _('semicolons removed'))
592 str = re.sub ('\\\\key[ \t]*;', '\\key \\default;', str)
593 str = re.sub ('\\\\mark[ \t]*;', '\\mark \\default;', str)
595 # Make sure groups of more than one ; have space before
596 # them, so that non of them gets removed by next rule
597 str = re.sub ("([^ \n\t;]);(;+)", "\\1 ;\\2", str)
599 # Only remove ; that are not after spaces, # or ;
600 # Otherwise we interfere with Scheme comments,
601 # which is badbadbad.
602 str = re.sub ("([^ \t;#]);", "\\1", str)
606 @rule ((1, 3, 147), 'default-neutral-direction -> neutral-direction')
608 str = re.sub ('default-neutral-direction', 'neutral-direction',str)
612 @rule ((1, 3, 148), '"(align" -> "(axis", "(rows" -> "(columns"')
614 str = re.sub ('\(align', '(axis', str)
615 str = re.sub ('\(rows', '(columns', str)
619 @rule ((1, 5, 33), 'SystemStartDelimiter -> systemStartDelimiter')
621 str = re.sub ('SystemStartDelimiter', 'systemStartDelimiter', str)
625 @rule ((1, 5, 38), 'arithmetic... -> spacing...')
627 str = re.sub ('arithmetic-multiplier', 'spacing-increment', str)
628 str = re.sub ('arithmetic-basicspace', 'shortest-duration-space', str)
633 @rule ((1, 5, 40), _ ('%s property names') % 'breakAlignOrder')
638 "Instrument_name": "instrument-name",
639 "Left_edge_item": "left-edge",
640 "Span_bar": "span-bar",
641 "Breathing_sign": "breathing-sign",
642 "Staff_bar": "staff-bar",
644 "Key_item": "key-signature",
645 "Time_signature": "time-signature",
648 props = match.group (1)
649 for (k,v) in break_dict.items():
650 props = re.sub (k, v, props)
651 return "breakAlignOrder = #'(%s)" % props
653 str = re.sub ("breakAlignOrder *= *#'\\(([a-z_\n\tA-Z ]+)\\)",
658 @rule ((1, 5, 49), 'noAutoBeaming -> autoBeaming')
660 str = re.sub ('noAutoBeaming *= *##f', 'autoBeaming = ##t', str)
661 str = re.sub ('noAutoBeaming *= *##t', 'autoBeaming = ##f', str)
665 @rule ((1, 5, 52), 'tuplet-X-visibility -> X-visibility')
667 str = re.sub ('tuplet-bracket-visibility', 'bracket-visibility', str)
668 str = re.sub ('tuplet-number-visibility', 'number-visibility', str)
672 @rule ((1, 5, 56), 'Pitch::transpose -> ly-transpose-pitch')
674 str = re.sub ('Pitch::transpose', 'ly-transpose-pitch', str)
678 @rule ((1, 5, 58), _ ('deprecate %s') % 'textNonEmpty')
680 str = re.sub ('textNonEmpty *= *##t', "TextScript \\set #'no-spacing-rods = ##f", str)
681 str = re.sub ('textNonEmpty *= *##f', "TextScript \\set #'no-spacing-rods = ##t", str)
685 @rule ((1, 5, 59), 'XxxxVerticalExtent -> xxxVerticalExtent')
687 str = re.sub ('MinimumVerticalExtent', 'minimumV@rticalExtent', str)
688 str = re.sub ('minimumVerticalExtent', 'minimumV@rticalExtent', str)
689 str = re.sub ('ExtraVerticalExtent', 'extraV@rticalExtent', str)
690 str = re.sub ('extraVerticalExtent', 'extraV@rticalExtent', str)
691 str = re.sub ('VerticalExtent', 'verticalExtent', str)
692 str = re.sub ('extraV@rticalExtent', 'extraVerticalExtent', str)
693 str = re.sub ('minimumV@rticalExtent', 'minimumVerticalExtent', str)
697 @rule ((1, 5, 62), 'visibility-lambda -> break-visibility')
699 str = re.sub ('visibility-lambda', 'break-visibility', str)
703 @rule ((1, 5, 67), _ ('automaticMelismata turned on by default'))
705 if re.search (r'\addlyrics',str) \
706 and re.search ('automaticMelismata', str) == None:
707 stderr_write (NOT_SMART % "automaticMelismata")
708 stderr_write (_ ("automaticMelismata is turned on by default since 1.5.67."))
710 raise FatalConversionError ()
714 @rule ((1, 5, 68), 'ly-set-X-property -> ly-set-X-property!')
716 str = re.sub ('ly-set-grob-property([^!])', 'ly-set-grob-property!\1', str)
717 str = re.sub ('ly-set-mus-property([^!])', 'ly-set-mus-property!\1', str)
721 @rule ((1, 5, 71), 'extent-[XY] -> [XY]-extent')
723 str = re.sub ('extent-X', 'X-extent', str)
724 str = re.sub ('extent-Y', 'Y-extent', str)
728 @rule ((1, 5, 72), 'set! point-and-click -> set-point-and-click!')
730 str = re.sub ("""#\(set! +point-and-click +line-column-location\)""",
731 """#(set-point-and-click! \'line-column)""", str)
732 str = re.sub ("""#\(set![ \t]+point-and-click +line-location\)""",
733 '#(set-point-and-click! \'line)', str)
734 str = re.sub ('#\(set! +point-and-click +#f\)',
735 '#(set-point-and-click! \'none)', str)
739 @rule ((1, 6, 5), 'Stems: flag-style -> stroke-style; style -> flag-style')
741 str = re.sub ('flag-style', 'stroke-style', str)
742 str = re.sub (r"""Stem([ ]+)\\override #'style""", r"""Stem \\override #'flag-style""", str);
743 str = re.sub (r"""Stem([ ]+)\\set([ ]+)#'style""", r"""Stem \\set #'flag-style""", str);
747 def subst_req_name (match):
748 return "(make-music-by-name \'%sEvent)" % regularize_id (match.group(1))
751 @rule ((1, 7, 1), 'ly-make-music foo_bar_req -> make-music-by-name FooBarEvent')
753 str = re.sub ('\\(ly-make-music *\"([A-Z][a-z_]+)_req\"\\)', subst_req_name, str)
754 str = re.sub ('Request_chord', 'EventChord', str)
759 "text" : 'TextSpanEvent',
760 "decrescendo" : 'DecrescendoEvent',
761 "crescendo" : 'CrescendoEvent',
762 "Sustain" : 'SustainPedalEvent',
763 "slur" : 'SlurEvent',
764 "UnaCorda" : 'UnaCordaEvent',
765 "Sostenuto" : 'SostenutoEvent',
768 def subst_ev_name (match):
770 if re.search ('start', match.group(1)):
772 mtype = spanner_subst[match.group(2)]
773 return "(make-span-event '%s %s)" % (mtype , stype)
775 def subst_definition_ev_name(match):
776 return ' = #%s' % subst_ev_name (match)
778 def subst_inline_ev_name (match):
779 s = subst_ev_name (match)
780 return '#(ly-export %s)' % s
782 def subst_csp_definition (match):
783 return ' = #(make-event-chord (list %s))' % subst_ev_name (match)
785 def subst_csp_inline (match):
786 return '#(ly-export (make-event-chord (list %s)))' % subst_ev_name (match)
789 @rule ((1, 7, 2), '\\spanrequest -> #(make-span-event .. ), \script -> #(make-articulation .. )')
791 str = re.sub (r' *= *\\spanrequest *([^ ]+) *"([^"]+)"', subst_definition_ev_name, str)
792 str = re.sub (r'\\spanrequest *([^ ]+) *"([^"]+)"', subst_inline_ev_name, str)
793 str = re.sub (r' *= *\\commandspanrequest *([^ ]+) *"([^"]+)"', subst_csp_definition, str)
794 str = re.sub (r'\\commandspanrequest *([^ ]+) *"([^"]+)"', subst_csp_inline, str)
795 str = re.sub (r'ly-id ', 'ly-import ', str)
797 str = re.sub (r' *= *\\script "([^"]+)"', ' = #(make-articulation "\\1")', str)
798 str = re.sub (r'\\script "([^"]+)"', '#(ly-export (make-articulation "\\1"))', str)
802 @rule ((1, 7, 3), 'ly- -> ly:')
804 str = re.sub (r'\(ly-', '(ly:', str)
814 'music-duration-length',
819 'transpose-key-alist',
823 'set-point-and-click!',
832 'music-duration-compress',
833 'set-point-and-click!'
836 origre = r'\b(%s)' % '|'.join (changed)
838 str = re.sub (origre, r'ly:\1',str)
839 str = re.sub ('set-point-and-click!', 'set-point-and-click', str)
843 @rule ((1, 7, 4), '<< >> -> < < > >')
845 if re.search ('new-chords-done',str):
848 str = re.sub (r'<<', '< <', str)
849 str = re.sub (r'>>', '> >', str)
853 @rule ((1, 7, 5), '\\transpose TO -> \\transpose FROM TO')
855 str = re.sub (r"\\transpose", r"\\transpose c'", str)
856 str = re.sub (r"\\transpose c' *([a-z]+)'", r"\\transpose c \1", str)
860 @rule ((1, 7, 6), 'note\\script -> note-\script')
876 origstr = '|'.join (kws)
877 str = re.sub (r'([^_^-])\\(%s)\b' % origstr, r'\1-\\\2', str)
881 @rule ((1, 7, 10), "\property ChordName #'style -> #(set-chord-name-style 'style)")
883 str = re.sub (r"\\property *ChordNames *\. *ChordName *\\(set|override) *#'style *= *#('[a-z]+)",
884 r"#(set-chord-name-style \2)", str)
885 str = re.sub (r"\\property *ChordNames *\. *ChordName *\\revert *#'style",
890 @rule ((1, 7, 11), "transpose-pitch -> pitch-transpose")
892 str = re.sub (r"ly:transpose-pitch", "ly:pitch-transpose", str)
896 @rule ((1, 7, 13), "ly:XX-molecule-YY -> ly:molecule-XX-YY")
898 str = re.sub (r"ly:get-molecule-extent", "ly:molecule-get-extent", str)
899 str = re.sub (r"ly:set-molecule-extent!", "ly:molecule-set-extent!", str)
900 str = re.sub (r"ly:add-molecule", "ly:molecule-add", str)
901 str = re.sub (r"ly:combine-molecule-at-edge", "ly:molecule-combine-at-edge", str)
902 str = re.sub (r"ly:align-to!", "ly:molecule-align-to!", str)
906 @rule ((1, 7, 15), "linewidth = -1 -> raggedright = ##t")
908 str = re.sub (r"linewidth *= *-[0-9.]+ *(\\mm|\\cm|\\in|\\pt)?", 'raggedright = ##t', str )
912 @rule ((1, 7, 16), "divisiomaior -> divisioMaior")
914 str = re.sub ("divisiomaior",
916 str = re.sub ("divisiominima",
917 "divisioMinima", str)
918 str = re.sub ("divisiomaxima",
919 "divisioMaxima", str)
923 @rule ((1, 7, 17), "Skip_req -> Skip_event")
925 str = re.sub ("Skip_req_swallow_translator",
926 "Skip_event_swallow_translator", str)
930 @rule ((1, 7, 18), "groupOpen/Close -> start/stopGroup, #'outer -> #'enclose-bounds")
932 str = re.sub ("groupOpen",
934 str = re.sub ("groupClose",
936 str = re.sub ("#'outer",
937 "#'enclose-bounds", str)
942 @rule ((1, 7, 19), _ ("remove %s") % "GraceContext")
944 if re.search( r'\\GraceContext', str):
945 stderr_write (NOT_SMART % "GraceContext")
946 stderr_write (FROM_TO \
947 % ("GraceContext", "#(add-to-grace-init .. )"))
948 stderr_write (UPDATE_MANUALLY)
949 raise FatalConversionError ()
951 str = re.sub ('HaraKiriStaffContext', 'RemoveEmptyStaffContext', str)
955 @rule ((1, 7, 22), "#'type -> #'style")
958 r"(set|override|revert) *#'type",
964 @rule ((1, 7, 23), "barNonAuto -> automaticBars")
967 "barNonAuto *= *##t",
968 "automaticBars = ##f",
971 "barNonAuto *= *##f",
972 "automaticBars = ##t",
977 @rule ((1, 7, 24), _ ("cluster syntax"))
979 if re.search( r'-(start|stop)Cluster', str):
980 stderr_write (NOT_SMART % _ ("cluster syntax"))
981 stderr_write (UPDATE_MANUALLY)
983 raise FatalConversionError ()
987 @rule ((1, 7, 28), _ ("new Pedal style syntax"))
989 str = re.sub (r"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\(override|set) *#'pedal-type *",
990 r"\property Staff.pedal\1Style ", str)
991 str = re.sub (r"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\revert *#'pedal-type", '', str)
998 origstr = '<%s>' % str
999 if re.search (r'\\\\', str):
1002 if re.search (r'\\property', str):
1005 if re.match (r'^\s*\)?\s*\\[a-zA-Z]+', str):
1009 def sub_durs (m, durs = durs):
1010 durs.append(m.group(2))
1013 str = re.sub (r"([a-z]+[,'!? ]*)([0-9]+\.*)", sub_durs, str)
1020 return '<%s>' % m.group (1)
1027 while last_str <> str:
1030 def sub_tremolos (m, slur_strs = slur_strs):
1032 if tr not in slur_strs:
1033 slur_strs.append (tr)
1036 str = re.sub (r"([a-z]+[',!? ]*)(:[0-9]+)",
1039 def sub_dyn_end (m, dyns = dyns):
1041 return ' ' + m.group(2)
1043 str = re.sub (r'(\\!)\s*([a-z]+)', sub_dyn_end, str)
1044 def sub_slurs(m, slur_strs = slur_strs):
1045 if '-)' not in slur_strs:
1046 slur_strs.append (')')
1049 def sub_p_slurs(m, slur_strs = slur_strs):
1050 if '-\)' not in slur_strs:
1051 slur_strs.append ('\)')
1054 str = re.sub (r"\)[ ]*([a-z]+)", sub_slurs, str)
1055 str = re.sub (r"\\\)[ ]*([a-z]+)", sub_p_slurs, str)
1056 def sub_begin_slurs(m, slur_strs = slur_strs):
1057 if '-(' not in slur_strs:
1058 slur_strs.append ('(')
1061 str = re.sub (r"([a-z]+[,'!?0-9 ]*)\(",
1062 sub_begin_slurs, str)
1063 def sub_begin_p_slurs(m, slur_strs = slur_strs):
1064 if '-\(' not in slur_strs:
1065 slur_strs.append ('\(')
1068 str = re.sub (r"([a-z]+[,'!?0-9 ]*)\\\(",
1069 sub_begin_p_slurs, str)
1071 def sub_dyns (m, slur_strs = slur_strs):
1073 if s == '@STARTCRESC@':
1074 slur_strs.append ("\\<")
1075 elif s == '@STARTDECRESC@':
1076 slur_strs.append ("\\>")
1078 slur_strs.append ('\\!')
1081 str = re.sub (r'@STARTCRESC@', sub_dyns, str)
1082 str = re.sub (r'-?\\!', sub_dyns, str)
1084 def sub_articulations (m, slur_strs = slur_strs):
1086 if a not in slur_strs:
1087 slur_strs.append (a)
1090 str = re.sub (r"([_^-]\@ACCENT\@)", sub_articulations,
1092 str = re.sub (r"([_^-]\\[a-z]+)", sub_articulations,
1094 str = re.sub (r"([_^-][>_.+|^-])", sub_articulations,
1096 str = re.sub (r'([_^-]"[^"]+")', sub_articulations,
1099 def sub_pslurs(m, slur_strs = slur_strs):
1100 slur_strs.append (' \\)')
1102 str = re.sub (r"\\\)[ ]*([a-z]+)", sub_pslurs, str)
1106 suffix = ''.join (slur_strs) + ''.join (pslur_strs) \
1109 return '@STARTCHORD@%s@ENDCHORD@%s%s' % (str , dur_str, suffix)
1113 def sub_chords (str):
1118 marker_str = '%% new-chords-done %%'
1120 if re.search (marker_str,str):
1122 str = re.sub ('<<', '@STARTCHORD@', str)
1123 str = re.sub ('>>', '@ENDCHORD@', str)
1125 str = re.sub (r'\\<', '@STARTCRESC@', str)
1126 str = re.sub (r'\\>', '@STARTDECRESC@', str)
1127 str = re.sub (r'([_^-])>', r'\1@ACCENT@', str)
1128 str = re.sub (r'<([^<>{}]+)>', sub_chord, str)
1130 # add dash: -[, so that [<<a b>> c d] becomes
1132 # and gets skipped by articulation_substitute
1133 str = re.sub (r'\[ *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)',
1135 str = re.sub (r'\\! *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)',
1138 str = re.sub (r'<([^?])', r'%s\1' % simstart, str)
1139 str = re.sub (r'>([^?])', r'%s\1' % simend, str)
1140 str = re.sub ('@STARTCRESC@', r'\\<', str)
1141 str = re.sub ('@STARTDECRESC@', r'\\>' ,str)
1142 str = re.sub (r'\\context *Voice *@STARTCHORD@',
1143 '@STARTCHORD@', str)
1144 str = re.sub ('@STARTCHORD@', chordstart, str)
1145 str = re.sub ('@ENDCHORD@', chordend, str)
1146 str = re.sub (r'@ACCENT@', '>', str)
1149 markup_start = re.compile(r"([-^_]|\\mark)\s*(#\s*'\s*)\(")
1150 musicglyph = re.compile(r"\(\s*music\b")
1151 columns = re.compile(r"\(\s*columns\b")
1152 submarkup_start = re.compile(r"\(\s*([a-zA-Z]+)")
1153 leftpar = re.compile(r"\(")
1154 rightpar = re.compile(r"\)")
1156 def text_markup (str):
1158 # Find the beginning of each markup:
1159 match = markup_start.search (str)
1161 result = result + str[:match.end (1)] + " \markup"
1162 str = str[match.end( 2):]
1163 # Count matching parentheses to find the end of the
1166 pars = re.finditer(r"[()]",str)
1168 if par.group () == '(':
1169 nesting_level = nesting_level + 1
1171 nesting_level = nesting_level - 1
1172 if nesting_level == 0:
1173 markup_end = par.end ()
1175 # The full markup in old syntax:
1176 markup = str[:markup_end]
1177 # Modify to new syntax:
1178 markup = musicglyph.sub (r"{\\musicglyph", markup)
1179 markup = columns.sub (r"{", markup)
1180 markup = submarkup_start.sub (r"{\\\1", markup)
1181 markup = leftpar.sub ("{", markup)
1182 markup = rightpar.sub ("}", markup)
1184 result = result + markup
1186 str = str[markup_end:]
1187 match = markup_start.search(str)
1188 result = result + str
1191 def articulation_substitute (str):
1192 str = re.sub (r"""([^-])\[ *(\\?\)?[a-z]+[,']*[!?]?[0-9:]*\.*)""",
1194 str = re.sub (r"""([^-])\\\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
1196 str = re.sub (r"""([^-\\])\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
1198 str = re.sub (r"""([^-])\\! *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
1202 string_or_scheme = re.compile ('("(?:[^"\\\\]|\\\\.)*")|(#\\s*\'?\\s*\\()')
1204 # Only apply articulation_substitute () outside strings and
1205 # Scheme expressions:
1206 def smarter_articulation_subst (str):
1208 # Find the beginning of next string or Scheme expr.:
1209 match = string_or_scheme.search (str)
1211 # Convert the preceding LilyPond code:
1212 previous_chunk = str[:match.start()]
1213 result = result + articulation_substitute (previous_chunk)
1214 if match.group (1): # Found a string
1215 # Copy the string to output:
1216 result = result + match.group (1)
1217 str = str[match.end(1):]
1218 else: # Found a Scheme expression. Count
1219 # matching parentheses to find its end
1220 str = str[match.start ():]
1222 pars = re.finditer(r"[()]",str)
1224 if par.group () == '(':
1225 nesting_level = nesting_level + 1
1227 nesting_level = nesting_level - 1
1228 if nesting_level == 0:
1229 scheme_end = par.end ()
1231 # Copy the Scheme expression to output:
1232 result = result + str[:scheme_end]
1233 str = str[scheme_end:]
1234 # Find next string or Scheme expression:
1235 match = string_or_scheme.search (str)
1236 # Convert the remainder of the file
1237 result = result + articulation_substitute (str)
1240 def conv_relative(str):
1241 if re.search (r"\\relative", str):
1242 str= "#(ly:set-option 'old-relative)\n" + str
1246 @rule ((1, 9, 0), _ ("""New relative mode,
1247 Postfix articulations, new text markup syntax, new chord syntax."""))
1249 str = re.sub (r"#'\(\)", "@SCM_EOL@", str)
1250 str = conv_relative (str)
1251 str = sub_chords (str)
1253 str = text_markup (str)
1254 str = smarter_articulation_subst (str)
1255 str = re.sub ("@SCM_EOL@", "#'()", str)
1259 @rule ((1, 9, 1), _ ("Remove - before articulation"))
1261 if re.search ("font-style",str):
1262 stderr_write (NOT_SMART % "font-style")
1263 stderr_write (UPDATE_MANUALLY)
1265 raise FatalConversionError ()
1267 str = re.sub (r'-\\markup', r'@\\markup', str)
1268 str = re.sub (r'-\\', r'\\', str)
1269 str = re.sub (r'-\)', ')', str)
1270 str = re.sub (r'-\(', '(', str)
1271 str = re.sub ('-\[', '[', str)
1272 str = re.sub ('-\]', ']', str)
1273 str = re.sub ('-~', '~', str)
1274 str = re.sub (r'@\\markup', r'-\\markup', str)
1278 @rule ((1, 9, 2), "\\newcontext -> \\new")
1280 str = re.sub ('ly:set-context-property',
1281 'ly:set-context-property!', str)
1282 str = re.sub ('\\\\newcontext', '\\\\new', str)
1283 str = re.sub ('\\\\grace[\t\n ]*([^{ ]+)',
1284 r'\\grace { \1 }', str)
1285 str = re.sub ("\\\\grace[\t\n ]*{([^}]+)}",
1287 \\property Voice.Stem \\override #'stroke-style = #"grace"
1289 \\property Voice.Stem \\revert #'stroke-style }
1294 @rule ((1, 9, 3), (_ ("%s misspelling") % "\\acciaccatura") +
1295 ", fingerHorizontalDirection -> fingeringOrientations")
1297 str = re.sub ('accacciatura',
1298 'acciaccatura', str)
1300 if re.search ("context-spec-music", str):
1301 stderr_write (NOT_SMART % "context-spec-music")
1302 stderr_write (UPDATE_MANUALLY)
1304 raise FatalConversionError ()
1306 str = re.sub ('fingerHorizontalDirection *= *#(LEFT|-1)',
1307 "fingeringOrientations = #'(up down left)", str)
1308 str = re.sub ('fingerHorizontalDirection *= *#(RIGHT|1)',
1309 "fingeringOrientations = #'(up down right)", str)
1313 @rule ((1, 9, 4), _ ('Swap < > and << >>'))
1315 if re.search ('\\figures', str):
1316 warning (_ ("attempting automatic \\figures conversion. Check results!"));
1318 def figures_replace (m):
1320 s = re.sub ('<', '@FIGOPEN@',s)
1321 s = re.sub ('>', '@FIGCLOSE@',s)
1322 return '\\figures { %s }' % s
1324 str = re.sub (r'\\figures[ \t\n]*{([^}]+)}', figures_replace, str)
1325 str = re.sub (r'\\<', '@STARTCRESC@', str)
1326 str = re.sub (r'\\>', '@STARTDECRESC@', str)
1327 str = re.sub (r'([-^_])>', r'\1@ACCENT@', str)
1328 str = re.sub (r'<<', '@STARTCHORD@', str)
1329 str = re.sub (r'>>', '@ENDCHORD@', str)
1330 str = re.sub (r'>', '@ENDSIMUL@', str)
1331 str = re.sub (r'<', '@STARTSIMUL@', str)
1332 str = re.sub ('@STARTDECRESC@', '\\>', str)
1333 str = re.sub ('@STARTCRESC@', '\\<', str)
1334 str = re.sub ('@ACCENT@', '>', str)
1335 str = re.sub ('@ENDCHORD@', '>', str)
1336 str = re.sub ('@STARTCHORD@', '<', str)
1337 str = re.sub ('@STARTSIMUL@', '<<', str)
1338 str = re.sub ('@ENDSIMUL@', '>>', str)
1339 str = re.sub ('@FIGOPEN@', '<', str)
1340 str = re.sub ('@FIGCLOSE@', '>', str)
1344 @rule ((1, 9, 5), 'HaraKiriVerticalGroup -> RemoveEmptyVerticalGroup')
1346 str = re.sub ('HaraKiriVerticalGroup', 'RemoveEmptyVerticalGroup', str)
1350 @rule ((1, 9, 6), _ ('deprecate %s') % 'ly:get-font')
1352 if re.search ("ly:get-font", str) :
1353 stderr_write (NOT_SMART % "ly:get-font")
1354 stderr_write (FROM_TO \
1355 % ("(ly:paper-get-font (ly:grob-get-paper foo) .. )",
1356 "(ly:paper-get-font (ly:grob-get-paper foo) .. )"))
1357 stderr_write (UPDATE_MANUALLY)
1358 raise FatalConversionError ()
1360 if re.search ("\\pitch *#", str) :
1361 stderr_write (NOT_SMART % "\\pitch")
1362 stderr_write (_ ("Use Scheme code to construct arbitrary note events."))
1365 raise FatalConversionError ()
1369 @rule ((1, 9, 7), _ ('''use symbolic constants for alterations,
1370 remove \\outputproperty, move ly:verbose into ly:get-option'''))
1372 def sub_alteration (m):
1376 '-2': 'DOUBLE-FLAT',
1379 '2': 'DOUBLE-SHARP',
1382 return '(ly:make-pitch %s %s %s)' % (m.group(1), m.group (2),
1385 str =re.sub ("\\(ly:make-pitch *([0-9-]+) *([0-9-]+) *([0-9-]+) *\\)",
1386 sub_alteration, str)
1389 str = re.sub ("ly:verbose", "ly:get-option 'verbose", str)
1391 m= re.search ("\\\\outputproperty #([^#]+)[\t\n ]*#'([^ ]+)", str)
1394 r"""\outputproperty found,
1395 Please hand-edit, using
1397 \applyoutput #(outputproperty-compatibility %s '%s <GROB PROPERTY VALUE>)
1399 as a substitution text.""") % (m.group (1), m.group (2)) )
1400 raise FatalConversionError ()
1402 if re.search ("ly:(make-pitch|pitch-alteration)", str) \
1403 or re.search ("keySignature", str):
1404 stderr_write (NOT_SMART % "pitches")
1406 _ ("""The alteration field of Scheme pitches was multiplied by 2
1407 to support quarter tone accidentals. You must update the following constructs manually:
1409 * calls of ly:make-pitch and ly:pitch-alteration
1410 * keySignature settings made with \property
1412 raise FatalConversionError ()
1416 @rule ((1, 9, 8), "dash-length -> dash-fraction")
1418 if re.search ("dash-length",str):
1419 stderr_write (NOT_SMART % "dash-length")
1420 stderr_write (FROM_TO % ("dash-length", "dash-fraction"))
1421 stderr_write (UPDATE_MANUALLY)
1422 raise FatalConversionError ()
1426 @rule ((2, 1, 1), "font-relative-size -> font-size")
1429 return "#'font-size = #%d" % (2*int (match.group (1)))
1431 str =re.sub (r"#'font-relative-size\s*=\s*#\+?([0-9-]+)", func, str)
1432 str =re.sub (r"#'font-family\s*=\s*#'ancient",
1433 r"#'font-family = #'music", str)
1437 @rule ((2, 1, 2), "ly:get-music-length -> ly:music-length")
1439 str =re.sub (r"ly:get-music-length", "ly:music-length", str)
1443 @rule ((2, 1, 3), "stanza -> instrument")
1445 str =re.sub (r"\.\s+stz=", ". instr ", str)
1449 @rule ((2, 1, 4), _ ("removal of automaticMelismata; use melismaBusyProperties instead."))
1459 return r" \property %s.melismaBusyProperties \unset" % c
1461 return r"\property %s.melismaBusyProperties = #'(melismaBusy)" % c
1463 str = re.sub (r"\\property ([a-zA-Z]+)\s*\.\s*automaticMelismata\s*=\s*##([ft])", func, str)
1467 @rule ((2, 1, 7), "\\translator Staff -> \\change Staff")
1469 str =re.sub (r"\\translator\s+([a-zA-Z]+)", r"\\change \1", str)
1473 @rule ((2, 1, 10), "\\newaddlyrics -> \\lyricsto")
1475 str =re.sub (r"\\newaddlyrics", r"\\lyricsto", str)
1479 @rule ((2, 1, 11), """\\include "paper16.ly" -> #(set-staff-size 16)
1480 \\note #3 #1 #1 -> \\note #"8." #1
1483 str = re.sub (r'\\include\s*"paper([0-9]+)(-init)?.ly"',
1484 r"#(set-staff-size \1)", str)
1486 def sub_note (match):
1488 log = int (match.group (1))
1489 dots = int (match.group (2))
1492 dur = '%d' % (1 << log)
1494 dur = { -1 : 'breve',
1500 return r'\note #"%s" #%s' % (dur, match.group (3))
1502 str = re.sub (r'\\note\s+#([0-9-]+)\s+#([0-9]+)\s+#([0-9.-]+)',
1507 @rule ((2, 1, 12), "OttavaSpanner -> OttavaBracket")
1509 str = re.sub (r"OttavaSpanner", r"OttavaBracket", str)
1513 @rule ((2, 1, 13), "set-staff-size -> set-global-staff-size")
1515 str = re.sub (r"\(set-staff-size ", r"(set-global-staff-size ", str)
1519 @rule ((2, 1, 14), "style = dotted -> dash-fraction = 0")
1521 str = re.sub (r"#'style\s*=\s*#'dotted-line",
1522 r"#'dash-fraction = #0.0 ", str)
1526 @rule ((2, 1, 15), "LyricsVoice . instr(ument) -> vocalName")
1528 str = re.sub (r'LyricsVoice\s*\.\s*instrument\s*=\s*("[^"]*")',
1529 r'LyricsVoice . vocalName = \1', str)
1531 str = re.sub (r'LyricsVoice\s*\.\s*instr\s*=\s*("[^"]*")',
1532 r'LyricsVoice . vocNam = \1', str)
1536 @rule ((2, 1, 16), '\\musicglyph #"accidentals-NUM" -> \\sharp/flat/etc.')
1549 return '\\%s' % d[m.group (1)]
1551 str = re.sub (r'\\musicglyph\s*#"accidentals-([0-9-]+)"',
1556 @rule ((2, 1, 17), _ ("\\partcombine syntax change to \\newpartcombine"))
1559 if re.search (r'\\partcombine', str):
1560 stderr_write (NOT_SMART % "\\partcombine")
1561 stderr_write (UPDATE_MANUALLY)
1562 raise FatalConversionError ()
1564 # this rule doesn't really work,
1565 # too lazy to figure out why.
1566 str = re.sub (r'\\context\s+Voice\s*=\s*one\s*\\partcombine\s+Voice\s*\\context\s+Thread\s*=\s*one(.*)\s*'
1567 + r'\\context\s+Thread\s*=\s*two',
1568 '\\\\newpartcombine\n\\1\n', str)
1572 @rule ((2, 1, 18), """\\newpartcombine -> \\partcombine,
1573 \\autochange Staff -> \\autochange
1576 str = re.sub (r'\\newpartcombine', r'\\partcombine', str)
1577 str = re.sub (r'\\autochange\s+Staff', r'\\autochange ', str)
1581 @rule ((2, 1, 19), _ ("""Drum notation changes, Removing \\chordmodifiers, \\notenames.
1582 Harmonic notes. Thread context removed. Lyrics context removed."""))
1584 if re.search ('include "drumpitch', str):
1585 stderr_write (_ ("Drums found. Enclose drum notes in \\drummode"))
1587 str = re.sub (r'\\include "drumpitch-init.ly"','', str)
1589 str = re.sub (r'\\pitchnames ','pitchnames = ', str)
1590 str = re.sub (r'\\chordmodifiers ','chordmodifiers = ', str)
1591 str = re.sub (r'\bdrums\b\s*=','drumContents = ', str)
1592 str = re.sub (r'\\drums\b','\\drumContents ', str)
1595 if re.search ('drums->paper', str):
1596 stderr_write (_ ("\n%s found. Check file manually!\n") % _("Drum notation"))
1598 str = re.sub (r"""\\apply\s+#\(drums->paper\s+'([a-z]+)\)""",
1599 r"""\property DrumStaff.drumStyleTable = #\1-style""",
1602 if re.search ('Thread', str):
1603 stderr_write (_ ("\n%s found. Check file manually!\n") % "Thread");
1605 str = re.sub (r"""(\\once\s*)?\\property\s+Thread\s*\.\s*NoteHead\s*"""
1606 + r"""\\(set|override)\s*#'style\s*=\s*#'harmonic"""
1607 + r"""\s+([a-z]+[,'=]*)([0-9]*\.*)"""
1608 ,r"""<\3\\harmonic>\4""", str)
1610 str = re.sub (r"""\\new Thread""", """\context Voice""", str)
1611 str = re.sub (r"""Thread""", """Voice""", str)
1613 if re.search ('\bLyrics\b', str):
1614 stderr_write (_ ("\n%s found. Check file manually!\n") % "Lyrics");
1616 str = re.sub (r"""LyricsVoice""", r"""L@ricsVoice""", str)
1617 str = re.sub (r"""\bLyrics\b""", r"""LyricsVoice""", str)
1618 str = re.sub (r"""LyricsContext""", r"""LyricsVoiceContext""", str)
1619 str = re.sub (r"""L@ricsVoice""", r"""LyricsVoice""",str)
1623 @rule ((2, 1, 20), "nonevent-skip -> skip-music")
1625 str = re.sub (r'nonevent-skip', 'skip-music', str)
1629 @rule ((2, 1, 21), """molecule-callback -> print-function,
1630 brew_molecule -> print
1631 brew-new-markup-molecule -> Text_item::print
1632 LyricsVoice -> Lyrics
1633 tupletInvisible -> TupletBracket \set #'transparent
1635 """ % (_ ("remove %s") % "Grob::preset_extent"))
1637 str = re.sub (r'molecule-callback', 'print-function', str)
1638 str = re.sub (r'brew_molecule', 'print', str)
1639 str = re.sub (r'brew-new-markup-molecule', 'Text_item::print', str)
1640 str = re.sub (r'LyricsVoice', 'Lyrics', str)
1641 str = re.sub (r'tupletInvisible',
1642 r"TupletBracket \\set #'transparent", str)
1643 # str = re.sub (r'molecule', 'collage', str)
1644 #molecule -> collage
1645 str = re.sub (r"\\property\s+[a-zA-Z]+\s*\.\s*[a-zA-Z]+\s*"
1646 + r"\\set\s*#'X-extent-callback\s*=\s*#Grob::preset_extent",
1651 @rule ((2, 1, 22), """%s
1652 \\set A.B = #C , \\unset A.B
1653 \\override A.B #C = #D, \\revert A.B #C
1655 """ % _ ("new syntax for property settings:"))
1657 str = re.sub (r'(\\property[^=]+)=\s*([-0-9]+)',
1659 str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\=]+)\s*\\(set|override)',
1660 r"\\overrid@ \1.\2 ", str)
1661 str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*=\s*',
1662 r'\\s@t \1.\2 = ', str)
1663 str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*\\unset',
1664 r'\\uns@t \1.\2 ', str)
1665 str = re.sub (r'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*\\revert'
1666 + r"\s*#'([-a-z0-9_]+)",
1667 r"\\rev@rt \1.\2 #'\3", str)
1668 str = re.sub (r'Voice\.', '', str)
1669 str = re.sub (r'Lyrics\.', '', str)
1670 str = re.sub (r'ChordNames\.', '', str)
1672 str = re.sub ('rev@rt', 'revert',str)
1673 str = re.sub ('s@t', 'set',str)
1674 str = re.sub ('overrid@', 'override',str)
1676 str = re.sub ('molecule', 'stencil', str)
1677 str = re.sub ('Molecule', 'Stencil', str)
1681 @rule ((2, 1, 23), _ ("Property setting syntax in \\translator{ }"))
1683 def subst_in_trans (match):
1685 s = re.sub (r'\s([a-zA-Z]+)\s*\\override',
1686 r' \\override \1', s)
1687 s = re.sub (r'\s([a-zA-Z]+)\s*\\set',
1688 r' \\override \1', s)
1689 s = re.sub (r'\s([a-zA-Z]+)\s*\\revert',
1692 str = re.sub (r'\\(translator|with)\s*{[^}]+}', subst_in_trans, str)
1696 context = m.group ('context')
1699 context = " '%s" % context[:-1] # -1: remove .
1703 d['context'] = context
1705 return r"""#(override-auto-beam-setting %(prop)s %(num)s %(den)s%(context)s)""" % d
1707 str = re.sub (r"""\\override\s*(?P<context>[a-zA-Z]+\s*\.\s*)?autoBeamSettings"""
1708 +r"""\s*#(?P<prop>[^=]+)\s*=\s*#\(ly:make-moment\s+(?P<num>\d+)\s+(?P<den>\d)\s*\)""",
1713 @rule ((2, 1, 24), "music-list? -> ly:music-list?")
1715 str = re.sub (r'music-list\?', 'ly:music-list?', str)
1716 str = re.sub (r'\|\s*~', '~ |', str)
1720 @rule ((2, 1, 25), _ ("Scheme grob function renaming"))
1722 str = re.sub (r'ly:get-spanner-bound', 'ly:spanner-get-bound', str)
1723 str = re.sub (r'ly:get-extent', 'ly:grob-extent', str)
1724 str = re.sub (r'ly:get-system', 'ly:grob-system', str)
1725 str = re.sub (r'ly:get-original', 'ly:grob-original', str)
1726 str = re.sub (r'ly:get-parent', 'ly:grob-parent', str)
1727 str = re.sub (r'ly:get-broken-into', 'ly:spanner-broken-into', str)
1728 str = re.sub (r'Melisma_engraver', 'Melisma_translator', str)
1729 if re.search ("ly:get-paper-variable", str):
1730 stderr_write (NOT_SMART % "ly:paper-get-variable")
1731 stderr_write (_ ('Use %s\n') % '(ly:paper-lookup (ly:grob-paper ))')
1732 raise FatalConversionError ()
1734 str = re.sub (r'\\defaultAccidentals', "#(set-accidental-style 'default)", str)
1735 str = re.sub (r'\\voiceAccidentals', "#(set-accidental-style 'voice)", str)
1736 str = re.sub (r'\\modernAccidentals', "#(set-accidental-style 'modern)", str)
1737 str = re.sub (r'\\modernCautionaries', "#(set-accidental-style 'modern-cautionary)", str)
1738 str = re.sub (r'\\modernVoiceAccidental', "#(set-accidental-style 'modern-voice)", str)
1739 str = re.sub (r'\\modernVoiceCautionaries', "#(set-accidental-style 'modern-voice-cautionary)", str)
1740 str = re.sub (r'\\pianoAccidentals', "#(set-accidental-style 'piano)", str)
1741 str = re.sub (r'\\pianoCautionaries', "#(set-accidental-style 'piano-cautionary)", str)
1742 str = re.sub (r'\\forgetAccidentals', "#(set-accidental-style 'forget)", str)
1743 str = re.sub (r'\\noResetKey', "#(set-accidental-style 'no-reset)", str)
1747 @rule ((2, 1, 26), _ ("More Scheme function renaming"))
1749 str = re.sub ('ly:set-grob-property!', 'ly:grob-set-property!',str)
1750 str = re.sub ('ly:set-mus-property!', 'ly:music-set-property!',str)
1751 str = re.sub ('ly:set-context-property!', 'ly:context-set-property!', str)
1752 str = re.sub ('ly:get-grob-property', 'ly:grob-property',str)
1753 str = re.sub ('ly:get-mus-property', 'ly:music-property',str)
1754 str = re.sub ('ly:get-context-property', 'ly:context-property',str)
1758 @rule ((2, 1, 27), "property transposing -> tuning")
1761 g = int (m.group (2))
1769 lower_pitches = filter (lambda x : x <= g, [0, 2, 4, 5, 7, 9, 11, 12])
1770 s = len (lower_pitches) -1
1771 a = g - lower_pitches [-1]
1775 str += ['eses', 'es', '', 'is', 'isis'][a + 2]
1777 str += ',' * (-o - 1)
1779 str += "'" * (o + 1)
1781 return '\\transposition %s ' % str
1784 str = re.sub (r"\\set ([A-Za-z]+\s*\.\s*)?transposing\s*=\s*#([-0-9]+)",
1789 @rule ((2, 1, 28), """make-music-by-name -> make-music,
1790 new syntax for setting \\arpeggioBracket""")
1792 str = re.sub (r'make-music-by-name', 'make-music', str)
1793 str = re.sub (r"\\override\s+.*Arpeggio\s+#.print-function\s+=\s+\\arpeggioBracket", r"\\arpeggioBracket", str)
1797 @rule ((2, 1, 29), '\\center -> \\center-align, \\translator -> \\context')
1799 str = re.sub (r'\\center([^-])', '\\center-align\\1', str)
1800 str = re.sub (r'\\translator', '\\context', str)
1804 @rule ((2, 1, 30), '''\\threeq{flat,sharp} -> \\sesqui{flat,sharp}
1805 ly:get-mutable-properties -> ly:mutable-music-properties
1806 centralCPosition -> middleCPosition
1807 ly:unset-context-property -> ly:context-unset-property
1808 ly:translator-find -> ly:context-find
1809 ly:get-stencil-extent -> ly:stencil-extent
1812 str = re.sub (r'\\threeq(flat|sharp)', r'\\sesqui\1', str)
1813 str = re.sub (r'ly:stencil-get-extent',
1814 'ly:stencil-extent', str)
1815 str = re.sub (r'ly:translator-find',
1816 'ly:context-find', str)
1817 str = re.sub ('ly:unset-context-property','ly:context-unset-property',
1820 str = re.sub (r'ly:get-mutable-properties',
1821 'ly:mutable-music-properties',str)
1822 str = re.sub (r'centralCPosition',
1823 'middleCPosition',str)
1827 @rule ((2, 1, 31), 'remove \\alias Timing')
1829 str = re.sub (r'\\alias\s*"?Timing"?', '', str)
1833 @rule ((2, 1, 33), 'breakAlignOrder -> break-align-orders.')
1835 str = re.sub (r"(\\set\s+)?(?P<context>(Score\.)?)breakAlignOrder\s*=\s*#'(?P<list>[^\)]+)",
1836 r"\n\\override \g<context>BreakAlignment #'break-align-orders = "
1837 + "#(make-vector 3 '\g<list>)", str)
1841 @rule ((2, 1, 34), 'set-paper-size -> set-default-paper-size.')
1843 str = re.sub (r"\(set-paper-size",
1844 "(set-default-paper-size",str)
1848 @rule ((2, 1, 36), 'ly:mutable-music-properties -> ly:music-mutable-properties')
1850 str = re.sub (r"ly:mutable-music-properties",
1851 "ly:music-mutable-properties", str)
1855 @rule ((2, 2, 0), _ ("bump version for release"))
1860 @rule ((2, 3, 1), '\\apply -> \\applymusic')
1862 return re.sub (r'\\apply\b', r'\\applymusic', str)
1865 @rule ((2, 3, 2), '\\FooContext -> \\Foo')
1867 if re.search ('textheight', str):
1868 stderr_write (NOT_SMART % "textheight")
1869 stderr_write (UPDATE_MANUALLY)
1871 _ ("""Page layout has been changed, using paper size and margins.
1872 textheight is no longer used.
1874 str = re.sub (r'\\OrchestralScoreContext', '\\Score', str)
1876 if m.group(1) not in ['RemoveEmptyStaff',
1877 'AncientRemoveEmptyStaffContext',
1879 return '\\' + m.group (1)
1884 str = re.sub (r'\\([a-zA-Z]+)Context\b', func, str)
1885 str = re.sub ('ly:paper-lookup', 'ly:output-def-lookup', str)
1889 @rule ((2, 3, 4), _ ('remove %s') % '\\notes')
1891 str = re.sub (r'\\notes\b', '', str)
1895 @rule ((2, 3, 6), 'lastpagefill -> raggedlastbottom')
1897 str = re.sub (r'lastpagefill\s*=\s*"?1"', 'raggedlastbottom = ##t', str)
1901 @rule ((2, 3, 8), 'remove \\consistsend, strip \\lyrics from \\lyricsto.')
1903 str = re.sub (r'\\consistsend', '\\consists', str)
1904 str = re.sub (r'\\lyricsto\s+("?[a-zA-Z]+"?)(\s*\\new Lyrics\s*)?\\lyrics',
1905 r'\\lyricsto \1 \2', str)
1909 @rule ((2, 3, 9), 'neo_mensural -> neomensural, if-text-padding -> bound-padding')
1911 str = re.sub (r'neo_mensural', 'neomensural', str)
1912 str = re.sub (r'if-text-padding', 'bound-padding', str)
1916 @rule ((2, 3, 10), '\\addlyrics -> \\oldaddlyrics, \\newlyrics -> \\addlyrics')
1918 str = re.sub (r'\\addlyrics', r'\\oldaddlyrics', str)
1919 str = re.sub (r'\\newlyrics', r'\\addlyrics', str)
1920 if re.search (r"\\override\s*TextSpanner", str):
1921 stderr_write ("\nWarning: TextSpanner has been split into DynamicTextSpanner and TextSpanner\n")
1925 @rule ((2, 3, 11), '\\setMmRestFermata -> ^\\fermataMarkup')
1927 str = re.sub (r'\\setMmRestFermata\s+(R[0-9.*/]*)',
1928 r'\1^\\fermataMarkup', str)
1932 @rule ((2, 3, 12), '''\\newpage -> \\pageBreak, junk \\script{up,down,both},
1933 soloADue -> printPartCombineTexts, #notes-to-clusters -> \\makeClusters
1936 str = re.sub (r'\\newpage', r'\\pageBreak', str)
1937 str = re.sub (r'\\scriptUp', r"""{
1938 \\override TextScript #'direction = #1
1939 \\override Script #'direction = #1
1941 str = re.sub (r'\\scriptDown', r"""{
1942 \\override TextScript #'direction = #-1
1943 \\override Script #'direction = #-1
1945 str = re.sub (r'\\scriptBoth', r"""{
1946 \\revert TextScript #'direction
1947 \\revert Script #'direction
1949 str = re.sub ('soloADue', 'printPartCombineTexts', str)
1950 str = re.sub (r'\\applymusic\s*#notes-to-clusters',
1951 '\\makeClusters', str)
1953 str = re.sub (r'pagenumber\s*=', 'firstpagenumber = ', str)
1957 @rule ((2, 3, 16), _ ('''\\foo -> \\foomode (for chords, notes, etc.)
1958 fold \\new FooContext \\foomode into \\foo.'''))
1960 str = re.sub (r'\\chords\b', r'\\chordmode', str)
1961 str = re.sub (r'\\lyrics\b', r'\\lyricmode', str)
1962 str = re.sub (r'\\figures\b', r'\\figuremode', str)
1963 str = re.sub (r'\\notes\b', r'\\notemode', str)
1964 str = re.sub (r'\\drums\b', r'\\drummode', str)
1965 str = re.sub (r'\\chordmode\s*\\new ChordNames', r'\\chords', str)
1966 str = re.sub (r'\\new ChordNames\s*\\chordmode', r'\\chords', str)
1967 str = re.sub (r'\\new FiguredBass\s*\\figuremode', r'\\figures', str)
1968 str = re.sub (r'\\figuremode\s*\new FiguredBass', r'\\figures', str)
1969 str = re.sub (r'\\new DrumStaff\s*\\drummode', r'\\drums', str)
1970 str = re.sub (r'\\drummode\s*\\new DrumStaff', r'\\drums', str)
1975 @rule ((2, 3, 17), '''slurBoth -> slurNeutral, stemBoth -> stemNeutral, etc.
1976 \\applymusic #(remove-tag 'foo) -> \\removeWithTag 'foo''')
1978 str = re.sub (r'(slur|stem|phrasingSlur|tie|dynamic|dots|tuplet|arpeggio|)Both', r'\1Neutral', str)
1979 str = re.sub (r"\\applymusic\s*#\(remove-tag\s*'([a-z-0-9]+)\)",
1980 r"\\removeWithTag #'\1", str)
1984 @rule ((2, 3, 18), 'Text_item -> Text_interface')
1986 str = re.sub (r'Text_item', 'Text_interface', str)
1990 @rule ((2, 3, 22), 'paper -> layout, bookpaper -> paper')
1992 str = re.sub (r'\\paper', r'\\layout', str)
1993 str = re.sub (r'\\bookpaper', r'\\paper', str)
1994 if re.search ('paper-set-staff-size', str):
1995 warning (_ ('''staff size should be changed at top-level
1998 #(set-global-staff-size <STAFF-HEIGHT-IN-POINT>)
2003 str = re.sub (r'#\(paper-set-staff-size', '%Use set-global-staff-size at toplevel\n% #(layout-set-staff-size', str)
2007 @rule ((2, 3, 23), r'\context Foo = NOTENAME -> \context Foo = "NOTENAME"')
2009 str = re.sub (r'\\context\s+([a-zA-Z]+)\s*=\s*([a-z]+)\s',
2010 r'\\context \1 = "\2" ',
2015 @rule ((2, 3, 24), _ ('''regularize other identifiers'''))
2018 return regularize_id (m.group (1))
2019 str = re.sub (r'(maintainer_email|maintainer_web|midi_stuff|gourlay_maxmeasures)',
2024 @rule ((2, 3, 25), 'petrucci_c1 -> petrucci-c1, 1style -> single-digit')
2026 str = re.sub ('petrucci_c1', 'petrucci-c1', str)
2027 str = re.sub ('1style', 'single-digit', str)
2031 @rule ((2, 4, 0), _ ("bump version for release"))
2036 @rule ((2, 5, 0), '\\quote -> \\quoteDuring')
2038 str = re.sub (r'\\quote\s+"?([a-zA-Z0-9]+)"?\s+([0-9.*/]+)',
2039 r'\\quoteDuring #"\1" { \skip \2 }',
2044 @rule ((2, 5, 1), 'ly:import-module -> ly:module-copy')
2046 str = re.sub (r'ly:import-module',
2047 r'ly:module-copy', str)
2051 @rule ((2, 5, 2), '\markup .. < .. > .. -> \markup .. { .. } ..')
2053 str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<(([^>]|<[^>]*>)*)>',
2055 str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<(([^>]|<[^>]*>)*)>',
2057 str = re.sub (r'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<(([^>]|<[^>]*>)*)>',
2061 s = re.sub (r'''((\\"|})\s*){''', '\2 \\line {', s)
2063 str = re.sub (r'\\markup\s*{([^}]|{[^}]*})*}', get_markup, str)
2067 @rule ((2, 5, 3), 'ly:find-glyph-by-name -> ly:font-get-glyph, remove - from glyphnames.')
2069 str = re.sub ('ly:find-glyph-by-name', 'ly:font-get-glyph', str)
2070 str = re.sub ('"(scripts|clefs|accidentals)-', r'"\1.', str)
2071 str = re.sub ("'hufnagel-do-fa", "'hufnagel.do.fa", str)
2072 str = re.sub ("'(vaticana|hufnagel|medicaea|petrucci|neomensural|mensural)-", r"'\1.", str)
2076 @rule ((2, 5, 12), '\set Slur #\'dashed = #X -> \slurDashed')
2078 str = re.sub (r"\\override\s+(Voice\.)?Slur #'dashed\s*=\s*#\d*(\.\d+)?",
2079 r"\\slurDashed", str)
2083 @rule ((2, 5, 13), _ ('\\encoding: smart recode latin1..utf-8. Remove ly:point-and-click'))
2085 input_encoding = 'latin1'
2087 encoding = match.group (1)
2089 # FIXME: automatic recoding of other than latin1?
2090 if encoding == 'latin1':
2091 return match.group (2)
2093 stderr_write (NOT_SMART % ("\\encoding: %s" % encoding))
2094 stderr_write (_ ("LilyPond source must be UTF-8"))
2096 if encoding == 'TeX':
2097 stderr_write (_ ("Try the texstrings backend"))
2100 stderr_write ( _("Do something like: %s") % \
2101 ("recode %s..utf-8 FILE" % encoding))
2103 stderr_write (_ ("Or save as UTF-8 in your editor"))
2105 raise FatalConversionError ()
2107 return match.group (0)
2109 str = re.sub (r'\\encoding\s+"?([a-zA-Z0-9]+)"?(\s+)', func, str)
2112 de_ascii = codecs.getdecoder ('ascii')
2113 de_utf_8 = codecs.getdecoder ('utf_8')
2114 de_input = codecs.getdecoder (input_encoding)
2115 en_utf_8 = codecs.getencoder ('utf_8')
2118 # only in python >= 2.3
2119 # except UnicodeDecodeError:
2120 except UnicodeError:
2121 # do not re-recode UTF-8 input
2124 #except UnicodeDecodeError:
2125 except UnicodeError:
2126 str = en_utf_8 (de_input (str)[0])[0]
2130 str = re.sub (r"#\(ly:set-point-and-click '[a-z-]+\)", '', str)
2134 @rule ((2, 5, 17), _ ('remove %s') % 'ly:stencil-set-extent!')
2136 if re.search ("ly:stencil-set-extent!", str):
2137 stderr_write (NOT_SMART % "ly:stencil-set-extent!")
2138 stderr_write (_ ('Use %s\n') % '(set! VAR (ly:make-stencil (ly:stencil-expr VAR) X-EXT Y-EXT))')
2139 raise FatalConversionError ()
2140 if re.search ("ly:stencil-align-to!", str):
2141 stderr_write (NOT_SMART % "ly:stencil-align-to!")
2142 stderr_write (_ ('Use %s\n') % '(set! VAR (ly:stencil-aligned-to VAR AXIS DIR))')
2143 raise FatalConversionError ()
2147 @rule ((2, 5, 18), 'ly:warn -> ly:warning')
2149 str = re.sub (r"ly:warn\b", 'ly:warning', str)
2153 @rule ((2, 5, 21), _ ('warn about auto beam settings'))
2155 if re.search ("(override-|revert-)auto-beam-setting", str)\
2156 or re.search ("autoBeamSettings", str):
2157 stderr_write (NOT_SMART % _ ("auto beam settings"))
2158 stderr_write (_ ('''
2159 Auto beam settings must now specify each interesting moment in a measure
2160 explicitly; 1/4 is no longer multiplied to cover moments 1/2 and 3/4 too.
2162 stderr_write (UPDATE_MANUALLY)
2163 raise FatalConversionError ()
2167 @rule ((2, 5, 25), 'unfoldrepeats -> unfoldRepeats, compressmusic -> compressMusic')
2169 str = re.sub (r"unfoldrepeats", 'unfoldRepeats', str)
2170 str = re.sub (r"compressmusic", 'compressMusic', str)
2174 @rule ((2, 6, 0), _ ("bump version for release"))
2179 @rule ((2, 7, 0), 'ly:get-default-font -> ly:grob-default-font')
2181 return re.sub('ly:get-default-font', 'ly:grob-default-font', str)
2184 @rule ((2, 7, 1), '''ly:parser-define -> ly:parser-define!
2185 excentricity -> eccentricity
2186 Timing_engraver -> Timing_translator + Default_bar_line_engraver
2189 str = re.sub('ly:parser-define', 'ly:parser-define!', str)
2190 str = re.sub('excentricity', 'eccentricity', str)
2191 str = re.sub(r'\\(consists|remove) *"?Timing_engraver"?',
2192 r'\\\1 "Timing_translator" \\\1 "Default_bar_line_engraver"',
2197 @rule ((2, 7, 2), 'ly:X-moment -> ly:moment-X')
2199 str = re.sub('ly:(add|mul|mod|div)-moment', r'ly:moment-\1', str)
2203 @rule ((2, 7, 4), 'keyAccidentalOrder -> keyAlterationOrder')
2205 str = re.sub('keyAccidentalOrder', 'keyAlterationOrder', str)
2209 @rule ((2, 7, 6), '''Performer_group_performer -> Performer_group, Engraver_group_engraver -> Engraver_group,
2210 inside-slur -> avoid-slur''')
2212 str = re.sub('Performer_group_performer', 'Performer_group', str)
2213 str = re.sub('Engraver_group_engraver', 'Engraver_group', str)
2214 str = re.sub (r"#'inside-slur\s*=\s*##t *",
2215 r"#'avoid-slur = #'inside ", str)
2216 str = re.sub (r"#'inside-slur\s*=\s*##f *",
2217 r"#'avoid-slur = #'around ", str)
2218 str = re.sub (r"#'inside-slur",
2219 r"#'avoid-slur", str)
2223 @rule ((2, 7, 10), '\\applyxxx -> \\applyXxx')
2225 str = re.sub(r'\\applyoutput', r'\\applyOutput', str)
2226 str = re.sub(r'\\applycontext', r'\\applyContext', str)
2227 str = re.sub(r'\\applymusic', r'\\applyMusic', str)
2228 str = re.sub(r'ly:grob-suicide', 'ly:grob-suicide!', str)
2232 @rule ((2, 7, 11), '"tabloid" -> "11x17"')
2234 str = re.sub(r'\"tabloid\"', '"11x17"', str)
2238 @rule ((2, 7, 12), 'outputProperty -> overrideProperty')
2240 str = re.sub(r'outputProperty' , 'overrideProperty', str)
2244 @rule ((2, 7, 13), 'layout engine refactoring [FIXME]')
2247 newkey = {'spacing-procedure': 'springs-and-rods',
2248 'after-line-breaking-callback' : 'after-line-breaking',
2249 'before-line-breaking-callback' : 'before-line-breaking',
2250 'print-function' : 'stencil'} [match.group(3)]
2251 what = match.group (1)
2252 grob = match.group (2)
2254 if what == 'revert':
2255 return "revert %s #'callbacks %% %s\n" % (grob, newkey)
2256 elif what == 'override':
2257 return "override %s #'callbacks #'%s" % (grob, newkey)
2262 str = re.sub(r"(override|revert)\s*([a-zA-Z.]+)\s*#'(spacing-procedure|after-line-breaking-callback"
2263 + r"|before-line-breaking-callback|print-function)",
2266 if re.search ('bar-size-procedure', str):
2267 stderr_write (NOT_SMART % "bar-size-procedure")
2268 if re.search ('space-function', str):
2269 stderr_write (NOT_SMART % "space-function")
2270 if re.search ('verticalAlignmentChildCallback', str):
2271 stderr_write (_ ('verticalAlignmentChildCallback has been deprecated'))
2276 @rule ((2, 7, 14), _ ('Remove callbacks property, deprecate XY-extent-callback.'))
2278 str = re.sub (r"\\override +([A-Z.a-z]+) #'callbacks",
2279 r"\\override \1", str)
2280 str = re.sub (r"\\revert ([A-Z.a-z]+) #'callbacks % ([a-zA-Z]+)",
2281 r"\\revert \1 #'\2", str)
2282 str = re.sub (r"([XY]-extent)-callback", r'\1', str)
2283 str = re.sub (r"RemoveEmptyVerticalGroup", "VerticalAxisGroup", str)
2284 str = re.sub (r"\\set ([a-zA-Z]*\.?)minimumVerticalExtent",
2285 r"\\override \1VerticalAxisGroup #'minimum-Y-extent",
2287 str = re.sub (r"minimumVerticalExtent",
2288 r"\\override VerticalAxisGroup #'minimum-Y-extent",
2290 str = re.sub (r"\\set ([a-zA-Z]*\.?)extraVerticalExtent",
2291 r"\\override \1VerticalAxisGroup #'extra-Y-extent", str)
2292 str = re.sub (r"\\set ([a-zA-Z]*\.?)verticalExtent",
2293 r"\\override \1VerticalAxisGroup #'Y-extent", str)
2297 @rule ((2, 7, 15), _ ('Use grob closures iso. XY-offset-callbacks.'))
2299 if re.search ('[XY]-offset-callbacks', str):
2300 stderr_write (NOT_SMART % "[XY]-offset-callbacks")
2301 if re.search ('position-callbacks', str):
2302 stderr_write (NOT_SMART % "position-callbacks")
2306 @rule ((2, 7, 22), r"\tag #'(a b) -> \tag #'a \tag #'b")
2309 syms = m.group (1).split ()
2310 tags = ["\\tag #'%s" % s for s in syms]
2311 return ' '.join (tags)
2313 str = re.sub (r"\\tag #'\(([^)]+)\)", sub_syms, str)
2317 @rule ((2, 7, 24), _ ('deprecate %s') % 'number-visibility')
2319 str = re.sub (r"#'number-visibility",
2320 "#'number-visibility % number-visibility is deprecated. Tune the TupletNumber instead\n",
2325 @rule ((2, 7, 28), "ly:spanner-get-bound -> ly:spanner-bound")
2327 str = re.sub (r"ly:spanner-get-bound", "ly:spanner-bound", str)
2331 @rule ((2, 7, 29), "override Stem #'beamed-* -> #'details #'beamed-*")
2333 for a in ['beamed-lengths', 'beamed-minimum-free-lengths',
2335 'beamed-extreme-minimum-free-lengths']:
2336 str = re.sub (r"\\override\s+Stem\s+#'%s" % a,
2337 r"\\override Stem #'details #'%s" % a,
2342 @rule ((2, 7, 30), "\\epsfile")
2344 str = re.sub (r'\\epsfile *#"', r'\\epsfile #X #10 #"', str)
2348 @rule ((2, 7, 31), "Foo_bar::bla_bla -> ly:foo-bar::bla-bla")
2352 return 'ly:' + str.lower ().replace ('_','-')
2354 str = re.sub (r'([A-Z][a-z_0-9]+::[a-z_0-9]+)',
2359 @rule ((2, 7, 32), _ ("foobar -> foo-bar for \paper, \layout"))
2362 ('inputencoding', 'input-encoding'),
2363 ('printpagenumber', 'print-page-number'),
2364 ('outputscale', 'output-scale'),
2365 ('betweensystemspace', 'between-system-space'),
2366 ('betweensystempadding', 'between-system-padding'),
2367 ('pagetopspace', 'page-top-space'),
2368 ('raggedlastbottom', 'ragged-last-bottom'),
2369 ('raggedright', 'ragged-right'),
2370 ('raggedlast', 'ragged-last'),
2371 ('raggedbottom', 'ragged-bottom'),
2372 ('aftertitlespace', 'after-title-space'),
2373 ('beforetitlespace', 'before-title-space'),
2374 ('betweentitlespace', 'between-title-space'),
2375 ('topmargin', 'top-margin'),
2376 ('bottommargin', 'bottom-margin'),
2377 ('headsep', 'head-separation'),
2378 ('footsep', 'foot-separation'),
2379 ('rightmargin', 'right-margin'),
2380 ('leftmargin', 'left-margin'),
2381 ('printfirstpagenumber', 'print-first-page-number'),
2382 ('firstpagenumber', 'first-page-number'),
2383 ('hsize', 'paper-width'),
2384 ('vsize', 'paper-height'),
2385 ('horizontalshift', 'horizontal-shift'),
2386 ('staffspace', 'staff-space'),
2387 ('linethickness', 'line-thickness'),
2388 ('ledgerlinethickness', 'ledger-line-thickness'),
2389 ('blotdiameter', 'blot-diameter'),
2390 ('staffheight', 'staff-height'),
2391 ('linewidth', 'line-width'),
2392 ('annotatespacing', 'annotate-spacing')
2395 for (a,b) in identifier_subs:
2397 ## str = re.sub ('"%s"' % a, '"%s"' b, str)
2399 str = re.sub (a, b, str)
2403 @rule ((2, 7, 32), "debug-beam-quanting -> debug-beam-scoring")
2405 str = re.sub ('debug-beam-quanting', 'debug-beam-scoring', str)
2409 @rule ((2, 7, 36), "def-(music-function|markup-command) -> define-(music-function|markup-command)")
2411 str = re.sub ('def-music-function', 'define-music-function', str)
2412 str = re.sub ('def-markup-command', 'define-markup-command', str)
2416 @rule ((2, 7, 40), "rehearsalMarkAlignSymbol/barNumberAlignSymbol -> break-align-symbol")
2418 str = re.sub (r'\\set\s+Score\s*\.\s*barNumberAlignSymbol\s*=',
2419 r"\\override Score.BarNumber #'break-align-symbol = ", str)
2420 str = re.sub (r'\\set\s*Score\s*\.\s*rehearsalMarkAlignSymbol\s*=',
2421 r"\\override Score.RehearsalMark #'break-align-symbol = ", str)
2425 @rule ((2, 9, 4), "(page-)penalty -> (page-)break-penalty")
2427 str = re.sub ('page-penalty', 'page-break-penalty', str)
2428 str = re.sub ('([^-])penalty', '\1break-penalty', str)
2432 @rule ((2, 9, 6), "\\context Foo \\applyOutput #bla -> \\applyOutput #'Foo #bla ")
2434 str = re.sub (r'\\context\s+\"?([a-zA-Z]+)\"?\s*\\applyOutput', r"\\applyOutput #'\1", str)
2438 @rule ((2, 9, 9), "annotatefoo -> annotate-foo")
2440 str = re.sub ('annotatepage', 'annotate-page', str)
2441 str = re.sub ('annotateheaders', 'annotate-headers', str)
2442 str = re.sub ('annotatesystems', 'annotate-systems', str)
2446 @rule ((2, 9, 11), "\\set tupletNumberFormatFunction -> \\override #'text = ")
2448 str = re.sub (r"""(\\set\s)?(?P<context>[a-zA-Z]*.?)tupletNumberFormatFunction\s*=\s*#denominator-tuplet-formatter""",
2449 r"""\\override \g<context>TupletNumber #'text = #tuplet-number::calc-denominator-text""", str)
2451 str = re.sub (r"""(\\set\s+)?(?P<context>[a-zA-Z]*.?)tupletNumberFormatFunction\s*=\s*#fraction-tuplet-formatter""",
2452 r"""\\override \g<context>TupletNumber #'text = #tuplet-number::calc-fraction-text""", str)
2454 if re.search ('tupletNumberFormatFunction', str):
2456 stderr_write ("tupletNumberFormatFunction has been removed. Use #'text property on TupletNumber")
2461 @rule ((2, 9, 13), "instrument -> instrumentName, instr -> shortInstrumentName, vocNam -> shortVocalName")
2463 str = re.sub ('vocNam', 'shortVocalName', str)
2464 str = re.sub (r'\.instr\s*=', r'.shortInstrumentName =', str)
2465 str = re.sub (r'\.instrument\s*=', r'.instrumentName =', str)
2469 @rule ((2, 9, 16), _ ("deprecate \\tempo in \\midi"))
2473 dur = int (m.group (1))
2474 dots = len (m.group (2))
2475 count = int (m.group (3))
2482 den = (1 << dots) * (1 << log2)
2483 num = ((1 << (dots+1)) - 1)
2489 tempoWholesPerMinute = #(ly:make-moment %d %d)
2493 """ % (num*count, den)
2495 str = re.sub (r'\\midi\s*{\s*\\tempo ([0-9]+)\s*([.]*)\s*=\s*([0-9]+)\s*}', sub_tempo, str)
2499 @rule ((2, 9, 19), "printfirst-page-number -> print-first-page-number")
2501 str = re.sub ('printfirst-page-number', 'print-first-page-number', str)
2505 @rule ((2, 10, 0), _ ("bump version for release"))
2510 @rule ((2, 11, 2), "ly:clone-parser -> ly:parser-clone")
2512 return re.sub ('ly:clone-parser',
2513 'ly:parser-clone', str)
2515 @rule ((2, 11, 3), "no-spacing-rods -> extra-spacing-width")
2517 str = re.sub (r"no-spacing-rods\s+=\s+##t", r"extra-spacing-width = #'(+inf.0 . -inf.0)", str)
2518 str = re.sub (r"no-spacing-rods\s+=\s+##f", r"extra-spacing-width = #'(0 . 0)", str)
2522 @rule ((2, 11, 5), _ ("deprecate cautionary-style. Use AccidentalCautionary properties"))
2524 str = re.sub ("Accidental\s*#'cautionary-style\s*=\s*#'smaller",
2525 "AccidentalCautionary #'font-size = #-2", str)
2526 str = re.sub ("Accidental\s*#'cautionary-style\s*=\s*#'parentheses",
2527 "AccidentalCautionary #'parenthesized = ##t", str)
2528 str = re.sub ("([A-Za-z]+)\s*#'cautionary-style\s*=\s*#'parentheses",
2529 r"\1 #'parenthesized = ##t", str)
2530 str = re.sub ("([A-Za-z]+)\s*#'cautionary-style\s*=\s*#'smaller",
2531 r"\1 #'font-size = #-2", str)
2535 @rule ((2, 11, 6), _ ("Rename accidental glyphs, use glyph-name-alist."))
2538 def sub_acc_name (m):
2539 idx = int (m.group (1).replace ('M','-'))
2541 return ["accidentals.doublesharp",
2542 "accidentals.sharp.slashslash.stemstemstem",
2543 "accidentals.sharp",
2544 "accidentals.sharp.slashslash.stem",
2545 "accidentals.natural",
2546 "accidentals.mirroredflat",
2548 "accidentals.mirroredflat.flat",
2549 "accidentals.flatflat"][4-idx]
2551 str = re.sub (r"accidentals[.](M?[-0-9]+)",
2553 str = re.sub (r"(KeySignature|Accidental[A-Za-z]*)\s*#'style\s*=\s*#'([a-z]+)",
2554 r"\1 #'glyph-name-alist = #alteration-\2-glyph-name-alist", str)
2555 ## FIXME: standard vs default, alteration-FOO vs FOO-alteration
2556 str = str.replace ('alteration-default-glyph-name-alist',
2557 'standard-alteration-glyph-name-alist')
2561 @rule ((2, 11, 10), """allowBeamBreak -> Beam #'breakable = ##t
2562 addquote -> addQuote
2565 str = re.sub (r'(\\set\s+)?([A-Z][a-zA-Z]+\s*\.\s*)allowBeamBreak',
2566 r"\override \2Beam #'breakable", str)
2567 str = re.sub (r'(\\set\s+)?allowBeamBreak',
2568 r"\override Beam #'breakable", str)
2569 str = re.sub (r'addquote', 'addQuote', str)
2570 if re.search ("Span_dynamic_performer", str):
2571 stderr_write ("Span_dynamic_performer has been merged into Dynamic_performer")
2576 @rule ((2, 11, 11), "layout-set-staff-size -> layout-set-absolute-staff-size")
2578 str = re.sub (r'\(layout-set-staff-size \(\*\s*([0-9.]+)\s*(pt|mm|cm)\)\)',
2579 r'(layout-set-absolute-staff-size (* \1 \2))', str)
2583 @rule ((2, 11, 13), "#'arrow = ##t -> #'bound-details #'right #'arrow = ##t")
2585 str = re.sub (r"\\override\s*([a-zA-Z.]+)\s*#'arrow\s*=\s*##t",
2586 r"\\override \1 #'bound-details #'right #'arrow = ##t",
2589 if re.search ('edge-text', str):
2590 stderr_write (NOT_SMART % _ ("edge-text settings for TextSpanner"))
2591 stderr_write (_ ("Use\n\n%s") %
2592 "\t\\override TextSpanner #'bound-details #'right #'text = <right-text>\n"
2593 "\t\\override TextSpanner #'bound-details #'left #'text = <left-text>\n")
2597 @rule ((2, 11, 15), "TextSpanner #'edge-height -> #'bound-details #'right/left #'text = ...\n\
2598 Remove 'forced-distance for fixed spacing between staves in a PianoStaff.")
2600 def sub_edge_height (m):
2602 for (var, h) in [('left', m.group (3)),
2603 ('right', m.group (4))]:
2609 context = m.group (2)
2613 s += (r"%s \override %sTextSpanner #'bound-details #'%s #'text = \markup { \draw-line #'(0 . %s) }"
2614 % (once, context, var, h))
2621 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)
2622 if re.search (r"#'forced-distance", str):
2623 stderr_write (NOT_SMART % "VerticalAlignment #'forced-distance")
2624 stderr_write (_ ("Use the `alignment-offsets' sub-property of\n"))
2625 stderr_write (_ ("NonMusicalPaperColumn #'line-break-system-details\n"))
2626 stderr_write (_ ("to set fixed distances between staves.\n"))
2630 @rule ((2, 11, 23), "#'break-align-symbol -> #'break-align-symbols")
2632 str = re.sub (r"\\override\s*([a-zA-Z.]+)\s*#'break-align-symbol\s*=\s*#'([a-z-]+)",
2633 r"\\override \1 #'break-align-symbols = #'(\2)", str)
2637 @rule ((2, 11, 35), """scripts.caesura -> scripts.caesura.curved.
2638 """ + _ ("Use #'style not #'dash-fraction to select solid/dashed lines."))
2640 str = re.sub (r"scripts\.caesura",
2641 r"scripts.caesura.curved", str)
2643 if re.search ('dash-fraction', str):
2644 stderr_write (NOT_SMART % _ ("all settings related to dashed lines"))
2645 stderr_write (_ ("Use \\override ... #'style = #'line for solid lines and\n"))
2646 stderr_write (_ ("\t\\override ... #'style = #'dashed-line for dashed lines."))
2650 @rule ((2, 11, 38), """\\setEasyHeads -> \\easyHeadsOn, \\fatText -> \\textLengthOn,
2651 \\emptyText -> \\textLengthOff""")
2653 str = re.sub (r"setEasyHeads", r"easyHeadsOn", str)
2654 str = re.sub (r"fatText", r"textLengthOn", str)
2655 str = re.sub (r"emptyText", r"textLengthOff", str)
2659 @rule ((2, 11, 46), "\\set hairpinToBarline -> \\override Hairpin #'to-barline")
2661 str = re.sub (r"\\set\s+([a-zA-Z]+)\s*.\s*hairpinToBarline\s*=\s*##([tf]+)",
2662 r"\\override \1.Hairpin #'to-barline = ##\2", str)
2663 str = re.sub (r"\\set\s+hairpinToBarline\s*=\s*##([tf]+)",
2664 r"\\override Hairpin #'to-barline = ##\1", str)
2665 str = re.sub (r"\\unset\s+([a-zA-Z]+)\s*.\s*hairpinToBarline",
2666 r"\\revert \1.Hairpin #'to-barline", str)
2667 str = re.sub (r"\\unset\s+hairpinToBarline",
2668 r"\\revert Hairpin #'to-barline", str)
2669 str = re.sub (r"hairpinToBarline\s*=\s*##([tf]+)",
2670 r"\\override Hairpin #'to-barline = ##\1", str)
2671 str = re.sub (r"\\set (de|)crescendoSpanner = #'dashed-line",
2672 r"\\set \1crescendoSpanner = #'text", str)
2676 @rule ((2, 11, 48), "\\compressMusic -> \\scaleDurations")
2678 str = re.sub (r"compressMusic", r"scaleDurations", str)
2682 @rule ((2, 11, 50), _ ("metronomeMarkFormatter uses text markup as second argument,\n\
2683 fret diagram properties moved to fret-diagram-details."))
2685 ## warning 1/2: metronomeMarkFormatter uses text markup as second argument
2686 if re.search ('metronomeMarkFormatter', str):
2687 stderr_write (NOT_SMART % "metronomeMarkFormatter")
2688 stderr_write (_ ("metronomeMarkFormatter got an additional text argument.\n"))
2689 stderr_write (_ ("The function assigned to Score.metronomeMarkFunction now uses the signature\n%s") %
2690 "\t(format-metronome-markup text dur count context)\n")
2692 ## warning 2/2: fret diagram properties moved to fret-diagram-details
2693 fret_props = ['barre-type',
2701 'xo-font-magnification',
2705 for prop in fret_props:
2706 if re.search (prop, str):
2707 stderr_write (NOT_SMART % (_ ("%s in fret-diagram properties") % prop))
2708 stderr_write (_ ('Use %s\n') % "fret-diagram-details")
2711 @rule ((2, 11, 51), "\\octave -> \\octaveCheck, \\arpeggioUp -> \\arpeggioArrowUp,\n\
2712 \\arpeggioDown -> \\arpeggioArrowDown, \\arpeggioNeutral -> \\arpeggioNormal,\n\
2713 \\setTextCresc -> \\crescTextCresc, \\setTextDecresc -> \\dimTextDecresc,\n\
2714 \\setTextDecr -> \\dimTextDecr, \\setTextDim -> \\dimTextDim,\n\
2715 \\setHairpinCresc -> \\crescHairpin, \\setHairpinDecresc -> \\dimHairpin,\n\
2716 \\sustainUp -> \\sustainOff, \\sustainDown -> \\sustainOn\n\
2717 \\sostenutoDown -> \\sostenutoOn, \\sostenutoUp -> \\sostenutoOff")
2719 str = re.sub (r"\\octave(?![a-zA-Z])", r"\\octaveCheck", str)
2720 str = re.sub (r"arpeggioUp", r"arpeggioArrowUp", str)
2721 str = re.sub (r"arpeggioDown", r"arpeggioArrowDown", str)
2722 str = re.sub (r"arpeggioNeutral", r"arpeggioNormal", str)
2723 str = re.sub (r"setTextCresc", r"crescTextCresc", str)
2724 str = re.sub (r"setTextDecresc", r"dimTextDecresc", str)
2725 str = re.sub (r"setTextDecr", r"dimTextDecr", str)
2726 str = re.sub (r"setTextDim", r"dimTextDim", str)
2727 str = re.sub (r"setHairpinCresc", r"crescHairpin", str)
2728 str = re.sub (r"setHairpinDecresc", r"dimHairpin", str)
2729 str = re.sub (r"sustainUp", r"sustainOff", str)
2730 str = re.sub (r"sustainDown", r"sustainOn", str)
2731 str = re.sub (r"sostenutoDown", r"sostenutoOn", str)
2732 str = re.sub (r"sostenutoUp", r"sostenutoOff", str)
2735 @rule ((2, 11, 52), "\\setHairpinDim -> \\dimHairpin")
2737 str = str.replace ("setHairpinDim", "dimHairpin")
2740 @rule ((2, 11, 53), "infinite-spacing-height -> extra-spacing-height")
2742 str = re.sub (r"infinite-spacing-height\s+=\s+##t", r"extra-spacing-height = #'(-inf.0 . +inf.0)", str)
2743 str = re.sub (r"infinite-spacing-height\s+=\s+##f", r"extra-spacing-height = #'(0 . 0)", str)
2746 @rule ((2, 11, 55), "#(set-octavation oct) -> \\ottava #oct,\n\
2747 \\put-adjacent markup axis dir markup -> \\put-adjacent axis dir markup markup")
2749 str = re.sub (r"#\(set-octavation (-*[0-9]+)\)", r"\\ottava #\1", str)
2750 if re.search ('put-adjacent', str):
2751 stderr_write (NOT_SMART % _ ("\\put-adjacent argument order"))
2752 stderr_write (_ ("Axis and direction now come before markups:\n"))
2753 stderr_write (_ ("\\put-adjacent axis dir markup markup."))
2757 @rule ((2, 11, 57), "\\center-align -> \\center-column, \\hcenter -> \\center-align")
2759 str = re.sub (r"([\\:]+)center-align", r"\1center-column", str)
2760 str = re.sub (r"hcenter(\s+)", r"center-align\1", str)
2763 @rule ((2, 11, 60), "printallheaders -> print-all-headers")
2765 str = re.sub (r"printallheaders", r"print-all-headers", str)
2768 @rule ((2, 11, 61), "gregorian-init.ly -> gregorian.ly")
2770 str = re.sub (r'\\include(\s+)"gregorian-init.ly"', r'\\include\1"gregorian.ly"', str)
2773 @rule ((2, 11, 62), "makam-init.ly -> makam.ly, \\bigger -> \\larger")
2775 str = re.sub (r'\\include(\s+)"makam-init.ly"', r'\\include\1"makam.ly"', str)
2776 str = re.sub (r"([\\:])bigger", r"\1larger", str)
2779 @rule ((2, 11, 64), "systemSeparatorMarkup -> system-separator-markup,\n\
2780 InnerStaffGroup -> StaffGroup, InnerChoirStaff -> ChoirStaff")
2782 str = re.sub (r'systemSeparatorMarkup', r'system-separator-markup', str)
2783 if re.search (r'\\InnerStaffGroup', str):
2784 stderr_write (NOT_SMART % _("re-definition of InnerStaffGroup"))
2785 stderr_write (FROM_TO % ("InnerStaffGroup", "StaffGroup"))
2786 stderr_write (UPDATE_MANUALLY)
2787 raise FatalConversionError ()
2788 if re.search (r'\\InnerChoirStaff', str):
2789 stderr_write (NOT_SMART % _("re-definition of InnerChoirStaff"))
2790 stderr_write (FROM_TO % ("InnerChoirStaff", "ChoirStaff"))
2791 stderr_write (UPDATE_MANUALLY)
2792 raise FatalConversionError ()
2794 str = re.sub ('InnerStaffGroup', 'StaffGroup', str)
2795 str = re.sub ('InnerChoirStaff', 'ChoirStaff', str)
2799 _ ("Syntax changes for \\addChordShape and \\chord-shape") + "\n" + \
2800 _ ("bump version for release"))
2802 if re.search(r'\\addChordShape', str):
2803 stderr_write (NOT_SMART % "addChordShape")
2804 stderr_write (_ ("stringTuning must be added to addChordShape call.\n"))
2805 stderr_write (UPDATE_MANUALLY)
2806 raise FatalConversionError ()
2807 if re.search (r'\\chord-shape', str):
2808 stderr_write (NOT_SMART % "chord-shape")
2809 stderr_write (_ ("stringTuning must be added to chord-shape call.\n"))
2810 stderr_write (UPDATE_MANUALLY)
2811 raise FatalConversionError ()
2815 _ ("Remove oldaddlyrics"))
2817 if re.search(r'\\oldaddlyrics', str):
2818 stderr_write (NOT_SMART % "oldaddlyrics")
2819 stderr_write (_ ("oldaddlyrics is no longer supported. \n \
2820 Use addlyrics or lyrsicsto instead.\n"))
2821 stderr_write (UPDATE_MANUALLY)
2822 raise FatalConversionError ()
2825 @rule ((2, 13, 0), _ ("keySignature property not reversed any more\n\
2826 MIDI 47: orchestral strings -> orchestral harp"))
2828 if re.search(r'\set Staff.keySignature', str):
2829 stderr_write (NOT_SMART % "Staff.keySignature")
2830 stderr_write (_ ("The alist for Staff.keySignature is no \
2831 longer in reversed order.\n"))
2832 str = str.replace('"orchestral strings"', '"orchestral harp"')
2836 _ ("\\bar \".\" now produces a thick barline\n\
2837 ly:hairpin::after-line-breaking -> ly:spanner::kill-zero-spanned-time\n\
2838 Dash parameters for slurs and ties are now in dash-definition"))
2840 if re.search(r'\\bar\s*"\."', str):
2841 stderr_write (NOT_SMART % "\\bar \".\"")
2842 stderr_write (_ ("\\bar \".\" now produces a thick barline.\n"))
2843 stderr_write (UPDATE_MANUALLY)
2844 str = re.sub (r'ly:hairpin::after-line-breaking', r'ly:spanner::kill-zero-spanned-time', str)
2845 if re.search("(Slur|Tie)\w+#\'dash-fraction", str) \
2846 or re.search("(Slur|Tie)\w+#\'dash-period", str):
2847 stderr_write (NOT_SMART % "dash-fraction, dash-period")
2848 stderr_write (_ ("Dash parameters for slurs and ties are now in \'dash-details.\n"))
2849 stderr_write (UPDATE_MANUALLY)
2853 _ ("Autobeaming rules have changed. override-auto-beam-setting and\n\
2854 revert-auto-beam-setting have been eliminated.\n\
2855 \\overrideBeamSettings has been added.\n\
2856 beatGrouping has been eliminated.\n\
2857 Different settings for vertical layout.\n\
2858 ly:system-start-text::print -> system-start-text::print\n\
2859 Beam #'thickness -> Beam #'beam-thickness\n\
2860 ly:note-head::brew-ez-stencil -> note-head::brew-ez-stencil\n\
2861 ly:ambitus::print -> ambitus::print\n\
2862 Explicit dynamics context definition from `Piano centered dynamics'\n\
2863 template replaced by new `Dynamics' context."))
2865 if re.search("override-auto-beam-setting", str):
2866 stderr_write (NOT_SMART % "override-auto-beam-setting")
2867 stderr_write (_ (" \
2868 Autobeam settings are now overriden with \\overrideBeamSettings.\n"))
2869 stderr_write (UPDATE_MANUALLY)
2870 if re.search("revert-auto-beam-setting", str):
2871 stderr_write (NOT_SMART % "override-auto-beam-setting")
2872 stderr_write (_ (" \
2873 Autobeam settings are now reverted with \\revertBeamSettings.\n"))
2874 stderr_write (UPDATE_MANUALLY)
2875 str = re.sub(r"\\set\s+beatGrouping", r"\\setBeatGrouping", str)
2876 if re.search(r"\w+\s*.\s*beatGrouping", str):
2877 stderr_write (NOT_SMART % "beatGrouping")
2878 stderr_write (_ (" \
2879 beatGrouping with a specified context must now be accomplished with\n\
2880 \\overrideBeamSettings.\n"))
2881 stderr_write (UPDATE_MANUALLY)
2882 if re.search(r'alignment-offsets', str):
2883 stderr_write (NOT_SMART % "alignment-offsets")
2884 stderr_write (_ ("alignment-offsets has been changed to alignment-distances: \
2885 you must now specify the distances between staves rather than the offset of staves.\n"))
2886 stderr_write (UPDATE_MANUALLY)
2887 str = re.sub ('ly:(system-start-text::print|note-head::brew-ez-stencil|ambitus::print)',
2889 str = re.sub ('(\\bBeam\\s+#\')(?=thickness\\b)', '\\1beam-', str)
2890 str = re.sub (r'(\\context\s*\{{1}[^\}]+\\type\s+\"?Engraver_group\"?\s+\\name\s+"*Dynamics"*[^\}]*\}{1})',
2891 '% [Convert-ly] The Dynamics context is now included by default.', str)
2895 _ ("Remove obsolete engravers/translators: Note_swallow_translator,\n\
2896 Rest_swallow_translator, Skip_event_swallow_translator, Swallow_engraver,\n\
2897 Swallow_performer and String_number_engraver.\n\
2898 New vertical spacing variables."))
2900 str = re.sub (r'\\(consists|remove)\s+"*(Swallow_(engraver|performer)|'
2901 '(Note|Rest|Skip_event)_swallow_translator|String_number_engraver)"*',
2904 # match through the end of assignments in the form "x = 30", "x = 1 \in", or "x = #3"
2905 str = re.sub (r"(page-top-space)\s*=\s*(([+-]?[.\d]*\s*\\[-\w]+)|(#?\s*[-+]?[.\d]+))",
2907 r" top-system-spacing #'space = #(/ obsolete-\1 staff-space)",
2909 str = re.sub (r"(between-system-space)\s*=\s*(([+-]?[.\d]*\s*\\[-\w]+)|(#?\s*[-+]?[.\d]+))",
2911 r" between-system-spacing #'space = #(/ obsolete-\1 staff-space)"
2912 r" between-scores-system-spacing #'space = #(/ obsolete-\1 staff-space)",
2914 str = re.sub (r"(between-system-padding)\s*=\s*(([+-]?[.\d]*\s*\\[-\w]+)|(#?\s*[-+]?[.\d]+))",
2916 r" between-system-spacing #'padding = #(/ obsolete-\1 staff-space)"
2917 r" between-scores-system-spacing #'padding = #(/ obsolete-\1 staff-space)",
2919 str = re.sub (r"((before|between|after)-title-space)\s*=\s*(([+-]?[.\d]*\s*\\[-\w]+)|(#?\s*[-+]?[.\d]+))",
2921 r" \2-title-spacing #'space = #(/ obsolete-\1 staff-space)",
2924 if re.search(r"VerticalAxisGroup\s*#\s*'minimum-Y-extent", str):
2925 stderr_write (NOT_SMART % "minimum-Y-extent")
2926 stderr_write (_ ("Vertical spacing no longer depends on the Y-extent of a VerticalAxisGroup.\n"))
2927 stderr_write (UPDATE_MANUALLY)
2932 _ ("Unify fetaNumber and fetaDynamic encodings"))
2934 return re.sub(r'\bfeta(Number|Dynamic)', 'fetaText', str)
2937 _ ("\\RemoveEmpty*StaffContext -> \\*Staff \\RemoveEmptyStaves"))
2939 str = re.sub (r"\\RemoveEmpty(|Drum|Rhythmic|Tab)StaffContext",
2940 r"\\\1Staff \\RemoveEmptyStaves",
2942 str = re.sub (r"\\AncientRemoveEmptyStaffContext",
2943 r"\\VaticanaStaff \\RemoveEmptyStaves",
2948 _ ("\\cresc etc. are now postfix operators"))
2950 str = re.sub (r'\\(cresc|dim|endcresc|enddim)\b', r'\\deprecated\1', str)
2954 ("interval-translate -> coord-translate"))
2956 str = re.sub ('interval-translate', 'coord-translate', str)
2960 _ ("Eliminate beamSettings, beatLength, \\setBeatGrouping, \\overrideBeamSettings and \\revertBeamSettings.\n\
2961 \"accordion.accEtcbase\" -> \"accordion.etcbass\""))
2966 'Discant': 'discant',
2967 'Bayanbase': 'bayanbass',
2968 'Stdbase': 'stdbass',
2969 'Freebase': 'freebass',
2972 return '"accordion.%s"' % d[m.group (1)]
2974 str = re.sub (r'"accordion\.acc([a-zA-Z]+)"',
2976 if re.search(r'overrideBeamSettings', str):
2977 stderr_write (NOT_SMART % "\\overrideBeamSettings")
2978 stderr_write (_ ("Use \\set beamExceptions or \\overrideTimeSignatureSettings.\n"))
2979 stderr_write (UPDATE_MANUALLY)
2980 if re.search(r'revertBeamSettings', str):
2981 stderr_write (NOT_SMART % "\\revertBeamSettings")
2982 stderr_write (_ ("Use \\set beamExceptions or \\revertTimeSignatureSettings.\n"))
2983 stderr_write (UPDATE_MANUALLY)
2984 if re.search(r'beamSettings', str):
2985 stderr_write (NOT_SMART % "beamSettings")
2986 stderr_write (_ ("Use baseMoment, beatStructure, and beamExceptions.\n"))
2987 stderr_write (UPDATE_MANUALLY)
2988 if re.search(r'beatLength', str):
2989 stderr_write (NOT_SMART % "beatLength")
2990 stderr_write (_ ("Use baseMoment and beatStructure.\n"))
2991 stderr_write (UPDATE_MANUALLY)
2992 if re.search(r'setBeatGrouping', str):
2993 stderr_write (NOT_SMART % "setbeatGrouping")
2994 stderr_write (_ ("Use baseMoment and beatStructure.\n"))
2995 stderr_write (UPDATE_MANUALLY)
2999 _ ("Woodwind diagrams: Move size, thickness, and graphic from argument list to properties.\n\
3000 Deprecate negative dash-period for hidden lines: use #'style = #'none instead."))
3002 if re.search(r'woodwind-diagram', str):
3003 stderr_write (NOT_SMART % "woodwind-diagrams")
3004 stderr_write (_ ("Move size, thickness, and graphic to properties. Argument should be just the key list.\n"))
3005 stderr_write (UPDATE_MANUALLY)
3006 str = re.sub (r"dash-period\s+=\s*#\s*-[0-9.]+",
3012 _ ("Rename vertical spacing variables.\n\
3013 Add fretboard-table argument to savePredefinedFretboard."))
3015 str = re.sub ('after-title-spacing', 'markup-system-spacing', str)
3016 str = re.sub ('before-title-spacing', 'score-markup-spacing', str)
3017 str = re.sub ('between-scores-system-spacing', 'score-system-spacing', str)
3018 # this rule also converts page-breaking-between-system-spacing:
3019 str = re.sub ('between-system-spacing', 'system-system-spacing', str)
3020 str = re.sub ('between-title-spacing', 'markup-markup-spacing', str)
3021 str = re.sub ('bottom-system-spacing', 'last-bottom-spacing', str)
3022 str = re.sub ('top-title-spacing', 'top-markup-spacing', str)
3024 str = re.sub (r"storePredefinedDiagram",
3025 r"storePredefinedDiagram #default-fret-table",
3030 _ ("Rename vertical spacing grob properties."))
3032 # this rule also converts default-next-staff-spacing:
3033 str = re.sub ('next-staff-spacing', 'staff-staff-spacing', str)
3034 # this is not a mistake:
3035 # Both 'next- and 'between- become 'staff-staff-spacing.
3036 # There is no conflict since they are in different grobs.
3037 str = re.sub ('between-staff-spacing', 'staff-staff-spacing', str)
3038 str = re.sub ('after-last-staff-spacing', 'staffgroup-staff-spacing', str)
3039 str = re.sub ('inter-staff-spacing', 'nonstaff-relatedstaff-spacing', str)
3040 str = re.sub ('non-affinity-spacing', 'nonstaff-unrelatedstaff-spacing', str)
3041 str = re.sub ('inter-loose-line-spacing', 'nonstaff-nonstaff-spacing', str);
3046 _ ("Remove \\paper variables head-separation and foot-separation."))
3048 if re.search (r'head-separation', str):
3049 stderr_write (NOT_SMART % "head-separation")
3050 stderr_write (_ ("Adjust settings for top-system-spacing instead.\n"))
3051 stderr_write (UPDATE_MANUALLY)
3052 if re.search (r'foot-separation', str):
3053 stderr_write (NOT_SMART % "foot-separation")
3054 stderr_write (_ ("Adjust settings for last-bottom-spacing instead.\n"))
3055 stderr_write (UPDATE_MANUALLY);
3060 _ ("Rename space to basic-distance in various spacing alists.\n\
3061 Remove HarmonicParenthesesItem grob."))
3063 str = re.sub (r'\(space\s+\.\s+([0-9]*\.?[0-9]*)\)', r'(basic-distance . \1)', str)
3064 str = re.sub (r"#'space\s+=\s+#?([0-9]*\.?[0-9]*)", r"#'basic-distance = #\1", str)
3065 if re.search (r'HarmonicParenthesesItem', str):
3066 stderr_write (NOT_SMART % "HarmonicParenthesesItem")
3067 stderr_write (_ ("HarmonicParenthesesItem has been eliminated.\n"))
3068 stderr_write (_ ("Harmonic parentheses are part of the TabNoteHead grob.\n"))
3069 stderr_write (UPDATE_MANUALLY);
3073 _ ("Remove context from overrideTimeSignatureSettings and revertTimeSignatureSettings.\n"))
3076 str = re.sub (r"\\(override|revert)TimeSignatureSettings(\s+[^#]*)(#[^#]*)#", r"\\\1TimeSignatureSettings\2#", str)
3080 _ ("Change stringTunings from a list of semitones to a list of pitches.\n"\
3081 "Change tenor and baritone ukulele names in string tunings.\n"\
3082 "Generate messages for manual conversion of vertical spacing if required."))
3085 def semitones2pitch(semitones):
3086 steps = [0, 0, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6]
3087 alterations = ["NATURAL", "SHARP", "NATURAL", "SHARP", "NATURAL", "NATURAL", "SHARP", "NATURAL", "SHARP", "NATURAL", "SHARP", "NATURAL"]
3089 while semitones > 11:
3092 while semitones < 0:
3095 pitchArgs = "%d %d %s" % (octave, steps[semitones], alterations[semitones])
3098 def convert_tones (semitone_list):
3099 tones = semitone_list.split ()
3102 args = semitones2pitch(int(tone))
3103 res += ",(ly:make-pitch " + args + ") "
3106 def new_tunings (matchobj):
3107 return "stringTunings = #`(" + convert_tones(matchobj.group(1)) + ")"
3108 str = re.sub (r"stringTunings\s*=\s*#'\(([\d\s-]*)\)", \
3111 str = re.sub (r"ukulele-(tenor|baritone)-tuning", r"\1-ukulele-tuning", str)
3113 if re.search (r"[^-]page-top-space", str):
3114 stderr_write (NOT_SMART % "page-top-space")
3115 stderr_write (UPDATE_MANUALLY)
3116 if re.search (r"[^-]between-system-(space|padding)", str):
3117 stderr_write (NOT_SMART % "between-system-space, -padding")
3118 stderr_write (UPDATE_MANUALLY)
3119 if re.search (r"[^-](before|between|after)-title-space", str):
3120 stderr_write (NOT_SMART % "before-, between-, after-title-space")
3121 stderr_write (UPDATE_MANUALLY)
3122 if re.search (r"\\name\s", str):
3123 stderr_write ("\n" + _("Vertical spacing changes might affect user-defined contexts.") + "\n")
3124 stderr_write (UPDATE_MANUALLY)
3129 _ ("Replace bar-size with bar-extent."))
3132 def size_as_extent (matchobj):
3133 half = "%g" % (float (matchobj.group (1)) / 2)
3134 return "bar-extent = #'(-" + half + " . " + half + ")"
3136 str = re.sub (r"bar-size\s*=\s*#([0-9\.]+)", size_as_extent, str)
3141 _ ("Woodwind diagrams: Changes to the clarinet diagram."))
3143 if re.search (r'\\woodwind-diagram\s*#[^#]*clarinet\s', str):
3144 stderr_write (NOT_SMART % "woodwind-diagrams")
3145 stderr_write (_ ("Clarinet fingering changed to reflect actual anatomy of instrument.\n"))
3146 stderr_write (UPDATE_MANUALLY)
3150 _ ("bump version for release"))
3155 _ ("Handling of non-automatic footnotes."))
3157 if re.search (r'\\footnote', str):
3158 stderr_write (NOT_SMART % "\\footnote")
3159 stderr_write (_ ("If you are using non-automatic footnotes, make sure to set footnote-auto-numbering = ##f in the paper block.\n"))
3160 stderr_write (UPDATE_MANUALLY)
3164 _ ("Change in internal property for MultiMeasureRest"))
3166 if re.search (r'use-breve-rest',str):
3167 stderr_write (NOT_SMART % "use-breve-rest")
3168 stderr_write (_ ("This internal property has been replaced by round-up-to-longer-rest, round-up-exceptions and usable-duration-logs.\n"))
3169 stderr_write (UPDATE_MANUALLY)
3173 _ ("Creation of a Flag grob and moving of certain Stem properties to this grob"))
3175 str = re.sub (r"Stem\s+#'flag-style", r"Flag #'style", str)
3176 str = re.sub (r"Stem\s+#'stroke-style", r"Flag #'stroke-style", str)
3177 str = re.sub (r"Stem\s+#'flag", r"Flag #'print", str)
3178 str = re.sub (r"(\s+(?:\\once\s*)?)\\override\s+Stem\s+#'transparent\s*=\s*##t", r"\g<1>\\override Stem #'transparent = ##t\g<1>\\override Flag #'transparent = ##t", str)
3179 str = re.sub (r"(\s+(?:\\once\s*)?)\\revert\s*Stem\s+#'transparent", r"\g<1>\\revert Stem #'transparent\g<1>\\revert Flag #'transparent", str)
3180 str = re.sub (r"(\s+(?:\\once\s*)?)\\override\s+Stem\s+#'stencil\s*=\s*##f", r"\g<1>\\override Stem #'stencil = ##f\g<1>\\override Flag #'stencil = ##f", str)
3181 str = re.sub (r"(\s+(?:\\once\s*)?)\\revert\s*Stem\s+#'stencil", r"\g<1>\\revert Stem #'stencil\g<1>\\revert Flag #'stencil", str)
3184 @rule ((2, 15, 16), r"\makeStringTuning, \contextStringTuning -> \stringTuning")
3186 str = re.sub (r"(\s+)\\contextStringTuning(\s+)#'([-a-zA-Z]+)(\s+<[^<>]+>)",
3187 r"""\g<1>#(define \g<3> #{ \\stringTuning\g<4> #})\g<1>\\set stringTunings = #\g<3>""",
3190 \\makeStringTuning(\s+)#'([-a-zA-Z]+)""",
3192 "\g<2>" = \\stringTuning""", str)
3193 str = re.sub (r"\\makeStringTuning(\s+)#'([-a-zA-Z]+)(\s+<[^<>]+>)",
3194 r"#(define \g<2> #{ \\stringTuning\g<3> #})", str)
3197 @rule ((2, 15, 17), "\\markuplines -> \\markuplist\n\
3198 Change Beam broken slope syntax.")
3201 \\markuplines( +)([^ ].*)
3203 \\markuplist\g<1>\g<2>
3205 str = re.sub (r"\\markuplines", r"\\markuplist", str)
3206 str = re.sub (r"@funindex markuplines", r"@funindex markuplist", str)
3207 if re.search (r'consistent-broken-slope', str):
3208 stderr_write (NOT_SMART % "consistent-broken-slope")
3209 stderr_write (_ ("consistent-broken-slope is now handled through the positions callback.\n"))
3210 stderr_write (_ ("input/regression/beam-broken-classic.ly shows how broken beams are now handled.\n"))
3211 stderr_write (UPDATE_MANUALLY)
3214 def paren_matcher (n):
3215 # poor man's matched paren scanning, gives up
3216 # after n+1 levels. Matches any string with balanced
3217 # parens inside; add the outer parens yourself if needed.
3219 return r"[^()]*?(?:\("*n+r"[^()]*?"+r"\)[^()]*?)*?"*n
3222 def undollar_scm (m):
3223 return re.sub (r"\$(.?)", r"\1", m.group (0))
3225 def undollar_embedded (m):
3226 str = re.sub (r"#\$", "#", m.group (1))
3227 # poor man's matched paren scanning after #, gives up
3229 str = re.sub ("#`?\("+paren_matcher (25)+"\)", undollar_scm, str)
3230 return m.string[m.start (0):m.start (1)] + str + m.string[m.end (1):m.end (0)]
3232 def strip_export (str):
3233 return re.sub (r"\(ly:export\s+(" + paren_matcher (25) + r")\)",
3236 def export_puller (m):
3237 if not re.search (r"ly:export\s+", m.group (0)):
3239 return "$" + strip_export (m.string[m.start (0)+1:m.end (0)])
3241 def ugly_function_rewriter (m):
3242 return m.string[m.start(0):m.start(1)] + strip_export (m.group (1)) + m.string[m.end(1):m.end(0)]
3244 should_really_be_music_function = "(?:\
3245 set-time-signature|empty-music|add-grace-property|\
3246 remove-grace-property|set-accidental-style)"
3248 def record_ugly (m):
3249 global should_really_be_music_function
3250 if not re.match (should_really_be_music_function, m.group (1)) \
3251 and re.search (r"ly:export\s+", m.group (2)):
3252 should_really_be_music_function = \
3253 should_really_be_music_function[:-1] + "|" + m.group (1) + ")"
3256 @rule ((2, 15, 18), "#$ -> #, ly:export -> $")
3258 str = re.sub (r"(?s)#@?\{(.*?)#@?\}", undollar_embedded, str)
3259 str = re.sub (r"#\(define(?:-public)?\s+\(([-a-zA-Z]+)"
3260 + r"\b[^()]*?\)(" + paren_matcher (25)
3261 + r")\)", record_ugly, str)
3262 str = re.sub (r"\(define(?:-public)?\s+\(" + should_really_be_music_function
3263 + r"\b[^()]*\)(" + paren_matcher (25)
3264 + r")\)", ugly_function_rewriter, str)
3265 str = re.sub (r"#(?=\(" + should_really_be_music_function + ")", "$", str)
3266 str = re.sub (r"#\(markup\*(?=\s)", r"$(markup", str)
3267 str = re.sub ("#\("+paren_matcher (25)+"\)", export_puller, str)
3268 if re.search (r"\(ly:export\s+", str):
3269 stderr_write (NOT_SMART % "ly:export")
3272 @rule ((2, 15, 19), r"$(set-time-signature ...) -> \time")
3274 str = re.sub (r"\$\(set-time-signature\s+([0-9]+)\s+([0-9]+)\s*\)",
3275 r"\\time \1/\2", str)
3276 str = re.sub (r"\$\(set-time-signature\s+([0-9]+)\s+([0-9]+)\s+(" +
3277 paren_matcher (5) + r")\)", r"\\time #\3 \1/\2", str)
3278 if re.search (r"\(set-time-signature\s+", str):
3279 stderr_write (NOT_SMART % "set-time-signature")
3282 @rule ((2, 15, 20), r"$(set-accidental-style ...) -> \accidentalStyle")
3284 str = re.sub (r"\$\(set-accidental-style\s+'([-a-z]+)\)",
3285 r'\\accidentalStyle "\1"', str)
3286 str = re.sub (r"\$\(set-accidental-style\s+'([-a-z]+)\s+'([-A-Za-z]+)\s*\)",
3287 r'''\\accidentalStyle #'\2 "\1"''', str)
3288 str = re.sub (r"(@funindex\s+)set-accidental-style",
3289 r"\1\\accidentalStyle", str)
3292 def brace_matcher (n):
3293 # poor man's matched brace scanning, gives up
3294 # after n+1 levels. Matches any string with balanced
3295 # braces inside; add the outer braces yourself if needed.
3297 return r"[^{}]*?(?:{"*n+r"[^{}]*?"+r"}[^{}]*?)*?"*n
3299 matchstring = r'"(?:[^"\\]|\\.)*"'
3300 matcharg = (r"\s+(?:[$#]['`]?\s*(?:[a-zA-Z]\S*|" + matchstring + r"|\("
3301 + paren_matcher(20) + r"\))|" + matchstring + r"|\\[a-z_A-Z]+)")
3302 matchmarkup = (r'(?:\\markup\s*(?:{' + brace_matcher (20) +r'}|' +
3303 matchstring + r'|(?:\\[a-z_A-Z][a-z_A-Z-]*(?:' + matcharg +
3304 r')*?\s*)*(?:' + matchstring + "|{" + brace_matcher (20) +
3305 "}))|" + matchstring + ")")
3307 @rule((2, 15, 25), r"\(auto)?Footnote(Grob)? -> \footnote")
3309 # The following replacement includes the final markup argument in
3310 # the match in order to better avoid touching the equally named
3311 # markup function. The other functions have unique names, so
3312 # there is no point in including their last, possibly complex
3313 # argument in the match.
3314 str = re.sub (r"\\footnote(" + matcharg + (r")(\s*" + matchmarkup)*2 + ")",
3315 r"\\footnote\2\1\3", str)
3316 str = re.sub (r"\\footnoteGrob"+("(" + matcharg + ")")*2 + r"(\s*" + matchmarkup + ")",
3317 r"\\footnote\3\2\1", str)
3318 str = re.sub (r"\\autoFootnoteGrob" + ("(" + matcharg + ")")*2,
3319 r"\\footnote\2\1", str)
3320 str = re.sub (r"\\autoFootnote",
3324 @rule((2, 15, 32), r"tempoWholesPerMinute -> \tempo")
3327 num = int (m.group (1))
3328 den = int (m.group (2))
3330 if (den & (den - 1)) != 0 :
3333 # Don't try dotted forms if they result in less than 30 bpm.
3334 # It is not actually relevant to get this right since this
3335 # only occurs in non-printing situations
3336 if den >= 16 and (num % 7) == 0 and num >= 210 :
3337 return r"\tempo %d.. = %d" % (den/4, num/7)
3339 if den >= 8 and (num % 3) == 0 and num >= 90 :
3340 return r"\tempo %d. = %d" % (den/2, num/3)
3342 return r"\tempo %d = %d" % (den, num)
3344 str = re.sub (r"\\context\s*@?\{\s*\\Score\s+tempoWholesPerMinute\s*=\s*" +
3345 r"#\(ly:make-moment\s+([0-9]+)\s+([0-9]+)\)\s*@?\}",
3350 # Guidelines to write rules (please keep this at the end of this file)
3352 # - keep at most one rule per version; if several conversions should be done,
3353 # concatenate them into a single "conv" function;
3355 # - enclose strings to be localized with `_(' and `)';
3357 # - write rule for bumping major stable version with
3359 # _ ("bump version for release")
3361 # as exact description.