1 # (setq py-indent-offset 4)
12 NOT_SMART
= _ ("Not smart enough to convert %s")
13 UPDATE_MANUALLY
= _ ("Please refer to the manual for details, and update manually.")
14 FROM_TO
= _ ( "%s has been replaced by %s")
17 class FatalConversionError
:
21 stderr_write
= lilylib
.stderr_write
24 stderr_write (_ ("warning: %s") % str)
26 # Decorator to make rule syntax simpler
27 def rule (version
, message
):
29 version: a LilyPond version tuple like (2, 11, 50)
30 message: the message that describes the conversion.
32 This decorator adds its function together with the version and the
33 message to the global conversions list. (It doesn't need to return
34 the function as it isn't used directly anyway.)
36 A conversion rule using this decorator looks like this:
38 @rule ((1, 2, 3), "convert foo to bar")
40 str = str.replace('foo', 'bar')
45 conversions
.append ((version
, f
, message
))
49 @rule ((0, 1, 9), _ ('\\header { key = concat + with + operator }'))
51 if re
.search ('\\\\multi', str):
53 stderr_write (NOT_SMART
% "\\multi")
58 @rule ((0, 1, 19), _ ('deprecated %s') % '\\octave')
60 if re
.search ('\\\\octave', str):
62 stderr_write (NOT_SMART
% "\\octave")
64 stderr_write (UPDATE_MANUALLY
)
66 # raise FatalConversionError ()
70 @rule ((0, 1, 20), _ ('deprecated \\textstyle, new \\key syntax'))
72 str = re
.sub ('\\\\textstyle([^;]+);',
73 '\\\\property Lyrics . textstyle = \\1', str)
74 # harmful to current .lys
75 # str = re.sub ('\\\\key([^;]+);', '\\\\accidentals \\1;', str)
79 @rule ((0, 1, 21), '\\musical_pitch -> \\musicalpitch, \\meter -> \\time')
81 str = re
.sub ('\\\\musical_pitch', '\\\\musicalpitch',str)
82 str = re
.sub ('\\\\meter', '\\\\time',str)
86 @rule ((1, 0, 0), _ ("bump version for release"))
91 @rule ((1, 0, 1), '\\accidentals -> \\keysignature, specialaccidentals -> keyoctaviation')
93 str = re
.sub ('\\\\accidentals', '\\\\keysignature',str)
94 str = re
.sub ('specialaccidentals *= *1', 'keyoctaviation = 0',str)
95 str = re
.sub ('specialaccidentals *= *0', 'keyoctaviation = 1',str)
99 @rule ((1, 0, 2), _ ('\\header { key = concat + with + operator }'))
101 if re
.search ('\\\\header', str):
103 stderr_write (NOT_SMART
% _ ("new \\header format"))
108 @rule ((1, 0, 3), '\\melodic -> \\notes')
110 str = re
.sub ('\\\\melodic([^a-zA-Z])', '\\\\notes\\1',str)
114 @rule ((1, 0, 4), 'default_{paper,midi}')
116 str = re
.sub ('default_paper *=', '',str)
117 str = re
.sub ('default_midi *=', '',str)
121 @rule ((1, 0, 5), 'ChoireStaff -> ChoirStaff')
123 str = re
.sub ('ChoireStaff', 'ChoirStaff',str)
124 str = re
.sub ('\\\\output', 'output = ',str)
128 @rule ((1, 0, 6), 'foo = \\translator {\\type .. } ->\\translator {\\type ..; foo; }')
130 if re
.search ('[a-zA-Z]+ = *\\translator',str):
132 stderr_write (NOT_SMART
% _ ("\\translator syntax"))
134 # raise FatalConversionError ()
138 @rule ((1, 0, 7), '\\lyric -> \\lyrics')
140 str = re
.sub ('\\\\lyrics*', '\\\\lyrics',str)
144 @rule ((1, 0, 10), '[2/3 ]1/1 -> \\times 2/3 ')
146 str = re
.sub ('\\\\\\[/3+', '\\\\times 2/3 { ',str)
147 str = re
.sub ('\\[/3+', '\\\\times 2/3 { [',str)
148 str = re
.sub ('\\\\\\[([0-9/]+)', '\\\\times \\1 {',str)
149 str = re
.sub ('\\[([0-9/]+)', '\\\\times \\1 { [',str)
150 str = re
.sub ('\\\\\\]([0-9/]+)', '}', str)
151 str = re
.sub ('\\\\\\]', '}',str)
152 str = re
.sub ('\\]([0-9/]+)', '] }', str)
156 @rule ((1, 0, 12), 'Chord syntax stuff')
161 @rule ((1, 0, 13), '<a ~ b> c -> <a b> ~ c')
163 str = re
.sub ('<([^>~]+)~([^>]*)>','<\\1 \\2> ~', str)
167 @rule ((1, 0, 14), '<[a b> <a b]>c -> [<a b> <a b>]')
169 str = re
.sub ('<\\[','[<', str)
170 str = re
.sub ('\\]>','>]', str)
174 @rule ((1, 0, 16), '\\type -> \\context, textstyle -> textStyle')
176 str = re
.sub ('\\\\type([^\n]*engraver)','\\\\TYPE\\1', str)
177 str = re
.sub ('\\\\type([^\n]*performer)','\\\\TYPE\\1', str)
178 str = re
.sub ('\\\\type','\\\\context', str)
179 str = re
.sub ('\\\\TYPE','\\\\type', str)
180 str = re
.sub ('textstyle','textStyle', str)
184 @rule ((1, 0, 18), _ ('\\repeat NUM Music Alternative -> \\repeat FOLDSTR Music Alternative'))
186 if re
.search ('\\\\repeat',str):
188 stderr_write (NOT_SMART
% "\\repeat")
190 # raise FatalConversionError ()
194 @rule ((1, 0, 19), 'fontsize -> fontSize, midi_instrument -> midiInstrument, SkipBars -> skipBars')
196 str = re
.sub ('SkipBars','skipBars', str)
197 str = re
.sub ('fontsize','fontSize', str)
198 str = re
.sub ('midi_instrument','midiInstrument', str)
202 @rule ((1, 0, 20), '{,tie,slur}ydirection -> {v,tieV,slurV}erticalDirection')
204 str = re
.sub ('tieydirection','tieVerticalDirection', str)
205 str = re
.sub ('slurydirection','slurVerticalDirection', str)
206 str = re
.sub ('ydirection','verticalDirection', str)
210 @rule ((1, 0, 21), 'hshift -> horizontalNoteShift')
212 str = re
.sub ('hshift','horizontalNoteShift', str)
216 @rule ((1, 1, 52), _ ('deprecate %s') % '\\grouping')
218 str = re
.sub ('\\\\grouping[^;]*;','', str)
222 @rule ((1, 1, 55), '\\wheel -> \\coda')
224 str = re
.sub ('\\\\wheel','\\\\coda', str)
228 @rule ((1, 1, 65), 'slurdash -> slurDash, keyoctaviation -> keyOctaviation')
230 str = re
.sub ('keyoctaviation','keyOctaviation', str)
231 str = re
.sub ('slurdash','slurDash', str)
235 @rule ((1, 1, 66), 'semi -> volta')
237 str = re
.sub ('\\\\repeat *\"?semi\"?','\\\\repeat "volta"', str)
241 @rule ((1, 1, 67), 'beamAuto -> noAutoBeaming')
243 str = re
.sub ('\"?beamAuto\"? *= *\"?0?\"?','noAutoBeaming = "1"', str)
247 @rule ((1, 2, 0), 'automaticMelismas -> automaticMelismata')
249 str = re
.sub ('automaticMelismas', 'automaticMelismata', str)
253 @rule ((1, 2, 1), 'dynamicDir -> dynamicDirection')
255 str = re
.sub ('dynamicDir\\b', 'dynamicDirection', str)
259 @rule ((1, 3, 4), '\\cadenza -> \\cadenza{On|Off}')
261 str = re
.sub ('\\\\cadenza *0 *;', '\\\\cadenzaOff', str)
262 str = re
.sub ('\\\\cadenza *1 *;', '\\\\cadenzaOn', str)
266 @rule ((1, 3, 5), 'beamAuto moment properties')
268 str = re
.sub ('"?beamAuto([^"=]+)"? *= *"([0-9]+)/([0-9]+)" *;*',
269 'beamAuto\\1 = #(make-moment \\2 \\3)',
274 @rule ((1, 3, 17), 'stemStyle -> flagStyle')
276 str = re
.sub ('stemStyle',
282 @rule ((1, 3, 18), 'staffLineLeading -> staffSpace')
284 str = re
.sub ('staffLineLeading',
290 @rule ((1, 3, 23), _ ('deprecate %s ') % '\\repetitions')
292 if re
.search ('\\\\repetitions',str):
294 stderr_write (NOT_SMART
% "\\repetitions")
296 # raise FatalConversionError ()
300 @rule ((1, 3, 35), 'textEmptyDimension -> textNonEmpty')
302 str = re
.sub ('textEmptyDimension *= *##t',
303 'textNonEmpty = ##f',
305 str = re
.sub ('textEmptyDimension *= *##f',
306 'textNonEmpty = ##t',
311 @rule ((1, 3, 38), '\musicalpitch { a b c } -> #\'(a b c)')
313 str = re
.sub ("([a-z]+)[ \t]*=[ \t]*\\\\musicalpitch *{([- 0-9]+)} *\n",
314 "(\\1 . (\\2))\n", str)
315 str = re
.sub ("\\\\musicalpitch *{([0-9 -]+)}",
316 "\\\\musicalpitch #'(\\1)", str)
317 if re
.search ('\\\\notenames',str):
319 stderr_write (NOT_SMART
% _ ("new \\notenames format"))
324 @rule ((1, 3, 39), '\\key A ; ->\\key a;')
327 return '\\key %s;' % match
.group (1).lower ()
329 str = re
.sub ("\\\\key ([^;]+);", replace
, str)
333 @rule ((1, 3, 41), '[:16 c4 d4 ] -> \\repeat "tremolo" 2 { c16 d16 }')
335 if re
.search ('\\[:',str):
337 stderr_write (NOT_SMART
% _ ("new tremolo format"))
342 @rule ((1, 3, 42), _ ('Staff_margin_engraver deprecated, use Instrument_name_engraver'))
344 str = re
.sub ('Staff_margin_engraver' , 'Instrument_name_engraver', str)
348 @rule ((1, 3, 49), 'noteHeadStyle value: string -> symbol')
350 str = re
.sub ('note[hH]eadStyle\\s*=\\s*"?(\\w+)"?' , "noteHeadStyle = #'\\1", str)
354 @rule ((1, 3, 58), 'noteHeadStyle value: string -> symbol')
356 if re
.search ('\\\\keysignature', str):
358 stderr_write (NOT_SMART
% '\\keysignature')
363 @rule ((1, 3, 59), '\key X ; -> \key X major; ')
365 str = re
.sub (r
"""\\key *([a-z]+) *;""", r
"""\\key \1 \major;""",str);
369 @rule ((1, 3, 68), 'latexheaders = "\\input global" -> latexheaders = "global"')
371 str = re
.sub (r
'latexheaders *= *"\\\\input ',
377 # TODO: lots of other syntax change should be done here as well
378 @rule ((1, 3, 92), 'basicXXXProperties -> XXX, Repeat_engraver -> Volta_engraver')
380 str = re
.sub ('basicCollisionProperties', 'NoteCollision', str)
381 str = re
.sub ('basicVoltaSpannerProperties' , "VoltaBracket", str)
382 str = re
.sub ('basicKeyProperties' , "KeySignature", str)
384 str = re
.sub ('basicClefItemProperties' ,"Clef", str)
387 str = re
.sub ('basicLocalKeyProperties' ,"Accidentals", str)
388 str = re
.sub ('basicMarkProperties' ,"Accidentals", str)
389 str = re
.sub ('basic([A-Za-z_]+)Properties', '\\1', str)
391 str = re
.sub ('Repeat_engraver' ,'Volta_engraver', str)
395 @rule ((1, 3, 93), _ ('change property definiton case (eg. onevoice -> oneVoice)'))
397 # Ugh, but meaning of \stemup changed too
398 # maybe we should do \stemup -> \stemUp\slurUp\tieUp ?
399 str = re
.sub ('\\\\stemup', '\\\\stemUp', str)
400 str = re
.sub ('\\\\stemdown', '\\\\stemDown', str)
401 str = re
.sub ('\\\\stemboth', '\\\\stemBoth', str)
403 str = re
.sub ('\\\\slurup', '\\\\slurUp', str)
404 str = re
.sub ('\\\\slurboth', '\\\\slurBoth', str)
405 str = re
.sub ('\\\\slurdown', '\\\\slurDown', str)
406 str = re
.sub ('\\\\slurdotted', '\\\\slurDotted', str)
407 str = re
.sub ('\\\\slurnormal', '\\\\slurNoDots', str)
409 str = re
.sub ('\\\\shiftoff', '\\\\shiftOff', str)
410 str = re
.sub ('\\\\shifton', '\\\\shiftOn', str)
411 str = re
.sub ('\\\\shiftonn', '\\\\shiftOnn', str)
412 str = re
.sub ('\\\\shiftonnn', '\\\\shiftOnnn', str)
414 str = re
.sub ('\\\\onevoice', '\\\\oneVoice', str)
415 str = re
.sub ('\\\\voiceone', '\\\\voiceOne', str)
416 str = re
.sub ('\\\\voicetwo', '\\\\voiceTwo', str)
417 str = re
.sub ('\\\\voicethree', '\\\\voiceThree', str)
418 str = re
.sub ('\\\\voicefour', '\\\\voiceFour', str)
420 # I don't know exactly when these happened...
421 # ugh, we loose context setting here...
422 str = re
.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\stemUp\\\\slurUp\\\\tieUp', str)
423 str = re
.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\stemDown\\\\slurDown\\\\tieDown', str)
424 str = re
.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\stemBoth\\\\slurBoth\\\\tieBoth', str)
426 str = re
.sub ('verticalDirection[^=]*= *#?"?(1|(\\\\up))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #1', str)
427 str = re
.sub ('verticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #-1', str)
428 str = re
.sub ('verticalDirection[^=]*= *#?"?(0|(\\\\center))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #0', str)
430 str = re
.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\\\1Up', str)
431 str = re
.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\\\1Down', str)
432 str = re
.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\\\1Both', str)
434 # (lacks capitalisation slur -> Slur)
435 str = re
.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\1 \\\\override #\'direction = #1', str)
436 str = re
.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\1 \\override #\'direction = #-1', str)
437 str = re
.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\1 \\\\override #\'direction = #0', str)
440 str = re
.sub ('\\\\property *[^ .]*[.]?dynamicDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\dynamicUp', str)
441 str = re
.sub ('\\\\property *[^ .]*[.]?dyn[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\dynamicDown', str)
442 str = re
.sub ('\\\\property *[^ .]*[.]?dyn[^=]*= *#?"?(0|(\\\\center))"?', '\\\\dynamicBoth', str)
444 str = re
.sub ('\\\\property *[^ .]*[.]?([a-z]+)Dash[^=]*= *#?"?(0|(""))"?', '\\\\\\1NoDots', str)
445 str = re
.sub ('\\\\property *[^ .]*[.]?([a-z]+)Dash[^=]*= *#?"?([1-9]+)"?', '\\\\\\1Dotted', str)
447 str = re
.sub ('\\\\property *[^ .]*[.]?noAutoBeaming[^=]*= *#?"?(0|(""))"?', '\\\\autoBeamOn', str)
448 str = re
.sub ('\\\\property *[^ .]*[.]?noAutoBeaming[^=]*= *#?"?([1-9]+)"?', '\\\\autoBeamOff', str)
452 @rule ((1, 3, 97), 'ChordName -> ChordNames')
454 str = re
.sub ('ChordNames*', 'ChordNames', str)
455 if re
.search ('\\\\textscript "[^"]* *"[^"]*"', str):
457 stderr_write (NOT_SMART
% _ ("new \\textscript markup text"))
460 str = re
.sub ('\\textscript +("[^"]*")', '\\textscript #\\1', str)
463 # TODO: add lots of these
465 @rule ((1, 3, 98), 'CONTEXT.textStyle -> GROB.#font-style ')
467 str = re
.sub ('\\\\property *"?Voice"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Voice.TextScript \\\\set #\'font-style = #\'\\1', str)
468 str = re
.sub ('\\\\property *"?Lyrics"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Lyrics.LyricText \\\\set #\'font-style = #\'\\1', str)
470 str = re
.sub ('\\\\property *"?([^.]+)"? *[.] *"?timeSignatureStyle"? *= *"([^"]*)"', '\\\\property \\1.TimeSignature \\\\override #\'style = #\'\\2', str)
472 str = re
.sub ('"?timeSignatureStyle"? *= *#?""', 'TimeSignature \\\\override #\'style = ##f', str)
474 str = re
.sub ('"?timeSignatureStyle"? *= *#?"([^"]*)"', 'TimeSignature \\\\override #\'style = #\'\\1', str)
476 str = re
.sub ('#\'style *= #*"([^"])"', '#\'style = #\'\\1', str)
478 str = re
.sub ('\\\\property *"?([^.]+)"? *[.] *"?horizontalNoteShift"? *= *"?#?([-0-9]+)"?', '\\\\property \\1.NoteColumn \\\\override #\'horizontal-shift = #\\2', str)
481 str = re
.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *""', '\\\\property \\1.Stem \\\\override #\'flag-style = ##f', str)
483 str = re
.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *"([^"]*)"', '\\\\property \\1.Stem \\\\override #\'flag-style = #\'\\2', str)
487 @rule ((1, 3, 102), 'beamAutoEnd -> autoBeamSettings \\push (end * * * *)')
489 str = re
.sub ('"?beamAutoEnd_([0-9]*)"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(end 1 \\1 * *) = \\2', str)
490 str = re
.sub ('"?beamAutoBegin_([0-9]*)"? *= *(#\\([^)]*\))', 'autoBeamSettings \\push #\'(begin 1 \\1 * *) = \\2', str)
491 str = re
.sub ('"?beamAutoEnd"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(end * * * *) = \\1', str)
492 str = re
.sub ('"?beamAutoBegin"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(begin * * * *) = \\1', str)
496 @rule ((1, 3, 111), '\\push -> \\override, \\pop -> \\revert')
498 str = re
.sub ('\\\\push', '\\\\override', str)
499 str = re
.sub ('\\\\pop', '\\\\revert', str)
503 @rule ((1, 3, 113), 'LyricVoice -> LyricsVoice')
505 str = re
.sub ('LyricVoice', 'LyricsVoice', str)
507 str = re
.sub ('Chord[Nn]ames*.Chord[Nn]ames*', 'ChordNames.ChordName', str)
508 str = re
.sub ('Chord[Nn]ames([ \t\n]+\\\\override)', 'ChordName\\1', str)
512 def regularize_id (str):
519 elif x
in string
.digits
:
520 x
= chr(ord (x
) - ord ('0') +ord ('A'))
521 elif x
not in string
.letters
:
523 elif x
in string
.lowercase
and lastx
== '_':
530 @rule ((1, 3, 117), _ ('identifier names: %s') % '$!foo_bar_123 -> xfooBarABC')
532 def regularize_dollar_reference (match
):
533 return regularize_id (match
.group (1))
534 def regularize_assignment (match
):
535 return '\n' + regularize_id (match
.group (1)) + ' = '
536 str = re
.sub ('\$([^\t\n ]+)', regularize_dollar_reference
, str)
537 str = re
.sub ('\n([^ \t\n]+)[ \t]*= *', regularize_assignment
, str)
541 @rule ((1, 3, 120), 'paper_xxx -> paperXxxx, pedalup -> pedalUp.')
543 def regularize_paper (match
):
544 return regularize_id (match
.group (1))
545 str = re
.sub ('(paper_[a-z]+)', regularize_paper
, str)
546 str = re
.sub ('sustainup', 'sustainUp', str)
547 str = re
.sub ('nobreak', 'noBreak', str)
548 str = re
.sub ('sustaindown', 'sustainDown', str)
549 str = re
.sub ('sostenutoup', 'sostenutoUp', str)
550 str = re
.sub ('sostenutodown', 'sostenutoDown', str)
551 str = re
.sub ('unachorda', 'unaChorda', str)
552 str = re
.sub ('trechorde', 'treChorde', str)
556 @rule ((1, 3, 122), 'drarnChords -> chordChanges, \\musicalpitch -> \\pitch')
558 str = re
.sub ('drarnChords', 'chordChanges', str)
559 str = re
.sub ('\\musicalpitch', '\\pitch', str)
563 @rule ((1, 3, 136), 'ly-X-elt-property -> ly-X-grob-property')
565 str = re
.sub ('ly-([sg])et-elt-property', 'ly-\\1et-grob-property', str)
569 @rule ((1, 3, 138), _ ('point-and-click argument changed to procedure.'))
571 str = re
.sub ('point-and-click +#t', 'point-and-click line-column-location', str)
575 @rule ((1, 3, 138), 'followThread -> followVoice.')
577 str = re
.sub ('followThread', 'followVoice', str)
578 str = re
.sub ('Thread.FollowThread', 'Voice.VoiceFollower', str)
579 str = re
.sub ('FollowThread', 'VoiceFollower', str)
583 @rule ((1, 3, 139), 'font-point-size -> font-design-size.')
585 str = re
.sub ('font-point-size', 'font-design-size', str)
589 @rule ((1, 3, 141), 'xNoDots -> xSolid')
591 str = re
.sub ('([a-zA-Z]*)NoDots', '\\1Solid', str)
595 @rule ((1, 3, 144), 'Chorda -> Corda')
597 str = re
.sub ('([Cc])hord([ea])', '\\1ord\\2', str)
601 @rule ((1, 3, 145), 'ContextNameXxxxVerticalExtent -> XxxxVerticalExtent')
603 str = re
.sub ('([A-Za-z]+)MinimumVerticalExtent', 'MinimumV@rticalExtent', str)
604 str = re
.sub ('([A-Za-z]+)ExtraVerticalExtent', 'ExtraV@rticalExtent', str)
605 str = re
.sub ('([A-Za-z]+)VerticalExtent', 'VerticalExtent', str)
606 str = re
.sub ('ExtraV@rticalExtent', 'ExtraVerticalExtent', str)
607 str = re
.sub ('MinimumV@rticalExtent', 'MinimumVerticalExtent', str)
611 @rule ((1, 3, 146), _('semicolons removed'))
613 str = re
.sub ('\\\\key[ \t]*;', '\\key \\default;', str)
614 str = re
.sub ('\\\\mark[ \t]*;', '\\mark \\default;', str)
616 # Make sure groups of more than one ; have space before
617 # them, so that non of them gets removed by next rule
618 str = re
.sub ("([^ \n\t;]);(;+)", "\\1 ;\\2", str)
620 # Only remove ; that are not after spaces, # or ;
621 # Otherwise we interfere with Scheme comments,
622 # which is badbadbad.
623 str = re
.sub ("([^ \t;#]);", "\\1", str)
627 @rule ((1, 3, 147), 'default-neutral-direction -> neutral-direction')
629 str = re
.sub ('default-neutral-direction', 'neutral-direction',str)
633 @rule ((1, 3, 148), '"(align" -> "(axis", "(rows" -> "(columns"')
635 str = re
.sub ('\(align', '(axis', str)
636 str = re
.sub ('\(rows', '(columns', str)
640 @rule ((1, 5, 33), 'SystemStartDelimiter -> systemStartDelimiter')
642 str = re
.sub ('SystemStartDelimiter', 'systemStartDelimiter', str)
646 @rule ((1, 5, 38), 'arithmetic... -> spacing...')
648 str = re
.sub ('arithmetic-multiplier', 'spacing-increment', str)
649 str = re
.sub ('arithmetic-basicspace', 'shortest-duration-space', str)
654 @rule ((1, 5, 40), _ ('%s property names') % 'breakAlignOrder')
659 "Instrument_name": "instrument-name",
660 "Left_edge_item": "left-edge",
661 "Span_bar": "span-bar",
662 "Breathing_sign": "breathing-sign",
663 "Staff_bar": "staff-bar",
665 "Key_item": "key-signature",
666 "Time_signature": "time-signature",
669 props
= match
.group (1)
670 for (k
,v
) in break_dict
.items():
671 props
= re
.sub (k
, v
, props
)
672 return "breakAlignOrder = #'(%s)" % props
674 str = re
.sub ("breakAlignOrder *= *#'\\(([a-z_\n\tA-Z ]+)\\)",
679 @rule ((1, 5, 49), 'noAutoBeaming -> autoBeaming')
681 str = re
.sub ('noAutoBeaming *= *##f', 'autoBeaming = ##t', str)
682 str = re
.sub ('noAutoBeaming *= *##t', 'autoBeaming = ##f', str)
686 @rule ((1, 5, 52), 'tuplet-X-visibility -> X-visibility')
688 str = re
.sub ('tuplet-bracket-visibility', 'bracket-visibility', str)
689 str = re
.sub ('tuplet-number-visibility', 'number-visibility', str)
693 @rule ((1, 5, 56), 'Pitch::transpose -> ly-transpose-pitch')
695 str = re
.sub ('Pitch::transpose', 'ly-transpose-pitch', str)
699 @rule ((1, 5, 58), _ ('deprecate %s') % 'textNonEmpty')
701 str = re
.sub ('textNonEmpty *= *##t', "TextScript \\set #'no-spacing-rods = ##f", str)
702 str = re
.sub ('textNonEmpty *= *##f', "TextScript \\set #'no-spacing-rods = ##t", str)
706 @rule ((1, 5, 59), 'XxxxVerticalExtent -> xxxVerticalExtent')
708 str = re
.sub ('MinimumVerticalExtent', 'minimumV@rticalExtent', str)
709 str = re
.sub ('minimumVerticalExtent', 'minimumV@rticalExtent', str)
710 str = re
.sub ('ExtraVerticalExtent', 'extraV@rticalExtent', str)
711 str = re
.sub ('extraVerticalExtent', 'extraV@rticalExtent', str)
712 str = re
.sub ('VerticalExtent', 'verticalExtent', str)
713 str = re
.sub ('extraV@rticalExtent', 'extraVerticalExtent', str)
714 str = re
.sub ('minimumV@rticalExtent', 'minimumVerticalExtent', str)
718 @rule ((1, 5, 62), 'visibility-lambda -> break-visibility')
720 str = re
.sub ('visibility-lambda', 'break-visibility', str)
724 @rule ((1, 5, 67), _ ('automaticMelismata turned on by default'))
726 if re
.search (r
'\addlyrics',str) \
727 and re
.search ('automaticMelismata', str) == None:
729 stderr_write (NOT_SMART
% "automaticMelismata; turned on by default since 1.5.67.")
731 raise FatalConversionError ()
735 @rule ((1, 5, 68), 'ly-set-X-property -> ly-set-X-property!')
737 str = re
.sub ('ly-set-grob-property([^!])', 'ly-set-grob-property!\1', str)
738 str = re
.sub ('ly-set-mus-property([^!])', 'ly-set-mus-property!\1', str)
742 @rule ((1, 5, 71), 'extent-[XY] -> [XY]-extent')
744 str = re
.sub ('extent-X', 'X-extent', str)
745 str = re
.sub ('extent-Y', 'Y-extent', str)
749 @rule ((1, 5, 72), 'set! point-and-click -> set-point-and-click!')
751 str = re
.sub ("""#\(set! +point-and-click +line-column-location\)""",
752 """#(set-point-and-click! \'line-column)""", str)
753 str = re
.sub ("""#\(set![ \t]+point-and-click +line-location\)""",
754 '#(set-point-and-click! \'line)', str)
755 str = re
.sub ('#\(set! +point-and-click +#f\)',
756 '#(set-point-and-click! \'none)', str)
760 @rule ((1, 6, 5), 'Stems: flag-style -> stroke-style; style -> flag-style')
762 str = re
.sub ('flag-style', 'stroke-style', str)
763 str = re
.sub (r
"""Stem([ ]+)\\override #'style""", r
"""Stem \\override #'flag-style""", str);
764 str = re
.sub (r
"""Stem([ ]+)\\set([ ]+)#'style""", r
"""Stem \\set #'flag-style""", str);
768 def subst_req_name (match
):
769 return "(make-music-by-name \'%sEvent)" % regularize_id (match
.group(1))
772 @rule ((1, 7, 1), 'ly-make-music foo_bar_req -> make-music-by-name FooBarEvent')
774 str = re
.sub ('\\(ly-make-music *\"([A-Z][a-z_]+)_req\"\\)', subst_req_name
, str)
775 str = re
.sub ('Request_chord', 'EventChord', str)
780 "text" : 'TextSpanEvent',
781 "decrescendo" : 'DecrescendoEvent',
782 "crescendo" : 'CrescendoEvent',
783 "Sustain" : 'SustainPedalEvent',
784 "slur" : 'SlurEvent',
785 "UnaCorda" : 'UnaCordaEvent',
786 "Sostenuto" : 'SostenutoEvent',
789 def subst_ev_name (match
):
791 if re
.search ('start', match
.group(1)):
793 mtype
= spanner_subst
[match
.group(2)]
794 return "(make-span-event '%s %s)" % (mtype
, stype
)
796 def subst_definition_ev_name(match
):
797 return ' = #%s' % subst_ev_name (match
)
799 def subst_inline_ev_name (match
):
800 s
= subst_ev_name (match
)
801 return '#(ly-export %s)' % s
803 def subst_csp_definition (match
):
804 return ' = #(make-event-chord (list %s))' % subst_ev_name (match
)
806 def subst_csp_inline (match
):
807 return '#(ly-export (make-event-chord (list %s)))' % subst_ev_name (match
)
810 @rule ((1, 7, 2), '\\spanrequest -> #(make-span-event .. ), \script -> #(make-articulation .. )')
812 str = re
.sub (r
' *= *\\spanrequest *([^ ]+) *"([^"]+)"', subst_definition_ev_name
, str)
813 str = re
.sub (r
'\\spanrequest *([^ ]+) *"([^"]+)"', subst_inline_ev_name
, str)
814 str = re
.sub (r
' *= *\\commandspanrequest *([^ ]+) *"([^"]+)"', subst_csp_definition
, str)
815 str = re
.sub (r
'\\commandspanrequest *([^ ]+) *"([^"]+)"', subst_csp_inline
, str)
816 str = re
.sub (r
'ly-id ', 'ly-import ', str)
818 str = re
.sub (r
' *= *\\script "([^"]+)"', ' = #(make-articulation "\\1")', str)
819 str = re
.sub (r
'\\script "([^"]+)"', '#(ly-export (make-articulation "\\1"))', str)
823 @rule ((1, 7, 3), 'ly- -> ly:')
825 str = re
.sub (r
'\(ly-', '(ly:', str)
835 'music-duration-length',
840 'transpose-key-alist',
844 'set-point-and-click!',
853 'music-duration-compress',
854 'set-point-and-click!'
857 origre
= r
'\b(%s)' % '|'.join (changed
)
859 str = re
.sub (origre
, r
'ly:\1',str)
860 str = re
.sub ('set-point-and-click!', 'set-point-and-click', str)
864 @rule ((1, 7, 4), '<< >> -> < < > >')
866 if re
.search ('new-chords-done',str):
869 str = re
.sub (r
'<<', '< <', str)
870 str = re
.sub (r
'>>', '> >', str)
874 @rule ((1, 7, 5), '\\transpose TO -> \\transpose FROM TO')
876 str = re
.sub (r
"\\transpose", r
"\\transpose c'", str)
877 str = re
.sub (r
"\\transpose c' *([a-z]+)'", r
"\\transpose c \1", str)
881 @rule ((1, 7, 6), 'note\\script -> note-\script')
897 origstr
= '|'.join (kws
)
898 str = re
.sub (r
'([^_^-])\\(%s)\b' % origstr
, r
'\1-\\\2', str)
902 @rule ((1, 7, 10), "\property ChordName #'style -> #(set-chord-name-style 'style)")
904 str = re
.sub (r
"\\property *ChordNames *\. *ChordName *\\(set|override) *#'style *= *#('[a-z]+)",
905 r
"#(set-chord-name-style \2)", str)
906 str = re
.sub (r
"\\property *ChordNames *\. *ChordName *\\revert *#'style",
911 @rule ((1, 7, 11), "transpose-pitch -> pitch-transpose")
913 str = re
.sub (r
"ly:transpose-pitch", "ly:pitch-transpose", str)
917 @rule ((1, 7, 13), "ly:XX-molecule-YY -> ly:molecule-XX-YY")
919 str = re
.sub (r
"ly:get-molecule-extent", "ly:molecule-get-extent", str)
920 str = re
.sub (r
"ly:set-molecule-extent!", "ly:molecule-set-extent!", str)
921 str = re
.sub (r
"ly:add-molecule", "ly:molecule-add", str)
922 str = re
.sub (r
"ly:combine-molecule-at-edge", "ly:molecule-combine-at-edge", str)
923 str = re
.sub (r
"ly:align-to!", "ly:molecule-align-to!", str)
927 @rule ((1, 7, 15), "linewidth = -1 -> raggedright = ##t")
929 str = re
.sub (r
"linewidth *= *-[0-9.]+ *(\\mm|\\cm|\\in|\\pt)?", 'raggedright = ##t', str )
933 @rule ((1, 7, 16), "divisiomaior -> divisioMaior")
935 str = re
.sub ("divisiomaior",
937 str = re
.sub ("divisiominima",
938 "divisioMinima", str)
939 str = re
.sub ("divisiomaxima",
940 "divisioMaxima", str)
944 @rule ((1, 7, 17), "Skip_req -> Skip_event")
946 str = re
.sub ("Skip_req_swallow_translator",
947 "Skip_event_swallow_translator", str)
951 @rule ((1, 7, 18), "groupOpen/Close -> start/stopGroup, #'outer -> #'enclose-bounds")
953 str = re
.sub ("groupOpen",
955 str = re
.sub ("groupClose",
957 str = re
.sub ("#'outer",
958 "#'enclose-bounds", str)
963 @rule ((1, 7, 19), _ ("remove %s") % "GraceContext")
965 if re
.search( r
'\\GraceContext', str):
967 stderr_write (NOT_SMART
% "GraceContext")
968 stderr_write (FROM_TO \
969 % ("GraceContext", "#(add-to-grace-init .. )"))
971 stderr_write (UPDATE_MANUALLY
)
973 raise FatalConversionError ()
975 str = re
.sub ('HaraKiriStaffContext', 'RemoveEmptyStaffContext', str)
979 @rule ((1, 7, 22), "#'type -> #'style")
982 r
"(set|override|revert) *#'type",
988 @rule ((1, 7, 23), "barNonAuto -> automaticBars")
991 "barNonAuto *= *##t",
992 "automaticBars = ##f",
995 "barNonAuto *= *##f",
996 "automaticBars = ##t",
1001 @rule ((1, 7, 24), _ ("cluster syntax"))
1003 if re
.search( r
'-(start|stop)Cluster', str):
1005 stderr_write (NOT_SMART
% _ ("cluster syntax"))
1007 stderr_write (UPDATE_MANUALLY
)
1010 raise FatalConversionError ()
1014 @rule ((1, 7, 28), _ ("new Pedal style syntax"))
1016 str = re
.sub (r
"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\(override|set) *#'pedal-type *",
1017 r
"\property Staff.pedal\1Style ", str)
1018 str = re
.sub (r
"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\revert *#'pedal-type", '', str)
1025 origstr
= '<%s>' % str
1026 if re
.search (r
'\\\\', str):
1029 if re
.search (r
'\\property', str):
1032 if re
.match (r
'^\s*\)?\s*\\[a-zA-Z]+', str):
1036 def sub_durs (m
, durs
= durs
):
1037 durs
.append(m
.group(2))
1040 str = re
.sub (r
"([a-z]+[,'!? ]*)([0-9]+\.*)", sub_durs
, str)
1047 return '<%s>' % m
.group (1)
1054 while last_str
<> str:
1057 def sub_tremolos (m
, slur_strs
= slur_strs
):
1059 if tr
not in slur_strs
:
1060 slur_strs
.append (tr
)
1063 str = re
.sub (r
"([a-z]+[',!? ]*)(:[0-9]+)",
1066 def sub_dyn_end (m
, dyns
= dyns
):
1068 return ' ' + m
.group(2)
1070 str = re
.sub (r
'(\\!)\s*([a-z]+)', sub_dyn_end
, str)
1071 def sub_slurs(m
, slur_strs
= slur_strs
):
1072 if '-)' not in slur_strs
:
1073 slur_strs
.append (')')
1076 def sub_p_slurs(m
, slur_strs
= slur_strs
):
1077 if '-\)' not in slur_strs
:
1078 slur_strs
.append ('\)')
1081 str = re
.sub (r
"\)[ ]*([a-z]+)", sub_slurs
, str)
1082 str = re
.sub (r
"\\\)[ ]*([a-z]+)", sub_p_slurs
, str)
1083 def sub_begin_slurs(m
, slur_strs
= slur_strs
):
1084 if '-(' not in slur_strs
:
1085 slur_strs
.append ('(')
1088 str = re
.sub (r
"([a-z]+[,'!?0-9 ]*)\(",
1089 sub_begin_slurs
, str)
1090 def sub_begin_p_slurs(m
, slur_strs
= slur_strs
):
1091 if '-\(' not in slur_strs
:
1092 slur_strs
.append ('\(')
1095 str = re
.sub (r
"([a-z]+[,'!?0-9 ]*)\\\(",
1096 sub_begin_p_slurs
, str)
1098 def sub_dyns (m
, slur_strs
= slur_strs
):
1100 if s
== '@STARTCRESC@':
1101 slur_strs
.append ("\\<")
1102 elif s
== '@STARTDECRESC@':
1103 slur_strs
.append ("\\>")
1105 slur_strs
.append ('\\!')
1108 str = re
.sub (r
'@STARTCRESC@', sub_dyns
, str)
1109 str = re
.sub (r
'-?\\!', sub_dyns
, str)
1111 def sub_articulations (m
, slur_strs
= slur_strs
):
1113 if a
not in slur_strs
:
1114 slur_strs
.append (a
)
1117 str = re
.sub (r
"([_^-]\@ACCENT\@)", sub_articulations
,
1119 str = re
.sub (r
"([_^-]\\[a-z]+)", sub_articulations
,
1121 str = re
.sub (r
"([_^-][>_.+|^-])", sub_articulations
,
1123 str = re
.sub (r
'([_^-]"[^"]+")', sub_articulations
,
1126 def sub_pslurs(m
, slur_strs
= slur_strs
):
1127 slur_strs
.append (' \\)')
1129 str = re
.sub (r
"\\\)[ ]*([a-z]+)", sub_pslurs
, str)
1133 suffix
= ''.join (slur_strs
) + ''.join (pslur_strs
) \
1136 return '@STARTCHORD@%s@ENDCHORD@%s%s' % (str , dur_str
, suffix
)
1140 def sub_chords (str):
1145 marker_str
= '%% new-chords-done %%'
1147 if re
.search (marker_str
,str):
1149 str = re
.sub ('<<', '@STARTCHORD@', str)
1150 str = re
.sub ('>>', '@ENDCHORD@', str)
1152 str = re
.sub (r
'\\<', '@STARTCRESC@', str)
1153 str = re
.sub (r
'\\>', '@STARTDECRESC@', str)
1154 str = re
.sub (r
'([_^-])>', r
'\1@ACCENT@', str)
1155 str = re
.sub (r
'<([^<>{}]+)>', sub_chord
, str)
1157 # add dash: -[, so that [<<a b>> c d] becomes
1159 # and gets skipped by articulation_substitute
1160 str = re
.sub (r
'\[ *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)',
1162 str = re
.sub (r
'\\! *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)',
1165 str = re
.sub (r
'<([^?])', r
'%s\1' % simstart
, str)
1166 str = re
.sub (r
'>([^?])', r
'%s\1' % simend
, str)
1167 str = re
.sub ('@STARTCRESC@', r
'\\<', str)
1168 str = re
.sub ('@STARTDECRESC@', r
'\\>' ,str)
1169 str = re
.sub (r
'\\context *Voice *@STARTCHORD@',
1170 '@STARTCHORD@', str)
1171 str = re
.sub ('@STARTCHORD@', chordstart
, str)
1172 str = re
.sub ('@ENDCHORD@', chordend
, str)
1173 str = re
.sub (r
'@ACCENT@', '>', str)
1176 markup_start
= re
.compile(r
"([-^_]|\\mark)\s*(#\s*'\s*)\(")
1177 musicglyph
= re
.compile(r
"\(\s*music\b")
1178 columns
= re
.compile(r
"\(\s*columns\b")
1179 submarkup_start
= re
.compile(r
"\(\s*([a-zA-Z]+)")
1180 leftpar
= re
.compile(r
"\(")
1181 rightpar
= re
.compile(r
"\)")
1183 def text_markup (str):
1185 # Find the beginning of each markup:
1186 match
= markup_start
.search (str)
1188 result
= result
+ str[:match
.end (1)] + " \markup"
1189 str = str[match
.end( 2):]
1190 # Count matching parentheses to find the end of the
1193 pars
= re
.finditer(r
"[()]",str)
1195 if par
.group () == '(':
1196 nesting_level
= nesting_level
+ 1
1198 nesting_level
= nesting_level
- 1
1199 if nesting_level
== 0:
1200 markup_end
= par
.end ()
1202 # The full markup in old syntax:
1203 markup
= str[:markup_end
]
1204 # Modify to new syntax:
1205 markup
= musicglyph
.sub (r
"{\\musicglyph", markup
)
1206 markup
= columns
.sub (r
"{", markup
)
1207 markup
= submarkup_start
.sub (r
"{\\\1", markup
)
1208 markup
= leftpar
.sub ("{", markup
)
1209 markup
= rightpar
.sub ("}", markup
)
1211 result
= result
+ markup
1213 str = str[markup_end
:]
1214 match
= markup_start
.search(str)
1215 result
= result
+ str
1218 def articulation_substitute (str):
1219 str = re
.sub (r
"""([^-])\[ *(\\?\)?[a-z]+[,']*[!?]?[0-9:]*\.*)""",
1221 str = re
.sub (r
"""([^-])\\\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
1223 str = re
.sub (r
"""([^-\\])\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
1225 str = re
.sub (r
"""([^-])\\! *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
1229 string_or_scheme
= re
.compile ('("(?:[^"\\\\]|\\\\.)*")|(#\\s*\'?\\s*\\()')
1231 # Only apply articulation_substitute () outside strings and
1232 # Scheme expressions:
1233 def smarter_articulation_subst (str):
1235 # Find the beginning of next string or Scheme expr.:
1236 match
= string_or_scheme
.search (str)
1238 # Convert the preceding LilyPond code:
1239 previous_chunk
= str[:match
.start()]
1240 result
= result
+ articulation_substitute (previous_chunk
)
1241 if match
.group (1): # Found a string
1242 # Copy the string to output:
1243 result
= result
+ match
.group (1)
1244 str = str[match
.end(1):]
1245 else: # Found a Scheme expression. Count
1246 # matching parentheses to find its end
1247 str = str[match
.start ():]
1249 pars
= re
.finditer(r
"[()]",str)
1251 if par
.group () == '(':
1252 nesting_level
= nesting_level
+ 1
1254 nesting_level
= nesting_level
- 1
1255 if nesting_level
== 0:
1256 scheme_end
= par
.end ()
1258 # Copy the Scheme expression to output:
1259 result
= result
+ str[:scheme_end
]
1260 str = str[scheme_end
:]
1261 # Find next string or Scheme expression:
1262 match
= string_or_scheme
.search (str)
1263 # Convert the remainder of the file
1264 result
= result
+ articulation_substitute (str)
1267 def conv_relative(str):
1268 if re
.search (r
"\\relative", str):
1269 str= "#(ly:set-option 'old-relative)\n" + str
1273 @rule ((1, 9, 0), _ ("""New relative mode,
1274 Postfix articulations, new text markup syntax, new chord syntax."""))
1276 str = re
.sub (r
"#'\(\)", "@SCM_EOL@", str)
1277 str = conv_relative (str)
1278 str = sub_chords (str)
1280 str = text_markup (str)
1281 str = smarter_articulation_subst (str)
1282 str = re
.sub ("@SCM_EOL@", "#'()", str)
1286 @rule ((1, 9, 1), _ ("Remove - before articulation"))
1288 if re
.search ("font-style",str):
1290 stderr_write (NOT_SMART
% "font-style")
1292 stderr_write (UPDATE_MANUALLY
)
1295 raise FatalConversionError ()
1297 str = re
.sub (r
'-\\markup', r
'@\\markup', str)
1298 str = re
.sub (r
'-\\', r
'\\', str)
1299 str = re
.sub (r
'-\)', ')', str)
1300 str = re
.sub (r
'-\(', '(', str)
1301 str = re
.sub ('-\[', '[', str)
1302 str = re
.sub ('-\]', ']', str)
1303 str = re
.sub ('-~', '~', str)
1304 str = re
.sub (r
'@\\markup', r
'-\\markup', str)
1308 @rule ((1, 9, 2), "\\newcontext -> \\new")
1310 str = re
.sub ('ly:set-context-property',
1311 'ly:set-context-property!', str)
1312 str = re
.sub ('\\\\newcontext', '\\\\new', str)
1313 str = re
.sub ('\\\\grace[\t\n ]*([^{ ]+)',
1314 r
'\\grace { \1 }', str)
1315 str = re
.sub ("\\\\grace[\t\n ]*{([^}]+)}",
1317 \\property Voice.Stem \\override #'stroke-style = #"grace"
1319 \\property Voice.Stem \\revert #'stroke-style }
1324 @rule ((1, 9, 3), (_ ("%s misspelling") % "\\acciaccatura") +
1325 ", fingerHorizontalDirection -> fingeringOrientations")
1327 str = re
.sub ('accacciatura',
1328 'acciaccatura', str)
1330 if re
.search ("context-spec-music", str):
1332 stderr_write (NOT_SMART
% "context-spec-music")
1334 stderr_write (UPDATE_MANUALLY
)
1337 raise FatalConversionError ()
1339 str = re
.sub ('fingerHorizontalDirection *= *#(LEFT|-1)',
1340 "fingeringOrientations = #'(up down left)", str)
1341 str = re
.sub ('fingerHorizontalDirection *= *#(RIGHT|1)',
1342 "fingeringOrientations = #'(up down right)", str)
1346 @rule ((1, 9, 4), _ ('Swap < > and << >>'))
1348 if re
.search ('\\figures', str):
1349 warning (_ ("attempting automatic \\figures conversion. Check results!"));
1351 def figures_replace (m
):
1353 s
= re
.sub ('<', '@FIGOPEN@',s
)
1354 s
= re
.sub ('>', '@FIGCLOSE@',s
)
1355 return '\\figures { %s }' % s
1357 str = re
.sub (r
'\\figures[ \t\n]*{([^}]+)}', figures_replace
, str)
1358 str = re
.sub (r
'\\<', '@STARTCRESC@', str)
1359 str = re
.sub (r
'\\>', '@STARTDECRESC@', str)
1360 str = re
.sub (r
'([-^_])>', r
'\1@ACCENT@', str)
1361 str = re
.sub (r
'<<', '@STARTCHORD@', str)
1362 str = re
.sub (r
'>>', '@ENDCHORD@', str)
1363 str = re
.sub (r
'>', '@ENDSIMUL@', str)
1364 str = re
.sub (r
'<', '@STARTSIMUL@', str)
1365 str = re
.sub ('@STARTDECRESC@', '\\>', str)
1366 str = re
.sub ('@STARTCRESC@', '\\<', str)
1367 str = re
.sub ('@ACCENT@', '>', str)
1368 str = re
.sub ('@ENDCHORD@', '>', str)
1369 str = re
.sub ('@STARTCHORD@', '<', str)
1370 str = re
.sub ('@STARTSIMUL@', '<<', str)
1371 str = re
.sub ('@ENDSIMUL@', '>>', str)
1372 str = re
.sub ('@FIGOPEN@', '<', str)
1373 str = re
.sub ('@FIGCLOSE@', '>', str)
1377 @rule ((1, 9, 5), 'HaraKiriVerticalGroup -> RemoveEmptyVerticalGroup')
1379 str = re
.sub ('HaraKiriVerticalGroup', 'RemoveEmptyVerticalGroup', str)
1383 @rule ((1, 9, 6), _ ('deprecate %s') % 'ly:get-font')
1385 if re
.search ("ly:get-font", str) :
1387 stderr_write (NOT_SMART
% "(ly:-get-font")
1389 stderr_write (FROM_TO \
1390 % ("(ly:paper-get-font (ly:grob-get-paper foo) .. )",
1391 "(ly:paper-get-font (ly:grob-get-paper foo) .. )"))
1392 stderr_write (UPDATE_MANUALLY
)
1394 raise FatalConversionError ()
1396 if re
.search ("\\pitch *#", str) :
1398 stderr_write (NOT_SMART
% "\\pitch")
1400 stderr_write (_ ("Use Scheme code to construct arbitrary note events."))
1403 raise FatalConversionError ()
1407 @rule ((1, 9, 7), _ ('''use symbolic constants for alterations,
1408 remove \\outputproperty, move ly:verbose into ly:get-option'''))
1410 def sub_alteration (m
):
1414 '-2': 'DOUBLE-FLAT',
1417 '2': 'DOUBLE-SHARP',
1420 return '(ly:make-pitch %s %s %s)' % (m
.group(1), m
.group (2),
1423 str =re
.sub ("\\(ly:make-pitch *([0-9-]+) *([0-9-]+) *([0-9-]+) *\\)",
1424 sub_alteration
, str)
1427 str = re
.sub ("ly:verbose", "ly:get-option 'verbose", str)
1429 m
= re
.search ("\\\\outputproperty #([^#]+)[\t\n ]*#'([^ ]+)", str)
1432 r
"""\outputproperty found,
1433 Please hand-edit, using
1435 \applyoutput #(outputproperty-compatibility %s '%s <GROB PROPERTY VALUE>)
1437 as a substitution text.""") % (m
.group (1), m
.group (2)) )
1438 raise FatalConversionError ()
1440 if re
.search ("ly:(make-pitch|pitch-alteration)", str) \
1441 or re
.search ("keySignature", str):
1443 stderr_write (NOT_SMART
% "pitches")
1446 _ ("""The alteration field of Scheme pitches was multiplied by 2
1447 to support quarter tone accidentals. You must update the following constructs manually:
1449 * calls of ly:make-pitch and ly:pitch-alteration
1450 * keySignature settings made with \property
1452 raise FatalConversionError ()
1456 @rule ((1, 9, 8), "dash-length -> dash-fraction")
1458 if re
.search ("dash-length",str):
1460 stderr_write (NOT_SMART
% "dash-length")
1462 stderr_write (FROM_TO
% ("dash-length", "dash-fraction"))
1464 stderr_write (UPDATE_MANUALLY
)
1466 raise FatalConversionError ()
1470 @rule ((2, 1, 1), "font-relative-size -> font-size")
1473 return "#'font-size = #%d" % (2*int (match
.group (1)))
1475 str =re
.sub (r
"#'font-relative-size\s*=\s*#\+?([0-9-]+)", func
, str)
1476 str =re
.sub (r
"#'font-family\s*=\s*#'ancient",
1477 r
"#'font-family = #'music", str)
1481 @rule ((2, 1, 2), "ly:get-music-length -> ly:music-length")
1483 str =re
.sub (r
"ly:get-music-length", "ly:music-length", str)
1487 @rule ((2, 1, 3), "stanza -> instrument")
1489 str =re
.sub (r
"\.\s+stz=", ". instr ", str)
1493 @rule ((2, 1, 4), _ ("removal of automaticMelismata; use melismaBusyProperties instead."))
1503 return r
" \property %s.melismaBusyProperties \unset" % c
1505 return r
"\property %s.melismaBusyProperties = #'(melismaBusy)" % c
1507 str = re
.sub (r
"\\property ([a-zA-Z]+)\s*\.\s*automaticMelismata\s*=\s*##([ft])", func
, str)
1511 @rule ((2, 1, 7), "\\translator Staff -> \\change Staff")
1513 str =re
.sub (r
"\\translator\s+([a-zA-Z]+)", r
"\\change \1", str)
1517 @rule ((2, 1, 10), "\\newaddlyrics -> \\lyricsto")
1519 str =re
.sub (r
"\\newaddlyrics", r
"\\lyricsto", str)
1523 @rule ((2, 1, 11), """\\include "paper16.ly" -> #(set-staff-size 16)
1524 \\note #3 #1 #1 -> \\note #"8." #1
1527 str = re
.sub (r
'\\include\s*"paper([0-9]+)(-init)?.ly"',
1528 r
"#(set-staff-size \1)", str)
1530 def sub_note (match
):
1532 log
= int (match
.group (1))
1533 dots
= int (match
.group (2))
1536 dur
= '%d' % (1 << log
)
1538 dur
= { -1 : 'breve',
1544 return r
'\note #"%s" #%s' % (dur
, match
.group (3))
1546 str = re
.sub (r
'\\note\s+#([0-9-]+)\s+#([0-9]+)\s+#([0-9.-]+)',
1551 @rule ((2, 1, 12), "OttavaSpanner -> OttavaBracket")
1553 str = re
.sub (r
"OttavaSpanner", r
"OttavaBracket", str)
1557 @rule ((2, 1, 13), "set-staff-size -> set-global-staff-size")
1559 str = re
.sub (r
"\(set-staff-size ", r
"(set-global-staff-size ", str)
1563 @rule ((2, 1, 14), "style = dotted -> dash-fraction = 0")
1565 str = re
.sub (r
"#'style\s*=\s*#'dotted-line",
1566 r
"#'dash-fraction = #0.0 ", str)
1570 @rule ((2, 1, 15), "LyricsVoice . instr(ument) -> vocalName")
1572 str = re
.sub (r
'LyricsVoice\s*\.\s*instrument\s*=\s*("[^"]*")',
1573 r
'LyricsVoice . vocalName = \1', str)
1575 str = re
.sub (r
'LyricsVoice\s*\.\s*instr\s*=\s*("[^"]*")',
1576 r
'LyricsVoice . vocNam = \1', str)
1580 @rule ((2, 1, 16), '\\musicglyph #"accidentals-NUM" -> \\sharp/flat/etc.')
1593 return '\\%s' % d
[m
.group (1)]
1595 str = re
.sub (r
'\\musicglyph\s*#"accidentals-([0-9-]+)"',
1600 @rule ((2, 1, 17), _ ("\\partcombine syntax change to \\newpartcombine"))
1603 if re
.search (r
'\\partcombine', str):
1605 stderr_write (NOT_SMART
% "\\partcombine")
1607 stderr_write (UPDATE_MANUALLY
)
1609 raise FatalConversionError ()
1611 # this rule doesn't really work,
1612 # too lazy to figure out why.
1613 str = re
.sub (r
'\\context\s+Voice\s*=\s*one\s*\\partcombine\s+Voice\s*\\context\s+Thread\s*=\s*one(.*)\s*'
1614 + r
'\\context\s+Thread\s*=\s*two',
1615 '\\\\newpartcombine\n\\1\n', str)
1619 @rule ((2, 1, 18), """\\newpartcombine -> \\partcombine,
1620 \\autochange Staff -> \\autochange
1623 str = re
.sub (r
'\\newpartcombine', r
'\\partcombine', str)
1624 str = re
.sub (r
'\\autochange\s+Staff', r
'\\autochange ', str)
1628 @rule ((2, 1, 19), _ ("""Drum notation changes, Removing \\chordmodifiers, \\notenames.
1629 Harmonic notes. Thread context removed. Lyrics context removed."""))
1631 if re
.search ('include "drumpitch', str):
1632 stderr_write (_ ("Drums found. Enclose drum notes in \\drummode"))
1634 str = re
.sub (r
'\\include "drumpitch-init.ly"','', str)
1636 str = re
.sub (r
'\\pitchnames ','pitchnames = ', str)
1637 str = re
.sub (r
'\\chordmodifiers ','chordmodifiers = ', str)
1638 str = re
.sub (r
'\bdrums\b\s*=','drumContents = ', str)
1639 str = re
.sub (r
'\\drums\b','\\drumContents ', str)
1642 if re
.search ('drums->paper', str):
1643 stderr_write (_ ("\n%s found. Check file manually!\n") % _("Drum notation"))
1645 str = re
.sub (r
"""\\apply\s+#\(drums->paper\s+'([a-z]+)\)""",
1646 r
"""\property DrumStaff.drumStyleTable = #\1-style""",
1649 if re
.search ('Thread', str):
1650 stderr_write (_ ("\n%s found. Check file manually!\n") % "Thread");
1652 str = re
.sub (r
"""(\\once\s*)?\\property\s+Thread\s*\.\s*NoteHead\s*"""
1653 + r
"""\\(set|override)\s*#'style\s*=\s*#'harmonic"""
1654 + r
"""\s+([a-z]+[,'=]*)([0-9]*\.*)"""
1655 ,r
"""<\3\\harmonic>\4""", str)
1657 str = re
.sub (r
"""\\new Thread""", """\context Voice""", str)
1658 str = re
.sub (r
"""Thread""", """Voice""", str)
1660 if re
.search ('\bLyrics\b', str):
1661 stderr_write (_ ("\n%s found. Check file manually!\n") % "Lyrics");
1663 str = re
.sub (r
"""LyricsVoice""", r
"""L@ricsVoice""", str)
1664 str = re
.sub (r
"""\bLyrics\b""", r
"""LyricsVoice""", str)
1665 str = re
.sub (r
"""LyricsContext""", r
"""LyricsVoiceContext""", str)
1666 str = re
.sub (r
"""L@ricsVoice""", r
"""LyricsVoice""",str)
1670 @rule ((2, 1, 20), "nonevent-skip -> skip-music")
1672 str = re
.sub (r
'nonevent-skip', 'skip-music', str)
1676 @rule ((2, 1, 21), """molecule-callback -> print-function,
1677 brew_molecule -> print
1678 brew-new-markup-molecule -> Text_item::print
1679 LyricsVoice -> Lyrics
1680 tupletInvisible -> TupletBracket \set #'transparent
1682 """ % (_ ("remove %s") % "Grob::preset_extent"))
1684 str = re
.sub (r
'molecule-callback', 'print-function', str)
1685 str = re
.sub (r
'brew_molecule', 'print', str)
1686 str = re
.sub (r
'brew-new-markup-molecule', 'Text_item::print', str)
1687 str = re
.sub (r
'LyricsVoice', 'Lyrics', str)
1688 str = re
.sub (r
'tupletInvisible',
1689 r
"TupletBracket \\set #'transparent", str)
1690 # str = re.sub (r'molecule', 'collage', str)
1691 #molecule -> collage
1692 str = re
.sub (r
"\\property\s+[a-zA-Z]+\s*\.\s*[a-zA-Z]+\s*"
1693 + r
"\\set\s*#'X-extent-callback\s*=\s*#Grob::preset_extent",
1698 @rule ((2, 1, 22), """%s
1699 \\set A.B = #C , \\unset A.B
1700 \\override A.B #C = #D, \\revert A.B #C
1702 """ % _ ("new syntax for property settings:"))
1704 str = re
.sub (r
'(\\property[^=]+)=\s*([-0-9]+)',
1706 str = re
.sub (r
'\\property\s+([^. ]+)\s*\.\s*([^\\=]+)\s*\\(set|override)',
1707 r
"\\overrid@ \1.\2 ", str)
1708 str = re
.sub (r
'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*=\s*',
1709 r
'\\s@t \1.\2 = ', str)
1710 str = re
.sub (r
'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*\\unset',
1711 r
'\\uns@t \1.\2 ', str)
1712 str = re
.sub (r
'\\property\s+([^. ]+)\s*\.\s*([^\\= ]+)\s*\\revert'
1713 + r
"\s*#'([-a-z0-9_]+)",
1714 r
"\\rev@rt \1.\2 #'\3", str)
1715 str = re
.sub (r
'Voice\.', '', str)
1716 str = re
.sub (r
'Lyrics\.', '', str)
1717 str = re
.sub (r
'ChordNames\.', '', str)
1719 str = re
.sub ('rev@rt', 'revert',str)
1720 str = re
.sub ('s@t', 'set',str)
1721 str = re
.sub ('overrid@', 'override',str)
1723 str = re
.sub ('molecule', 'stencil', str)
1724 str = re
.sub ('Molecule', 'Stencil', str)
1728 @rule ((2, 1, 23), _ ("Property setting syntax in \\translator{ }"))
1730 def subst_in_trans (match
):
1732 s
= re
.sub (r
'\s([a-zA-Z]+)\s*\\override',
1733 r
' \\override \1', s
)
1734 s
= re
.sub (r
'\s([a-zA-Z]+)\s*\\set',
1735 r
' \\override \1', s
)
1736 s
= re
.sub (r
'\s([a-zA-Z]+)\s*\\revert',
1739 str = re
.sub (r
'\\(translator|with)\s*{[^}]+}', subst_in_trans
, str)
1743 context
= m
.group ('context')
1746 context
= " '%s" % context
[:-1] # -1: remove .
1750 d
['context'] = context
1752 return r
"""#(override-auto-beam-setting %(prop)s %(num)s %(den)s%(context)s)""" % d
1754 str = re
.sub (r
"""\\override\s*(?P<context>[a-zA-Z]+\s*\.\s*)?autoBeamSettings"""
1755 +r
"""\s*#(?P<prop>[^=]+)\s*=\s*#\(ly:make-moment\s+(?P<num>\d+)\s+(?P<den>\d)\s*\)""",
1760 @rule ((2, 1, 24), "music-list? -> ly:music-list?")
1762 str = re
.sub (r
'music-list\?', 'ly:music-list?', str)
1763 str = re
.sub (r
'\|\s*~', '~ |', str)
1767 @rule ((2, 1, 25), _ ("Scheme grob function renaming"))
1769 str = re
.sub (r
'ly:get-spanner-bound', 'ly:spanner-get-bound', str)
1770 str = re
.sub (r
'ly:get-extent', 'ly:grob-extent', str)
1771 str = re
.sub (r
'ly:get-system', 'ly:grob-system', str)
1772 str = re
.sub (r
'ly:get-original', 'ly:grob-original', str)
1773 str = re
.sub (r
'ly:get-parent', 'ly:grob-parent', str)
1774 str = re
.sub (r
'ly:get-broken-into', 'ly:spanner-broken-into', str)
1775 str = re
.sub (r
'Melisma_engraver', 'Melisma_translator', str)
1776 if re
.search ("ly:get-paper-variable", str):
1778 stderr_write (NOT_SMART
% "ly:paper-get-variable")
1780 stderr_write (_ ('use %s') % '(ly:paper-lookup (ly:grob-paper ))')
1782 raise FatalConversionError ()
1784 str = re
.sub (r
'\\defaultAccidentals', "#(set-accidental-style 'default)", str)
1785 str = re
.sub (r
'\\voiceAccidentals', "#(set-accidental-style 'voice)", str)
1786 str = re
.sub (r
'\\modernAccidentals', "#(set-accidental-style 'modern)", str)
1787 str = re
.sub (r
'\\modernCautionaries', "#(set-accidental-style 'modern-cautionary)", str)
1788 str = re
.sub (r
'\\modernVoiceAccidental', "#(set-accidental-style 'modern-voice)", str)
1789 str = re
.sub (r
'\\modernVoiceCautionaries', "#(set-accidental-style 'modern-voice-cautionary)", str)
1790 str = re
.sub (r
'\\pianoAccidentals', "#(set-accidental-style 'piano)", str)
1791 str = re
.sub (r
'\\pianoCautionaries', "#(set-accidental-style 'piano-cautionary)", str)
1792 str = re
.sub (r
'\\forgetAccidentals', "#(set-accidental-style 'forget)", str)
1793 str = re
.sub (r
'\\noResetKey', "#(set-accidental-style 'no-reset)", str)
1797 @rule ((2, 1, 26), _ ("More Scheme function renaming"))
1799 str = re
.sub ('ly:set-grob-property!', 'ly:grob-set-property!',str)
1800 str = re
.sub ('ly:set-mus-property!', 'ly:music-set-property!',str)
1801 str = re
.sub ('ly:set-context-property!', 'ly:context-set-property!', str)
1802 str = re
.sub ('ly:get-grob-property', 'ly:grob-property',str)
1803 str = re
.sub ('ly:get-mus-property', 'ly:music-property',str)
1804 str = re
.sub ('ly:get-context-property', 'ly:context-property',str)
1808 @rule ((2, 1, 27), "property transposing -> tuning")
1811 g
= int (m
.group (2))
1819 lower_pitches
= filter (lambda x
: x
<= g
, [0, 2, 4, 5, 7, 9, 11, 12])
1820 s
= len (lower_pitches
) -1
1821 a
= g
- lower_pitches
[-1]
1824 print s
, lower_pitches
, g
, a
, s
1826 str += ['eses', 'es', '', 'is', 'isis'][a
+ 2]
1828 str += ',' * (-o
- 1)
1830 str += "'" * (o
+ 1)
1832 return '\\transposition %s ' % str
1835 str = re
.sub (r
"\\set ([A-Za-z]+\s*\.\s*)?transposing\s*=\s*#([-0-9]+)",
1840 @rule ((2, 1, 28), """make-music-by-name -> make-music,
1841 new syntax for setting \\arpeggioBracket""")
1843 str = re
.sub (r
'make-music-by-name', 'make-music', str)
1844 str = re
.sub (r
"\\override\s+.*Arpeggio\s+#.print-function\s+=\s+\\arpeggioBracket", r
"\\arpeggioBracket", str)
1848 @rule ((2, 1, 29), '\\center -> \\center-align, \\translator -> \\context')
1850 str = re
.sub (r
'\\center([^-])', '\\center-align\\1', str)
1851 str = re
.sub (r
'\\translator', '\\context', str)
1855 @rule ((2, 1, 30), '''\\threeq{flat,sharp} -> \\sesqui{flat,sharp}
1856 ly:get-mutable-properties -> ly:mutable-music-properties
1857 centralCPosition -> middleCPosition
1858 ly:unset-context-property -> ly:context-unset-property
1859 ly:translator-find -> ly:context-find
1860 ly:get-stencil-extent -> ly:stencil-extent
1863 str = re
.sub (r
'\\threeq(flat|sharp)', r
'\\sesqui\1', str)
1864 str = re
.sub (r
'ly:stencil-get-extent',
1865 'ly:stencil-extent', str)
1866 str = re
.sub (r
'ly:translator-find',
1867 'ly:context-find', str)
1868 str = re
.sub ('ly:unset-context-property','ly:context-unset-property',
1871 str = re
.sub (r
'ly:get-mutable-properties',
1872 'ly:mutable-music-properties',str)
1873 str = re
.sub (r
'centralCPosition',
1874 'middleCPosition',str)
1878 @rule ((2, 1, 31), 'remove \\alias Timing')
1880 str = re
.sub (r
'\\alias\s*"?Timing"?', '', str)
1884 @rule ((2, 1, 33), 'breakAlignOrder -> break-align-orders.')
1886 str = re
.sub (r
"(\\set\s+)?(?P<context>(Score\.)?)breakAlignOrder\s*=\s*#'(?P<list>[^\)]+)",
1887 r
"\n\\override \g<context>BreakAlignment #'break-align-orders = "
1888 + "#(make-vector 3 '\g<list>)", str)
1892 @rule ((2, 1, 34), 'set-paper-size -> set-default-paper-size.')
1894 str = re
.sub (r
"\(set-paper-size",
1895 "(set-default-paper-size",str)
1899 @rule ((2, 1, 36), 'ly:mutable-music-properties -> ly:music-mutable-properties')
1901 str = re
.sub (r
"ly:mutable-music-properties",
1902 "ly:music-mutable-properties", str)
1906 @rule ((2, 2, 0), _ ("bump version for release"))
1911 @rule ((2, 3, 1), '\\apply -> \\applymusic')
1913 return re
.sub (r
'\\apply\b', r
'\\applymusic', str)
1916 @rule ((2, 3, 2), '\\FooContext -> \\Foo')
1918 if re
.search ('textheight', str):
1920 stderr_write (NOT_SMART
% "textheight")
1922 stderr_write (UPDATE_MANUALLY
)
1925 _ ("""Page layout has been changed, using paper size and margins.
1926 textheight is no longer used.
1928 str = re
.sub (r
'\\OrchestralScoreContext', '\\Score', str)
1930 if m
.group(1) not in ['RemoveEmptyStaff',
1931 'AncientRemoveEmptyStaffContext',
1933 return '\\' + m
.group (1)
1938 str = re
.sub (r
'\\([a-zA-Z]+)Context\b', func
, str)
1939 str = re
.sub ('ly:paper-lookup', 'ly:output-def-lookup', str)
1943 @rule ((2, 3, 4), _ ('remove %s') % '\\notes')
1945 str = re
.sub (r
'\\notes\b', '', str)
1949 @rule ((2, 3, 6), 'lastpagefill -> raggedlastbottom')
1951 str = re
.sub (r
'lastpagefill\s*=\s*"?1"', 'raggedlastbottom = ##t', str)
1955 @rule ((2, 3, 8), 'remove \\consistsend, strip \\lyrics from \\lyricsto.')
1957 str = re
.sub (r
'\\consistsend', '\\consists', str)
1958 str = re
.sub (r
'\\lyricsto\s+("?[a-zA-Z]+"?)(\s*\\new Lyrics\s*)?\\lyrics',
1959 r
'\\lyricsto \1 \2', str)
1963 @rule ((2, 3, 9), 'neo_mensural -> neomensural, if-text-padding -> bound-padding')
1965 str = re
.sub (r
'neo_mensural', 'neomensural', str)
1966 str = re
.sub (r
'if-text-padding', 'bound-padding', str)
1970 @rule ((2, 3, 10), '\\addlyrics -> \\oldaddlyrics, \\newlyrics -> \\addlyrics')
1972 str = re
.sub (r
'\\addlyrics', r
'\\oldaddlyrics', str)
1973 str = re
.sub (r
'\\newlyrics', r
'\\addlyrics', str)
1974 if re
.search (r
"\\override\s*TextSpanner", str):
1975 stderr_write ("\nWarning: TextSpanner has been split into DynamicTextSpanner and TextSpanner\n")
1979 @rule ((2, 3, 11), '\\setMmRestFermata -> ^\\fermataMarkup')
1981 str = re
.sub (r
'\\setMmRestFermata\s+(R[0-9.*/]*)',
1982 r
'\1^\\fermataMarkup', str)
1986 @rule ((2, 3, 12), '''\\newpage -> \\pageBreak, junk \\script{up,down,both},
1987 soloADue -> printPartCombineTexts, #notes-to-clusters -> \\makeClusters
1990 str = re
.sub (r
'\\newpage', r
'\\pageBreak', str)
1991 str = re
.sub (r
'\\scriptUp', r
"""{
1992 \\override TextScript #'direction = #1
1993 \\override Script #'direction = #1
1995 str = re
.sub (r
'\\scriptDown', r
"""{
1996 \\override TextScript #'direction = #-1
1997 \\override Script #'direction = #-1
1999 str = re
.sub (r
'\\scriptBoth', r
"""{
2000 \\revert TextScript #'direction
2001 \\revert Script #'direction
2003 str = re
.sub ('soloADue', 'printPartCombineTexts', str)
2004 str = re
.sub (r
'\\applymusic\s*#notes-to-clusters',
2005 '\\makeClusters', str)
2007 str = re
.sub (r
'pagenumber\s*=', 'firstpagenumber = ', str)
2011 @rule ((2, 3, 16), _ ('''\\foo -> \\foomode (for chords, notes, etc.)
2012 fold \\new FooContext \\foomode into \\foo.'''))
2014 str = re
.sub (r
'\\chords\b', r
'\\chordmode', str)
2015 str = re
.sub (r
'\\lyrics\b', r
'\\lyricmode', str)
2016 str = re
.sub (r
'\\figures\b', r
'\\figuremode', str)
2017 str = re
.sub (r
'\\notes\b', r
'\\notemode', str)
2018 str = re
.sub (r
'\\drums\b', r
'\\drummode', str)
2019 str = re
.sub (r
'\\chordmode\s*\\new ChordNames', r
'\\chords', str)
2020 str = re
.sub (r
'\\new ChordNames\s*\\chordmode', r
'\\chords', str)
2021 str = re
.sub (r
'\\new FiguredBass\s*\\figuremode', r
'\\figures', str)
2022 str = re
.sub (r
'\\figuremode\s*\new FiguredBass', r
'\\figures', str)
2023 str = re
.sub (r
'\\new DrumStaff\s*\\drummode', r
'\\drums', str)
2024 str = re
.sub (r
'\\drummode\s*\\new DrumStaff', r
'\\drums', str)
2029 @rule ((2, 3, 17), '''slurBoth -> slurNeutral, stemBoth -> stemNeutral, etc.
2030 \\applymusic #(remove-tag 'foo) -> \\removeWithTag 'foo''')
2032 str = re
.sub (r
'(slur|stem|phrasingSlur|tie|dynamic|dots|tuplet|arpeggio|)Both', r
'\1Neutral', str)
2033 str = re
.sub (r
"\\applymusic\s*#\(remove-tag\s*'([a-z-0-9]+)\)",
2034 r
"\\removeWithTag #'\1", str)
2038 @rule ((2, 3, 18), 'Text_item -> Text_interface')
2040 str = re
.sub (r
'Text_item', 'Text_interface', str)
2044 @rule ((2, 3, 22), 'paper -> layout, bookpaper -> paper')
2046 str = re
.sub (r
'\\paper', r
'\\layout', str)
2047 str = re
.sub (r
'\\bookpaper', r
'\\paper', str)
2048 if re
.search ('paper-set-staff-size', str):
2049 warning (_ ('''staff size should be changed at top-level
2052 #(set-global-staff-size <STAFF-HEIGHT-IN-POINT>)
2057 str = re
.sub (r
'#\(paper-set-staff-size', '%Use set-global-staff-size at toplevel\n% #(layout-set-staff-size', str)
2061 @rule ((2, 3, 23), r
'\context Foo = NOTENAME -> \context Foo = "NOTENAME"')
2063 str = re
.sub (r
'\\context\s+([a-zA-Z]+)\s*=\s*([a-z]+)\s',
2064 r
'\\context \1 = "\2" ',
2069 @rule ((2, 3, 24), _ ('''regularize other identifiers'''))
2072 return regularize_id (m
.group (1))
2073 str = re
.sub (r
'(maintainer_email|maintainer_web|midi_stuff|gourlay_maxmeasures)',
2078 @rule ((2, 3, 25), 'petrucci_c1 -> petrucci-c1, 1style -> single-digit')
2080 str = re
.sub ('petrucci_c1', 'petrucci-c1', str)
2081 str = re
.sub ('1style', 'single-digit', str)
2085 @rule ((2, 4, 0), _ ("bump version for release"))
2090 @rule ((2, 5, 0), '\\quote -> \\quoteDuring')
2092 str = re
.sub (r
'\\quote\s+"?([a-zA-Z0-9]+)"?\s+([0-9.*/]+)',
2093 r
'\\quoteDuring #"\1" { \skip \2 }',
2098 @rule ((2, 5, 1), 'ly:import-module -> ly:module-copy')
2100 str = re
.sub (r
'ly:import-module',
2101 r
'ly:module-copy', str)
2105 @rule ((2, 5, 2), '\markup .. < .. > .. -> \markup .. { .. } ..')
2107 str = re
.sub (r
'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<(([^>]|<[^>]*>)*)>',
2109 str = re
.sub (r
'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<(([^>]|<[^>]*>)*)>',
2111 str = re
.sub (r
'\\(column|fill-line|dir-column|center-align|right-align|left-align|bracketed-y-column)\s*<(([^>]|<[^>]*>)*)>',
2115 s
= re
.sub (r
'''((\\"|})\s*){''', '\2 \\line {', s
)
2117 str = re
.sub (r
'\\markup\s*{([^}]|{[^}]*})*}', get_markup
, str)
2121 @rule ((2, 5, 3), 'ly:find-glyph-by-name -> ly:font-get-glyph, remove - from glyphnames.')
2123 str = re
.sub ('ly:find-glyph-by-name', 'ly:font-get-glyph', str)
2124 str = re
.sub ('"(scripts|clefs|accidentals)-', r
'"\1.', str)
2125 str = re
.sub ("'hufnagel-do-fa", "'hufnagel.do.fa", str)
2126 str = re
.sub ("'(vaticana|hufnagel|medicaea|petrucci|neomensural|mensural)-", r
"'\1.", str)
2130 @rule ((2, 5, 12), '\set Slur #\'dashed = #X -> \slurDashed')
2132 str = re
.sub (r
"\\override\s+(Voice\.)?Slur #'dashed\s*=\s*#\d*(\.\d+)?",
2133 r
"\\slurDashed", str)
2137 @rule ((2, 5, 13), _ ('\\encoding: smart recode latin1..utf-8. Remove ly:point-and-click'))
2139 input_encoding
= 'latin1'
2141 encoding
= match
.group (1)
2143 # FIXME: automatic recoding of other than latin1?
2144 if encoding
== 'latin1':
2145 return match
.group (2)
2148 stderr_write (NOT_SMART
% ("\\encoding: %s" % encoding
))
2150 stderr_write (_ ("LilyPond source must be UTF-8"))
2152 if encoding
== 'TeX':
2153 stderr_write (_ ("Try the texstrings backend"))
2156 stderr_write ( _("Do something like: %s") % \
2157 ("recode %s..utf-8 FILE" % encoding
))
2159 stderr_write (_ ("Or save as UTF-8 in your editor"))
2161 raise FatalConversionError ()
2163 return match
.group (0)
2165 str = re
.sub (r
'\\encoding\s+"?([a-zA-Z0-9]+)"?(\s+)', func
, str)
2168 de_ascii
= codecs
.getdecoder ('ascii')
2169 de_utf_8
= codecs
.getdecoder ('utf_8')
2170 de_input
= codecs
.getdecoder (input_encoding
)
2171 en_utf_8
= codecs
.getencoder ('utf_8')
2174 # only in python >= 2.3
2175 # except UnicodeDecodeError:
2176 except UnicodeError:
2177 # do not re-recode UTF-8 input
2180 #except UnicodeDecodeError:
2181 except UnicodeError:
2182 str = en_utf_8 (de_input (str)[0])[0]
2186 str = re
.sub (r
"#\(ly:set-point-and-click '[a-z-]+\)", '', str)
2190 @rule ((2, 5, 17), _ ('remove %s') % 'ly:stencil-set-extent!')
2192 if re
.search ("ly:stencil-set-extent!", str):
2194 stderr_write (NOT_SMART
% "ly:stencil-set-extent!")
2196 stderr_write ('use (set! VAR (ly:make-stencil (ly:stencil-expr VAR) X-EXT Y-EXT))\n')
2197 raise FatalConversionError ()
2198 if re
.search ("ly:stencil-align-to!", str):
2200 stderr_write (NOT_SMART
% "ly:stencil-align-to!")
2202 stderr_write ('use (set! VAR (ly:stencil-aligned-to VAR AXIS DIR))\n')
2203 raise FatalConversionError ()
2207 @rule ((2, 5, 18), 'ly:warn -> ly:warning')
2209 str = re
.sub (r
"ly:warn\b", 'ly:warning', str)
2213 @rule ((2, 5, 21), _ ('warn about auto beam settings'))
2215 if re
.search ("(override-|revert-)auto-beam-setting", str)\
2216 or re
.search ("autoBeamSettings", str):
2218 stderr_write (NOT_SMART
% _ ("auto beam settings"))
2220 stderr_write (_ ('''
2221 Auto beam settings must now specify each interesting moment in a measure
2222 explicitely; 1/4 is no longer multiplied to cover moments 1/2 and 3/4 too.
2224 stderr_write (UPDATE_MANUALLY
)
2226 raise FatalConversionError ()
2230 @rule ((2, 5, 25), 'unfoldrepeats -> unfoldRepeats, compressmusic -> compressMusic')
2232 str = re
.sub (r
"unfoldrepeats", 'unfoldRepeats', str)
2233 str = re
.sub (r
"compressmusic", 'compressMusic', str)
2237 @rule ((2, 6, 0), _ ("bump version for release"))
2242 @rule ((2, 7, 0), 'ly:get-default-font -> ly:grob-default-font')
2244 return re
.sub('ly:get-default-font', 'ly:grob-default-font', str)
2247 @rule ((2, 7, 1), '''ly:parser-define -> ly:parser-define!
2248 excentricity -> eccentricity
2249 Timing_engraver -> Timing_translator + Default_bar_line_engraver
2252 str = re
.sub('ly:parser-define', 'ly:parser-define!', str)
2253 str = re
.sub('excentricity', 'eccentricity', str)
2254 str = re
.sub(r
'\\(consists|remove) *"?Timing_engraver"?',
2255 r
'\\\1 "Timing_translator" \\\1 "Default_bar_line_engraver"',
2260 @rule ((2, 7, 2), 'ly:X-moment -> ly:moment-X')
2262 str = re
.sub('ly:(add|mul|mod|div)-moment', r
'ly:moment-\1', str)
2266 @rule ((2, 7, 4), 'keyAccidentalOrder -> keyAlterationOrder')
2268 str = re
.sub('keyAccidentalOrder', 'keyAlterationOrder', str)
2272 @rule ((2, 7, 6), '''Performer_group_performer -> Performer_group, Engraver_group_engraver -> Engraver_group,
2273 inside-slur -> avoid-slur''')
2275 str = re
.sub('Performer_group_performer', 'Performer_group', str)
2276 str = re
.sub('Engraver_group_engraver', 'Engraver_group', str)
2277 str = re
.sub (r
"#'inside-slur\s*=\s*##t *",
2278 r
"#'avoid-slur = #'inside ", str)
2279 str = re
.sub (r
"#'inside-slur\s*=\s*##f *",
2280 r
"#'avoid-slur = #'around ", str)
2281 str = re
.sub (r
"#'inside-slur",
2282 r
"#'avoid-slur", str)
2286 @rule ((2, 7, 10), '\\applyxxx -> \\applyXxx')
2288 str = re
.sub(r
'\\applyoutput', r
'\\applyOutput', str)
2289 str = re
.sub(r
'\\applycontext', r
'\\applyContext', str)
2290 str = re
.sub(r
'\\applymusic', r
'\\applyMusic', str)
2291 str = re
.sub(r
'ly:grob-suicide', 'ly:grob-suicide!', str)
2295 @rule ((2, 7, 11), '"tabloid" -> "11x17"')
2297 str = re
.sub(r
'\"tabloid\"', '"11x17"', str)
2301 @rule ((2, 7, 12), 'outputProperty -> overrideProperty')
2303 str = re
.sub(r
'outputProperty' , 'overrideProperty', str)
2307 @rule ((2, 7, 13), 'layout engine refactoring [FIXME]')
2310 newkey
= {'spacing-procedure': 'springs-and-rods',
2311 'after-line-breaking-callback' : 'after-line-breaking',
2312 'before-line-breaking-callback' : 'before-line-breaking',
2313 'print-function' : 'stencil'} [match
.group(3)]
2314 what
= match
.group (1)
2315 grob
= match
.group (2)
2317 if what
== 'revert':
2318 return "revert %s #'callbacks %% %s\n" % (grob
, newkey
)
2319 elif what
== 'override':
2320 return "override %s #'callbacks #'%s" % (grob
, newkey
)
2325 str = re
.sub(r
"(override|revert)\s*([a-zA-Z.]+)\s*#'(spacing-procedure|after-line-breaking-callback"
2326 + r
"|before-line-breaking-callback|print-function)",
2329 if re
.search ('bar-size-procedure', str):
2330 stderr_write (NOT_SMART
% "bar-size-procedure")
2331 if re
.search ('space-function', str):
2332 stderr_write (NOT_SMART
% "space-function")
2333 if re
.search ('verticalAlignmentChildCallback', str):
2334 stderr_write (_ ('verticalAlignmentChildCallback has been deprecated'))
2338 @rule ((2, 7, 14), _ ('Remove callbacks property, deprecate XY-extent-callback.'))
2340 str = re
.sub (r
"\\override +([A-Z.a-z]+) #'callbacks",
2341 r
"\\override \1", str)
2342 str = re
.sub (r
"\\revert ([A-Z.a-z]+) #'callbacks % ([a-zA-Z]+)",
2343 r
"\\revert \1 #'\2", str)
2344 str = re
.sub (r
"([XY]-extent)-callback", r
'\1', str)
2345 str = re
.sub (r
"RemoveEmptyVerticalGroup", "VerticalAxisGroup", str)
2346 str = re
.sub (r
"\\set ([a-zA-Z]*\.?)minimumVerticalExtent",
2347 r
"\\override \1VerticalAxisGroup #'minimum-Y-extent",
2349 str = re
.sub (r
"minimumVerticalExtent",
2350 r
"\\override VerticalAxisGroup #'minimum-Y-extent",
2352 str = re
.sub (r
"\\set ([a-zA-Z]*\.?)extraVerticalExtent",
2353 r
"\\override \1VerticalAxisGroup #'extra-Y-extent", str)
2354 str = re
.sub (r
"\\set ([a-zA-Z]*\.?)verticalExtent",
2355 r
"\\override \1VerticalAxisGroup #'Y-extent", str)
2359 @rule ((2, 7, 15), _ ('Use grob closures iso. XY-offset-callbacks.'))
2361 if re
.search ('[XY]-offset-callbacks', str):
2362 stderr_write (NOT_SMART
% "[XY]-offset-callbacks")
2363 if re
.search ('position-callbacks', str):
2364 stderr_write (NOT_SMART
% "position-callbacks")
2368 @rule ((2, 7, 22), r
"\tag #'(a b) -> \tag #'a \tag #'b")
2371 syms
= m
.group (1).split ()
2372 tags
= ["\\tag #'%s" % s
for s
in syms
]
2373 return ' '.join (tags
)
2375 str = re
.sub (r
"\\tag #'\(([^)]+)\)", sub_syms
, str)
2379 @rule ((2, 7, 24), _ ('deprecate %s') % 'number-visibility')
2381 str = re
.sub (r
"#'number-visibility",
2382 "#'number-visibility % number-visibility is deprecated. Tune the TupletNumber instead\n",
2387 @rule ((2, 7, 28), "ly:spanner-get-bound -> ly:spanner-bound")
2389 str = re
.sub (r
"ly:spanner-get-bound", "ly:spanner-bound", str)
2393 @rule ((2, 7, 29), "override Stem #'beamed-* -> #'details #'beamed-*")
2395 for a
in ['beamed-lengths', 'beamed-minimum-free-lengths',
2397 'beamed-extreme-minimum-free-lengths']:
2398 str = re
.sub (r
"\\override\s+Stem\s+#'%s" % a
,
2399 r
"\\override Stem #'details #'%s" % a
,
2404 @rule ((2, 7, 30), "\\epsfile")
2406 str = re
.sub (r
'\\epsfile *#"', r
'\\epsfile #X #10 #"', str)
2410 @rule ((2, 7, 31), "Foo_bar::bla_bla -> ly:foo-bar::bla-bla")
2414 return 'ly:' + str.lower ().replace ('_','-')
2416 str = re
.sub (r
'([A-Z][a-z_0-9]+::[a-z_0-9]+)',
2421 @rule ((2, 7, 32), _ ("foobar -> foo-bar for \paper, \layout"))
2424 ('inputencoding', 'input-encoding'),
2425 ('printpagenumber', 'print-page-number'),
2426 ('outputscale', 'output-scale'),
2427 ('betweensystemspace', 'between-system-space'),
2428 ('betweensystempadding', 'between-system-padding'),
2429 ('pagetopspace', 'page-top-space'),
2430 ('raggedlastbottom', 'ragged-last-bottom'),
2431 ('raggedright', 'ragged-right'),
2432 ('raggedlast', 'ragged-last'),
2433 ('raggedbottom', 'ragged-bottom'),
2434 ('aftertitlespace', 'after-title-space'),
2435 ('beforetitlespace', 'before-title-space'),
2436 ('betweentitlespace', 'between-title-space'),
2437 ('topmargin', 'top-margin'),
2438 ('bottommargin', 'bottom-margin'),
2439 ('headsep', 'head-separation'),
2440 ('footsep', 'foot-separation'),
2441 ('rightmargin', 'right-margin'),
2442 ('leftmargin', 'left-margin'),
2443 ('printfirstpagenumber', 'print-first-page-number'),
2444 ('firstpagenumber', 'first-page-number'),
2445 ('hsize', 'paper-width'),
2446 ('vsize', 'paper-height'),
2447 ('horizontalshift', 'horizontal-shift'),
2448 ('staffspace', 'staff-space'),
2449 ('linethickness', 'line-thickness'),
2450 ('ledgerlinethickness', 'ledger-line-thickness'),
2451 ('blotdiameter', 'blot-diameter'),
2452 ('staffheight', 'staff-height'),
2453 ('linewidth', 'line-width'),
2454 ('annotatespacing', 'annotate-spacing')
2457 for (a
,b
) in identifier_subs
:
2459 ## str = re.sub ('"%s"' % a, '"%s"' b, str)
2461 str = re
.sub (a
, b
, str)
2465 @rule ((2, 7, 32), "debug-beam-quanting -> debug-beam-scoring")
2467 str = re
.sub ('debug-beam-quanting', 'debug-beam-scoring', str)
2471 @rule ((2, 7, 36), "def-(music-function|markup-command) -> define-(music-function|markup-command)")
2473 str = re
.sub ('def-music-function', 'define-music-function', str)
2474 str = re
.sub ('def-markup-command', 'define-markup-command', str)
2478 @rule ((2, 7, 40), "rehearsalMarkAlignSymbol/barNumberAlignSymbol -> break-align-symbol")
2480 str = re
.sub (r
'\\set\s+Score\s*\.\s*barNumberAlignSymbol\s*=',
2481 r
"\\override Score.BarNumber #'break-align-symbol = ", str)
2482 str = re
.sub (r
'\\set\s*Score\s*\.\s*rehearsalMarkAlignSymbol\s*=',
2483 r
"\\override Score.RehearsalMark #'break-align-symbol = ", str)
2487 @rule ((2, 9, 4), "(page-)penalty -> (page-)break-penalty")
2489 str = re
.sub ('page-penalty', 'page-break-penalty', str)
2490 str = re
.sub ('([^-])penalty', '\1break-penalty', str)
2494 @rule ((2, 9, 6), "\\context Foo \\applyOutput #bla -> \\applyOutput #'Foo #bla ")
2496 str = re
.sub (r
'\\context\s+\"?([a-zA-Z]+)\"?\s*\\applyOutput', r
"\\applyOutput #'\1", str)
2500 @rule ((2, 9, 9), "annotatefoo -> annotate-foo")
2502 str = re
.sub ('annotatepage', 'annotate-page', str)
2503 str = re
.sub ('annotateheaders', 'annotate-headers', str)
2504 str = re
.sub ('annotatesystems', 'annotate-systems', str)
2508 @rule ((2, 9, 11), "\\set tupletNumberFormatFunction -> \\override #'text = ")
2510 str = re
.sub (r
"""(\\set\s)?(?P<context>[a-zA-Z]*.?)tupletNumberFormatFunction\s*=\s*#denominator-tuplet-formatter""",
2511 r
"""\\override \g<context>TupletNumber #'text = #tuplet-number::calc-denominator-text""", str)
2513 str = re
.sub (r
"""(\\set\s+)?(?P<context>[a-zA-Z]*.?)tupletNumberFormatFunction\s*=\s*#fraction-tuplet-formatter""",
2514 r
"""\\override \g<context>TupletNumber #'text = #tuplet-number::calc-fraction-text""", str)
2516 if re
.search ('tupletNumberFormatFunction', str):
2518 stderr_write ("tupletNumberFormatFunction has been removed. Use #'text property on TupletNumber")
2523 @rule ((2, 9, 13), "instrument -> instrumentName, instr -> shortInstrumentName, vocNam -> shortVocalName")
2525 str = re
.sub ('vocNam', 'shortVocalName', str)
2526 str = re
.sub (r
'\.instr\s*=', r
'.shortInstrumentName =', str)
2527 str = re
.sub (r
'\.instrument\s*=', r
'.instrumentName =', str)
2531 @rule ((2, 9, 16), _ ("deprecate \\tempo in \\midi"))
2535 dur
= int (m
.group (1))
2536 dots
= len (m
.group (2))
2537 count
= int (m
.group (3))
2544 den
= (1 << dots
) * (1 << log2
)
2545 num
= ((1 << (dots
+1)) - 1)
2551 tempoWholesPerMinute = #(ly:make-moment %d %d)
2555 """ % (num
*count
, den
)
2557 str = re
.sub (r
'\\midi\s*{\s*\\tempo ([0-9]+)\s*([.]*)\s*=\s*([0-9]+)\s*}', sub_tempo
, str)
2561 @rule ((2, 9, 19), "printfirst-page-number -> print-first-page-number")
2563 str = re
.sub ('printfirst-page-number', 'print-first-page-number', str)
2567 @rule ((2, 10, 0), _ ("bump version for release"))
2572 @rule ((2, 11, 2), "ly:clone-parser -> ly:parser-clone")
2574 return re
.sub ('ly:clone-parser',
2575 'ly:parser-clone', str)
2578 @rule ((2, 11, 5), _ ("deprecate cautionary-style. Use AccidentalCautionary properties"))
2580 str = re
.sub ("Accidental\s*#'cautionary-style\s*=\s*#'smaller",
2581 "AccidentalCautionary #'font-size = #-2", str)
2582 str = re
.sub ("Accidental\s*#'cautionary-style\s*=\s*#'parentheses",
2583 "AccidentalCautionary #'parenthesized = ##t", str)
2584 str = re
.sub ("([A-Za-z]+)\s*#'cautionary-style\s*=\s*#'parentheses",
2585 r
"\1 #'parenthesized = ##t", str)
2586 str = re
.sub ("([A-Za-z]+)\s*#'cautionary-style\s*=\s*#'smaller",
2587 r
"\1 #'font-size = #-2", str)
2591 @rule ((2, 11, 6), _ ("Rename accidental glyphs, use glyph-name-alist."))
2594 def sub_acc_name (m
):
2595 idx
= int (m
.group (1).replace ('M','-'))
2597 return ["accidentals.doublesharp",
2598 "accidentals.sharp.slashslash.stemstemstem",
2599 "accidentals.sharp",
2600 "accidentals.sharp.slashslash.stem",
2601 "accidentals.natural",
2602 "accidentals.mirroredflat",
2604 "accidentals.mirroredflat.flat",
2605 "accidentals.flatflat"][4-idx
]
2607 str = re
.sub (r
"accidentals[.](M?[-0-9]+)",
2609 str = re
.sub (r
"(KeySignature|Accidental[A-Za-z]*)\s*#'style\s*=\s*#'([a-z]+)",
2610 r
"\1 #'glyph-name-alist = #alteration-\2-glyph-name-alist", str)
2611 ## FIXME: standard vs default, alteration-FOO vs FOO-alteration
2612 str = str.replace ('alteration-default-glyph-name-alist',
2613 'standard-alteration-glyph-name-alist')
2617 @rule ((2, 11, 10), """allowBeamBreak -> Beam #'breakable = ##t
2618 addquote -> addQuote
2621 str = re
.sub (r
'(\\set\s+)?([A-Z][a-zA-Z]+\s*\.\s*)allowBeamBreak',
2622 r
"\override \2Beam #'breakable", str)
2623 str = re
.sub (r
'(\\set\s+)?allowBeamBreak',
2624 r
"\override Beam #'breakable", str)
2625 str = re
.sub (r
'addquote', 'addQuote', str)
2626 if re
.search ("Span_dynamic_performer", str):
2627 stderr_write ("Span_dynamic_performer has been merged into Dynamic_performer")
2632 @rule ((2, 11, 11), "layout-set-staff-size -> layout-set-absolute-staff-size")
2634 str = re
.sub (r
'\(layout-set-staff-size \(\*\s*([0-9.]+)\s*(pt|mm|cm)\)\)',
2635 r
'(layout-set-absolute-staff-size (* \1 \2))', str)
2639 @rule ((2, 11, 13), "#'arrow = ##t -> #'bound-details #'right #'arrow = ##t")
2641 str = re
.sub (r
"\\override\s*([a-zA-Z.]+)\s*#'arrow\s*=\s*##t",
2642 r
"\\override \1 #'bound-details #'right #'arrow = ##t",
2645 if re
.search ('edge-text', str):
2646 stderr_write (NOT_SMART
% _ ("edge-text settings for TextSpanner."))
2647 stderr_write (_ ("Use\n\n%s") %
2648 "\t\\override TextSpanner #'bound-details #'right #'text = <right-text>\n"
2649 "\t\\override TextSpanner #'bound-details #'left #'text = <left-text>\n")
2653 @rule ((2, 11, 15), "#'edge-height -> #'bound-details #'right/left #'text = ...")
2655 def sub_edge_height (m
):
2657 for (var
, h
) in [('left', m
.group (3)),
2658 ('right', m
.group (4))]:
2665 s
+= (r
"%s \override %s #'bound-details #'%s #'text = \markup { \draw-line #'(0 . %s) }"
2666 % (once
, m
.group (2), var
, h
))
2673 str = re
.sub (r
"(\\once)?\s*\\override\s*([a-zA-Z.]+)\s*#'edge-height\s*=\s*#'\(([0-9.-]+)\s+[.]\s+([0-9.-]+)\)",
2674 sub_edge_height
, str)
2678 @rule ((2, 11, 23), "#'break-align-symbol -> #'break-align-symbols")
2680 str = re
.sub (r
"\\override\s*([a-zA-Z.]+)\s*#'break-align-symbol\s*=\s*#'([a-z-]+)",
2681 r
"\\override \1 #'break-align-symbols = #'(\2)", str)
2685 @rule ((2, 11, 35), """scripts.caesura -> scripts.caesura.curved.
2686 """ + _ ("Use #'style not #'dash-fraction to select solid/dashed lines."))
2688 str = re
.sub (r
"scripts\.caesura",
2689 r
"scripts.caesura.curved", str)
2691 if re
.search ('dash-fraction', str):
2692 stderr_write (NOT_SMART
% _ ("all settings related to dashed lines.\n"))
2693 stderr_write (_ ("Use \\override ... #'style = #'line for solid lines and\n"))
2694 stderr_write (_ ("\t\\override ... #'style = #'dashed-line for dashed lines."))
2698 @rule ((2, 11, 38), """\\setEasyHeads -> \\easyHeadsOn, \\fatText -> \\textLengthOn,
2699 \\emptyText -> \\textLengthOff""")
2701 str = re
.sub (r
"setEasyHeads", r
"easyHeadsOn", str)
2702 str = re
.sub (r
"fatText", r
"textLengthOn", str)
2703 str = re
.sub (r
"emptyText", r
"textLengthOff", str)
2707 @rule ((2, 11, 46), "\\set hairpinToBarline -> \\override Hairpin #'to-barline")
2709 str = re
.sub (r
"\\set\s+([a-zA-Z]+)\s*.\s*hairpinToBarline\s*=\s*##([tf]+)",
2710 r
"\\override \1.Hairpin #'to-barline = ##\2", str)
2711 str = re
.sub (r
"\\set\s+hairpinToBarline\s*=\s*##([tf]+)",
2712 r
"\\override Hairpin #'to-barline = ##\1", str)
2713 str = re
.sub (r
"\\unset\s+([a-zA-Z]+)\s*.\s*hairpinToBarline",
2714 r
"\\revert \1.Hairpin #'to-barline", str)
2715 str = re
.sub (r
"\\unset\s+hairpinToBarline",
2716 r
"\\revert Hairpin #'to-barline", str)
2717 str = re
.sub (r
"hairpinToBarline\s*=\s*##([tf]+)",
2718 r
"\\override Hairpin #'to-barline = ##\1", str)
2719 str = re
.sub (r
"\\set (de|)crescendoSpanner = #'dashed-line",
2720 r
"\\set \1crescendoSpanner = #'text", str)
2724 @rule ((2, 11, 48), "\\compressMusic -> \\scaleDurations")
2726 str = re
.sub (r
"compressMusic", r
"scaleDurations", str)
2730 @rule ((2, 11, 50), _ ("metronomeMarkFormatter uses text markup as second argument,\n\
2731 fret diagram properties moved to fret-diagram-details."))
2733 ## warning 1/2: metronomeMarkFormatter uses text markup as second argument
2734 if re
.search ('metronomeMarkFormatter', str):
2735 stderr_write (NOT_SMART
% _ ("metronomeMarkFormatter got an additional text argument.\n"))
2736 stderr_write (_ ("The function assigned to Score.metronomeMarkFunction now uses the signature\n%s") %
2737 "\t(format-metronome-markup text dur count context)\n")
2739 ## warning 2/2: fret diagram properties moved to fret-diagram-details
2740 fret_props
= ['barre-type',
2748 'xo-font-magnification',
2752 for prop
in fret_props
:
2753 if re
.search (prop
, str):
2754 stderr_write (NOT_SMART
%
2755 prop
+ " in fret-diagram properties. Use fret-diagram-details.")
2759 @rule ((2, 11, 51), "\\octave -> \\octaveCheck, \\arpeggioUp -> \\arpeggioArrowUp,\n\
2760 \\arpeggioDown -> \\arpeggioArrowDown, \\arpeggioNeutral -> \\arpeggioNormal,\n\
2761 \\setTextCresc -> \\crescTextCresc, \\setTextDecresc -> \\dimTextDecresc,\n\
2762 \\setTextDecr -> \\dimTextDecr, \\setTextDim -> \\dimTextDim,\n\
2763 \\setHairpinCresc -> \\crescHairpin, \\setHairpinDecresc -> \\dimHairpin,\n\
2764 \\sustainUp -> \\sustainOff, \\sustainDown -> \\sustainOn\n\
2765 \\sostenutoDown -> \\sostenutoOn, \\sostenutoUp -> \\sostenutoOff")
2767 str = re
.sub (r
"\\octave", r
"\\octaveCheck", str)
2768 str = re
.sub (r
"arpeggioUp", r
"arpeggioArrowUp", str)
2769 str = re
.sub (r
"arpeggioDown", r
"arpeggioArrowDown", str)
2770 str = re
.sub (r
"arpeggioNeutral", r
"arpeggioNormal", str)
2771 str = re
.sub (r
"setTextCresc", r
"crescTextCresc", str)
2772 str = re
.sub (r
"setTextDecresc", r
"dimTextDecresc", str)
2773 str = re
.sub (r
"setTextDecr", r
"dimTextDecr", str)
2774 str = re
.sub (r
"setTextDim", r
"dimTextDim", str)
2775 str = re
.sub (r
"setHairpinCresc", r
"crescHairpin", str)
2776 str = re
.sub (r
"setHairpinDecresc", r
"dimHairpin", str)
2777 str = re
.sub (r
"sustainUp", r
"sustainOff", str)
2778 str = re
.sub (r
"sustainDown", r
"sustainOn", str)
2779 str = re
.sub (r
"sostenutoDown", r
"sostenutoOn", str)
2780 str = re
.sub (r
"sostenutoUp", r
"sostenutoOff", str)
2783 @rule ((2, 11, 52), "\\setHairpinDim -> \\dimHairpin")
2785 str = str.replace ("setHairpinDim", "dimHairpin")
2788 @rule ((2, 11, 53), "infinite-spacing-height -> extra-spacing-height")
2790 str = re
.sub (r
"infinite-spacing-height\s+=\s+##t", r
"extra-spacing-height = #'(-inf.0 . +inf.0)", str)
2791 str = re
.sub (r
"infinite-spacing-height\s+=\s+##f", r
"extra-spacing-height = #'(0 . 0)", str)
2794 @rule ((2, 11, 55), "#(set-octavation oct) -> \\ottava #oct,\n\
2795 \\put-adjacent markup axis dir markup -> \\put-adjacent axis dir markup markup")
2797 str = re
.sub (r
"#\(set-octavation (-*[0-9]+)\)", r
"\\ottava #\1", str)
2798 if re
.search ('put-adjacent', str):
2799 stderr_write (NOT_SMART
% _ ("\\put-adjacent argument order.\n"))
2800 stderr_write (_ ("Axis and direction now come before markups:\n"))
2801 stderr_write (_ ("\\put-adjacent axis dir markup markup."))
2804 @rule ((2, 11, 57), "\\center-align -> \\center-column, \\hcenter -> \\center-align")
2806 str = re
.sub (r
"([\\:]+)center-align", r
"\1center-column", str)
2807 str = re
.sub (r
"hcenter(\s+)", r
"center-align\1", str)
2810 @rule ((2, 11, 60), "printallheaders -> print-all-headers")
2812 str = re
.sub (r
"printallheaders", r
"print-all-headers", str)
2815 @rule ((2, 11, 61), "gregorian-init.ly -> gregorian.ly")
2817 str = re
.sub (r
'\\include(\s+)"gregorian-init.ly"', r
'\\include\1"gregorian.ly"', str)
2820 @rule ((2, 11, 62), "makam-init.ly -> makam.ly, \\bigger -> \\larger")
2822 str = re
.sub (r
'\\include(\s+)"makam-init.ly"', r
'\\include\1"makam.ly"', str)
2823 str = re
.sub (r
"\\bigger", r
"\\larger", str)
2826 @rule ((2, 11, 64), "systemSeparatorMarkup -> system-separator-markup,\n\
2827 InnerStaffGroup -> StaffGroup, InnerChoirStaff -> ChoirStaff")
2829 str = re
.sub (r
'systemSeparatorMarkup', r
'system-separator-markup', str)
2830 if re
.search (r
'\\InnerStaffGroup', str):
2832 stderr_write (NOT_SMART
% _("re-definition of InnerStaffGroup.\n"))
2833 stderr_write (FROM_TO
% ("InnerStaffGroup", "StaffGroup.\n"))
2834 stderr_write (UPDATE_MANUALLY
)
2835 raise FatalConversionError ()
2836 if re
.search (r
'\\InnerChoirStaff', str):
2838 stderr_write (NOT_SMART
% _("re-definition of InnerChoirStaff.\n"))
2839 stderr_write (FROM_TO
% ("InnerChoirStaff", "ChoirStaff.\n"))
2840 stderr_write (UPDATE_MANUALLY
)
2841 raise FatalConversionError ()
2843 str = re
.sub ('InnerStaffGroup', 'StaffGroup', str)
2844 str = re
.sub ('InnerChoirStaff', 'ChoirStaff', str)
2847 @rule ((2, 11, 66), "Syntax changes for \\addChordShape and \\chord-shape")
2849 if re
.search(r
'\\addChordShape', str):
2851 stderr_write (NOT_SMART
% _("stringTuning must be added to \
2852 addChordShape call.\n"))
2853 stderr_write (UPDATE_MANUALLY
)
2854 raise FatalConversionError ()
2855 if re
.search (r
'\\chord-shape', str):
2857 stderr_write (NOT_SMART
% _("stringTuning must be added to \
2858 chord-shape call.\n"))
2859 stderr_write (UPDATE_MANUALLY
)
2860 raise FatalConversionError ()
2863 # Guidelines to write rules (please keep this at the end of this file)
2865 # - keep at most one rule per version; if several conversions should be done,
2866 # concatenate them into a single "conv" function;
2868 # - enclose strings to be localized with `_(' and `)';
2870 # - write rule for bumping major stable version with
2872 # _ ("bump version for release")
2874 # as exact description.