From 9a9f468dfc0aebccb458c49ba8e28fa58b17d1cd Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Thu, 18 Aug 2005 14:04:01 +0000 Subject: [PATCH] * python/convertrules.py (conv): inside-slur -> avoid-slur. Remove functions. Remove if 1: constructs, reindent. * scripts/convert-ly.py (add_version): Add functions from convertrules.py * scm/script.scm (default-script-alist): s/priority/script-priority. Fixes script stacking. Backportme. (Fermata): Very low priority. --- ChangeLog | 12 + python/convertrules.py | 2361 ++++++++++++++++++++-------------------- scm/script.scm | 13 +- scripts/convert-ly.py | 59 +- 4 files changed, 1230 insertions(+), 1215 deletions(-) diff --git a/ChangeLog b/ChangeLog index e2d8da7611..85afa016df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-08-18 Jan Nieuwenhuizen + + * python/convertrules.py (conv): inside-slur -> avoid-slur. + Remove functions. Remove if 1: constructs, reindent. + + * scripts/convert-ly.py (add_version): Add functions from + convertrules.py + + * scm/script.scm (default-script-alist): + s/priority/script-priority. Fixes script stacking. Backportme. + (Fermata): Very low priority. + 2005-08-18 Han-Wen Nienhuys * input/regression/*.ly: remove superfluous \score blocks. Reindent. diff --git a/python/convertrules.py b/python/convertrules.py index 0bd24bd3a4..83f6eff57f 100644 --- a/python/convertrules.py +++ b/python/convertrules.py @@ -22,611 +22,609 @@ lilypond_version_re = re.compile (lilypond_version_re_str) -if 1: - def conv(str): - if re.search ('\\\\multi', str): - error_file.write ('\n') - error_file.write (NOT_SMART % "\\multi") - error_file.write ('\n') - return str - conversions.append (((0,1,9), conv, '\\header { key = concat + with + operator }')) +def conv(str): + if re.search ('\\\\multi', str): + error_file.write ('\n') + error_file.write (NOT_SMART % "\\multi") + error_file.write ('\n') + return str -if 1: - def conv (str): - if re.search ('\\\\octave', str): - error_file.write ('\n') - error_file.write (NOT_SMART % "\\octave") - error_file.write ('\n') - error_file.write (UPDATE_MANUALLY) - error_file.write ('\n') - # raise FatalConversionError () +conversions.append (((0,1,9), conv, '\\header { key = concat + with + operator }')) - return str - conversions.append (( - ((0,1,19), conv, 'deprecated \\octave; cannot convert automatically'))) +def conv (str): + if re.search ('\\\\octave', str): + error_file.write ('\n') + error_file.write (NOT_SMART % "\\octave") + error_file.write ('\n') + error_file.write (UPDATE_MANUALLY) + error_file.write ('\n') + # raise FatalConversionError () + return str -if 1: - def conv (str): - str = re.sub ('\\\\textstyle([^;]+);', - '\\\\property Lyrics . textstyle = \\1', str) - # harmful to current .lys - # str = re.sub ('\\\\key([^;]+);', '\\\\accidentals \\1;', str) +conversions.append (( + ((0,1,19), conv, 'deprecated \\octave; cannot convert automatically'))) - return str - conversions.append (( - ((0,1,20), conv, 'deprecated \\textstyle, new \\key syntax'))) +def conv (str): + str = re.sub ('\\\\textstyle([^;]+);', + '\\\\property Lyrics . textstyle = \\1', str) + # harmful to current .lys + # str = re.sub ('\\\\key([^;]+);', '\\\\accidentals \\1;', str) -if 1: - def conv (str): - str = re.sub ('\\\\musical_pitch', '\\\\musicalpitch',str) - str = re.sub ('\\\\meter', '\\\\time',str) + return str - return str +conversions.append (( + ((0,1,20), conv, 'deprecated \\textstyle, new \\key syntax'))) - conversions.append (( - ((0,1,21), conv, '\\musical_pitch -> \\musicalpitch, '+ - '\\meter -> \\time'))) -if 1: - def conv (str): - return str - conversions.append (( - ((1,0,0), conv, '0.1.21 -> 1.0.0 '))) +def conv (str): + str = re.sub ('\\\\musical_pitch', '\\\\musicalpitch',str) + str = re.sub ('\\\\meter', '\\\\time',str) + return str -if 1: - def conv (str): - str = re.sub ('\\\\accidentals', '\\\\keysignature',str) - str = re.sub ('specialaccidentals *= *1', 'keyoctaviation = 0',str) - str = re.sub ('specialaccidentals *= *0', 'keyoctaviation = 1',str) +conversions.append (( + ((0,1,21), conv, '\\musical_pitch -> \\musicalpitch, '+ + '\\meter -> \\time'))) - return str - conversions.append (( - ((1,0,1), conv, '\\accidentals -> \\keysignature, ' + - 'specialaccidentals -> keyoctaviation'))) +def conv (str): + return str -if 1: - def conv(str): - if re.search ('\\\\header', str): - error_file.write ('\n') - error_file.write (NOT_SMART % "new \\header format") - error_file.write ('\n') - return str +conversions.append (( + ((1,0,0), conv, '0.1.21 -> 1.0.0 '))) - conversions.append (((1,0,2), conv, '\\header { key = concat + with + operator }')) -if 1: - def conv(str): - str = re.sub ('\\\\melodic([^a-zA-Z])', '\\\\notes\\1',str) - return str - conversions.append (((1,0,3), conv, '\\melodic -> \\notes')) +def conv (str): + str = re.sub ('\\\\accidentals', '\\\\keysignature',str) + str = re.sub ('specialaccidentals *= *1', 'keyoctaviation = 0',str) + str = re.sub ('specialaccidentals *= *0', 'keyoctaviation = 1',str) -if 1: - def conv(str): - str = re.sub ('default_paper *=', '',str) - str = re.sub ('default_midi *=', '',str) - return str + return str - conversions.append (((1,0,4), conv, 'default_{paper,midi}')) +conversions.append (( + ((1,0,1), conv, '\\accidentals -> \\keysignature, ' + + 'specialaccidentals -> keyoctaviation'))) -if 1: - def conv(str): - str = re.sub ('ChoireStaff', 'ChoirStaff',str) - str = re.sub ('\\\\output', 'output = ',str) - return str +def conv(str): + if re.search ('\\\\header', str): + error_file.write ('\n') + error_file.write (NOT_SMART % "new \\header format") + error_file.write ('\n') + return str - conversions.append (((1,0,5), conv, 'ChoireStaff -> ChoirStaff')) +conversions.append (((1,0,2), conv, '\\header { key = concat + with + operator }')) -if 1: - def conv(str): - if re.search ('[a-zA-Z]+ = *\\translator',str): - error_file.write ('\n') - error_file.write (NOT_SMART % "\\translator syntax") - error_file.write ('\n') - # raise FatalConversionError () - return str - conversions.append (((1,0,6), conv, 'foo = \\translator {\\type .. } ->\\translator {\\type ..; foo; }')) +def conv(str): + str = re.sub ('\\\\melodic([^a-zA-Z])', '\\\\notes\\1',str) + return str +conversions.append (((1,0,3), conv, '\\melodic -> \\notes')) -if 1: - def conv(str): - str = re.sub ('\\\\lyrics*', '\\\\lyrics',str) - return str +def conv(str): + str = re.sub ('default_paper *=', '',str) + str = re.sub ('default_midi *=', '',str) + return str - conversions.append (((1,0,7), conv, '\\lyric -> \\lyrics')) - -if 1: - def conv(str): - str = re.sub ('\\\\\\[/3+', '\\\\times 2/3 { ',str) - str = re.sub ('\\[/3+', '\\\\times 2/3 { [',str) - str = re.sub ('\\\\\\[([0-9/]+)', '\\\\times \\1 {',str) - str = re.sub ('\\[([0-9/]+)', '\\\\times \\1 { [',str) - str = re.sub ('\\\\\\]([0-9/]+)', '}', str) - str = re.sub ('\\\\\\]', '}',str) - str = re.sub ('\\]([0-9/]+)', '] }', str) - return str +conversions.append (((1,0,4), conv, 'default_{paper,midi}')) - conversions.append (((1,0,10), conv, '[2/3 ]1/1 -> \\times 2/3 ')) -if 1: - def conv(str): - return str - conversions.append (((1,0,12), conv, 'Chord syntax stuff')) +def conv(str): + str = re.sub ('ChoireStaff', 'ChoirStaff',str) + str = re.sub ('\\\\output', 'output = ',str) + return str -if 1: - def conv(str): +conversions.append (((1,0,5), conv, 'ChoireStaff -> ChoirStaff')) - str = re.sub ('<([^>~]+)~([^>]*)>','<\\1 \\2> ~', str) +def conv(str): + if re.search ('[a-zA-Z]+ = *\\translator',str): + error_file.write ('\n') + error_file.write (NOT_SMART % "\\translator syntax") + error_file.write ('\n') + # raise FatalConversionError () + return str - return str +conversions.append (((1,0,6), conv, 'foo = \\translator {\\type .. } ->\\translator {\\type ..; foo; }')) - conversions.append (((1,0,13), conv, ' c -> ~ c')) -if 1: - def conv(str): - str = re.sub ('<\\[','[<', str) - str = re.sub ('\\]>','>]', str) - return str +def conv(str): + str = re.sub ('\\\\lyrics*', '\\\\lyrics',str) - conversions.append (((1,0,14), conv, '<[a b> c -> [ ]')) + return str +conversions.append (((1,0,7), conv, '\\lyric -> \\lyrics')) -if 1: - def conv(str): - str = re.sub ('\\\\type([^\n]*engraver)','\\\\TYPE\\1', str) - str = re.sub ('\\\\type([^\n]*performer)','\\\\TYPE\\1', str) - str = re.sub ('\\\\type','\\\\context', str) - str = re.sub ('\\\\TYPE','\\\\type', str) - str = re.sub ('textstyle','textStyle', str) - return str +def conv(str): + str = re.sub ('\\\\\\[/3+', '\\\\times 2/3 { ',str) + str = re.sub ('\\[/3+', '\\\\times 2/3 { [',str) + str = re.sub ('\\\\\\[([0-9/]+)', '\\\\times \\1 {',str) + str = re.sub ('\\[([0-9/]+)', '\\\\times \\1 { [',str) + str = re.sub ('\\\\\\]([0-9/]+)', '}', str) + str = re.sub ('\\\\\\]', '}',str) + str = re.sub ('\\]([0-9/]+)', '] }', str) + return str - conversions.append (((1,0,16), conv, '\\type -> \\context, textstyle -> textStyle')) +conversions.append (((1,0,10), conv, '[2/3 ]1/1 -> \\times 2/3 ')) -if 1: - def conv(str): - if re.search ('\\\\repeat',str): - error_file.write ('\n') - error_file.write (NOT_SMART % "\\repeat") - error_file.write ('\n') - # raise FatalConversionError () - return str +def conv(str): + return str +conversions.append (((1,0,12), conv, 'Chord syntax stuff')) - conversions.append (((1,0,18), conv, - '\\repeat NUM Music Alternative -> \\repeat FOLDSTR Music Alternative')) -if 1: - def conv(str): - str = re.sub ('SkipBars','skipBars', str) - str = re.sub ('fontsize','fontSize', str) - str = re.sub ('midi_instrument','midiInstrument', str) - return str +def conv(str): - conversions.append (((1,0,19), conv, - 'fontsize -> fontSize, midi_instrument -> midiInstrument, SkipBars -> skipBars')) + str = re.sub ('<([^>~]+)~([^>]*)>','<\\1 \\2> ~', str) -if 1: - def conv(str): - str = re.sub ('tieydirection','tieVerticalDirection', str) - str = re.sub ('slurydirection','slurVerticalDirection', str) - str = re.sub ('ydirection','verticalDirection', str) + return str - return str +conversions.append (((1,0,13), conv, ' c -> ~ c')) - conversions.append (((1,0,20), conv, - '{,tie,slur}ydirection -> {v,tieV,slurV}erticalDirection')) +def conv(str): + str = re.sub ('<\\[','[<', str) + str = re.sub ('\\]>','>]', str) -if 1: - def conv(str): - str = re.sub ('hshift','horizontalNoteShift', str) + return str - return str +conversions.append (((1,0,14), conv, '<[a b> c -> [ ]')) - conversions.append (((1,0,21), conv, - 'hshift -> horizontalNoteShift')) -if 1: - def conv(str): - str = re.sub ('\\\\grouping[^;]*;','', str) +def conv(str): + str = re.sub ('\\\\type([^\n]*engraver)','\\\\TYPE\\1', str) + str = re.sub ('\\\\type([^\n]*performer)','\\\\TYPE\\1', str) + str = re.sub ('\\\\type','\\\\context', str) + str = re.sub ('\\\\TYPE','\\\\type', str) + str = re.sub ('textstyle','textStyle', str) - return str + return str - conversions.append (((1,1,52), conv, - 'deprecate \\grouping')) +conversions.append (((1,0,16), conv, '\\type -> \\context, textstyle -> textStyle')) -if 1: - def conv(str): - str = re.sub ('\\\\wheel','\\\\coda', str) - return str +def conv(str): + if re.search ('\\\\repeat',str): + error_file.write ('\n') + error_file.write (NOT_SMART % "\\repeat") + error_file.write ('\n') + # raise FatalConversionError () + return str - conversions.append (((1,1,55), conv, - '\\wheel -> \\coda')) +conversions.append (((1,0,18), conv, + '\\repeat NUM Music Alternative -> \\repeat FOLDSTR Music Alternative')) -if 1: - def conv(str): - str = re.sub ('keyoctaviation','keyOctaviation', str) - str = re.sub ('slurdash','slurDash', str) - return str +def conv(str): + str = re.sub ('SkipBars','skipBars', str) + str = re.sub ('fontsize','fontSize', str) + str = re.sub ('midi_instrument','midiInstrument', str) - conversions.append (((1,1,65), conv, - 'slurdash -> slurDash, keyoctaviation -> keyOctaviation')) + return str -if 1: - def conv(str): - str = re.sub ('\\\\repeat *\"?semi\"?','\\\\repeat "volta"', str) +conversions.append (((1,0,19), conv, + 'fontsize -> fontSize, midi_instrument -> midiInstrument, SkipBars -> skipBars')) - return str - conversions.append (((1,1,66), conv, - 'semi -> volta')) +def conv(str): + str = re.sub ('tieydirection','tieVerticalDirection', str) + str = re.sub ('slurydirection','slurVerticalDirection', str) + str = re.sub ('ydirection','verticalDirection', str) -if 1: - def conv(str): - str = re.sub ('\"?beamAuto\"? *= *\"?0?\"?','noAutoBeaming = "1"', str) + return str - return str +conversions.append (((1,0,20), conv, + '{,tie,slur}ydirection -> {v,tieV,slurV}erticalDirection')) - conversions.append (((1,1,67), conv, - 'beamAuto -> noAutoBeaming')) -if 1: - def conv(str): - str = re.sub ('automaticMelismas', 'automaticMelismata', str) - return str +def conv(str): + str = re.sub ('hshift','horizontalNoteShift', str) - conversions.append (((1,2,0), conv, - 'automaticMelismas -> automaticMelismata')) + return str -if 1: - def conv(str): - str = re.sub ('dynamicDir\\b', 'dynamicDirection', str) +conversions.append (((1,0,21), conv, + 'hshift -> horizontalNoteShift')) - return str - conversions.append (((1,2,1), conv, - 'dynamicDir -> dynamicDirection')) -if 1: - def conv(str): - str = re.sub ('\\\\cadenza *0 *;', '\\\\cadenzaOff', str) - str = re.sub ('\\\\cadenza *1 *;', '\\\\cadenzaOn', str) +def conv(str): + str = re.sub ('\\\\grouping[^;]*;','', str) - return str + return str - conversions.append (((1,3,4), conv, - '\\cadenza -> \\cadenza{On|Off}')) +conversions.append (((1,1,52), conv, + 'deprecate \\grouping')) -if 1: - def conv (str): - str = re.sub ('"?beamAuto([^"=]+)"? *= *"([0-9]+)/([0-9]+)" *;*', - 'beamAuto\\1 = #(make-moment \\2 \\3)', - str) - return str - conversions.append (((1,3,5), conv, 'beamAuto moment properties')) -if 1: - def conv (str): - str = re.sub ('stemStyle', - 'flagStyle', - str) - return str +def conv(str): + str = re.sub ('\\\\wheel','\\\\coda', str) - conversions.append (((1,3,17), conv, 'stemStyle -> flagStyle')) + return str -if 1: - def conv (str): - str = re.sub ('staffLineLeading', - 'staffSpace', - str) - return str +conversions.append (((1,1,55), conv, + '\\wheel -> \\coda')) - conversions.append (((1,3,18), conv, 'staffLineLeading -> staffSpace')) +def conv(str): + str = re.sub ('keyoctaviation','keyOctaviation', str) + str = re.sub ('slurdash','slurDash', str) -if 1: - def conv(str): - if re.search ('\\\\repetitions',str): - error_file.write ('\n') - error_file.write (NOT_SMART % "\\repetitions") - error_file.write ('\n') - # raise FatalConversionError () - return str + return str - conversions.append (((1,3,23), conv, - '\\\\repetitions feature dropped')) +conversions.append (((1,1,65), conv, + 'slurdash -> slurDash, keyoctaviation -> keyOctaviation')) -if 1: - def conv (str): - str = re.sub ('textEmptyDimension *= *##t', - 'textNonEmpty = ##f', - str) - str = re.sub ('textEmptyDimension *= *##f', - 'textNonEmpty = ##t', - str) - return str +def conv(str): + str = re.sub ('\\\\repeat *\"?semi\"?','\\\\repeat "volta"', str) - conversions.append (((1,3,35), conv, 'textEmptyDimension -> textNonEmpty')) + return str -if 1: - def conv (str): - str = re.sub ("([a-z]+)[ \t]*=[ \t]*\\\\musicalpitch *{([- 0-9]+)} *\n", - "(\\1 . (\\2))\n", str) - str = re.sub ("\\\\musicalpitch *{([0-9 -]+)}", - "\\\\musicalpitch #'(\\1)", str) - if re.search ('\\\\notenames',str): - error_file.write ('\n') - error_file.write (NOT_SMART % "new \\notenames format") - error_file.write ('\n') - return str +conversions.append (((1,1,66), conv, + 'semi -> volta')) - conversions.append (((1,3,38), conv, '\musicalpitch { a b c } -> #\'(a b c)')) -if 1: - def conv (str): - def replace (match): - return '\\key %s;' % string.lower (match.group (1)) - str = re.sub ("\\\\key ([^;]+);", replace, str) - return str +def conv(str): + str = re.sub ('\"?beamAuto\"? *= *\"?0?\"?','noAutoBeaming = "1"', str) - conversions.append (((1,3,39), conv, '\\key A ; ->\\key a;')) + return str -if 1: - def conv (str): - if re.search ('\\[:',str): - error_file.write ('\n') - error_file.write (NOT_SMART % "new tremolo format") - error_file.write ('\n') - return str +conversions.append (((1,1,67), conv, + 'beamAuto -> noAutoBeaming')) - conversions.append (((1,3,41), conv, - '[:16 c4 d4 ] -> \\repeat "tremolo" 2 { c16 d16 }')) -if 1: - def conv (str): - str = re.sub ('Staff_margin_engraver' , 'Instrument_name_engraver', str) - return str +def conv(str): + str = re.sub ('automaticMelismas', 'automaticMelismata', str) - conversions.append (((1,3,42), conv, - 'Staff_margin_engraver deprecated, use Instrument_name_engraver')) + return str -if 1: - def conv (str): - str = re.sub ('note[hH]eadStyle\\s*=\\s*"?(\\w+)"?' , "noteHeadStyle = #'\\1", str) - return str +conversions.append (((1,2,0), conv, + 'automaticMelismas -> automaticMelismata')) - conversions.append (((1,3,49), conv, - 'noteHeadStyle value: string -> symbol')) -if 1: - def conv (str): - if re.search ('\\\\keysignature', str): - error_file.write ('\n') - error_file.write (NOT_SMART % "new tremolo format") - error_file.write ('\n') - return str +def conv(str): + str = re.sub ('dynamicDir\\b', 'dynamicDirection', str) + return str - conversions.append (((1,3,58), conv, - 'noteHeadStyle value: string -> symbol')) +conversions.append (((1,2,1), conv, + 'dynamicDir -> dynamicDirection')) -if 1: - def conv (str): - str = re.sub (r"""\\key *([a-z]+) *;""", r"""\\key \1 \major;""",str); - return str - conversions.append (((1,3,59), conv, - '\key X ; -> \key X major; ')) -if 1: - def conv (str): - str = re.sub (r'latexheaders *= *"\\\\input ', - 'latexheaders = "', - str) - return str - conversions.append (((1,3,68), conv, 'latexheaders = "\\input global" -> latexheaders = "global"')) +def conv(str): + str = re.sub ('\\\\cadenza *0 *;', '\\\\cadenzaOff', str) + str = re.sub ('\\\\cadenza *1 *;', '\\\\cadenzaOn', str) + + return str + +conversions.append (((1,3,4), conv, + '\\cadenza -> \\cadenza{On|Off}')) + + +def conv (str): + str = re.sub ('"?beamAuto([^"=]+)"? *= *"([0-9]+)/([0-9]+)" *;*', + 'beamAuto\\1 = #(make-moment \\2 \\3)', + str) + return str + +conversions.append (((1,3,5), conv, 'beamAuto moment properties')) + + +def conv (str): + str = re.sub ('stemStyle', + 'flagStyle', + str) + return str + +conversions.append (((1,3,17), conv, 'stemStyle -> flagStyle')) + + +def conv (str): + str = re.sub ('staffLineLeading', + 'staffSpace', + str) + return str + +conversions.append (((1,3,18), conv, 'staffLineLeading -> staffSpace')) + + + +def conv(str): + if re.search ('\\\\repetitions',str): + error_file.write ('\n') + error_file.write (NOT_SMART % "\\repetitions") + error_file.write ('\n') + # raise FatalConversionError () + return str + +conversions.append (((1,3,23), conv, + '\\\\repetitions feature dropped')) + + + +def conv (str): + str = re.sub ('textEmptyDimension *= *##t', + 'textNonEmpty = ##f', + str) + str = re.sub ('textEmptyDimension *= *##f', + 'textNonEmpty = ##t', + str) + return str + +conversions.append (((1,3,35), conv, 'textEmptyDimension -> textNonEmpty')) + + +def conv (str): + str = re.sub ("([a-z]+)[ \t]*=[ \t]*\\\\musicalpitch *{([- 0-9]+)} *\n", + "(\\1 . (\\2))\n", str) + str = re.sub ("\\\\musicalpitch *{([0-9 -]+)}", + "\\\\musicalpitch #'(\\1)", str) + if re.search ('\\\\notenames',str): + error_file.write ('\n') + error_file.write (NOT_SMART % "new \\notenames format") + error_file.write ('\n') + return str + +conversions.append (((1,3,38), conv, '\musicalpitch { a b c } -> #\'(a b c)')) + + +def conv (str): + def replace (match): + return '\\key %s;' % string.lower (match.group (1)) + + str = re.sub ("\\\\key ([^;]+);", replace, str) + return str + +conversions.append (((1,3,39), conv, '\\key A ; ->\\key a;')) + + +def conv (str): + if re.search ('\\[:',str): + error_file.write ('\n') + error_file.write (NOT_SMART % "new tremolo format") + error_file.write ('\n') + return str + +conversions.append (((1,3,41), conv, + '[:16 c4 d4 ] -> \\repeat "tremolo" 2 { c16 d16 }')) + + +def conv (str): + str = re.sub ('Staff_margin_engraver' , 'Instrument_name_engraver', str) + return str + +conversions.append (((1,3,42), conv, + 'Staff_margin_engraver deprecated, use Instrument_name_engraver')) + + +def conv (str): + str = re.sub ('note[hH]eadStyle\\s*=\\s*"?(\\w+)"?' , "noteHeadStyle = #'\\1", str) + return str + +conversions.append (((1,3,49), conv, + 'noteHeadStyle value: string -> symbol')) + + +def conv (str): + if re.search ('\\\\keysignature', str): + error_file.write ('\n') + error_file.write (NOT_SMART % "new tremolo format") + error_file.write ('\n') + return str + + +conversions.append (((1,3,58), conv, + 'noteHeadStyle value: string -> symbol')) + + +def conv (str): + str = re.sub (r"""\\key *([a-z]+) *;""", r"""\\key \1 \major;""",str); + return str +conversions.append (((1,3,59), conv, + '\key X ; -> \key X major; ')) + + +def conv (str): + str = re.sub (r'latexheaders *= *"\\\\input ', + 'latexheaders = "', + str) + return str +conversions.append (((1,3,68), conv, 'latexheaders = "\\input global" -> latexheaders = "global"')) # TODO: lots of other syntax change should be done here as well -if 1: - def conv (str): - str = re.sub ('basicCollisionProperties', 'NoteCollision', str) - str = re.sub ('basicVoltaSpannerProperties' , "VoltaBracket", str) - str = re.sub ('basicKeyProperties' , "KeySignature", str) - str = re.sub ('basicClefItemProperties' ,"Clef", str) +def conv (str): + str = re.sub ('basicCollisionProperties', 'NoteCollision', str) + str = re.sub ('basicVoltaSpannerProperties' , "VoltaBracket", str) + str = re.sub ('basicKeyProperties' , "KeySignature", str) + str = re.sub ('basicClefItemProperties' ,"Clef", str) - str = re.sub ('basicLocalKeyProperties' ,"Accidentals", str) - str = re.sub ('basicMarkProperties' ,"Accidentals", str) - str = re.sub ('basic([A-Za-z_]+)Properties', '\\1', str) - str = re.sub ('Repeat_engraver' ,'Volta_engraver', str) - return str + str = re.sub ('basicLocalKeyProperties' ,"Accidentals", str) + str = re.sub ('basicMarkProperties' ,"Accidentals", str) + str = re.sub ('basic([A-Za-z_]+)Properties', '\\1', str) - conversions.append (((1,3,92), conv, 'basicXXXProperties -> XXX, Repeat_engraver -> Volta_engraver')) + str = re.sub ('Repeat_engraver' ,'Volta_engraver', str) + return str -if 1: - def conv (str): - # Ugh, but meaning of \stemup changed too - # maybe we should do \stemup -> \stemUp\slurUp\tieUp ? - str = re.sub ('\\\\stemup', '\\\\stemUp', str) - str = re.sub ('\\\\stemdown', '\\\\stemDown', str) - str = re.sub ('\\\\stemboth', '\\\\stemBoth', str) +conversions.append (((1,3,92), conv, 'basicXXXProperties -> XXX, Repeat_engraver -> Volta_engraver')) - str = re.sub ('\\\\slurup', '\\\\slurUp', str) - str = re.sub ('\\\\slurboth', '\\\\slurBoth', str) - str = re.sub ('\\\\slurdown', '\\\\slurDown', str) - str = re.sub ('\\\\slurdotted', '\\\\slurDotted', str) - str = re.sub ('\\\\slurnormal', '\\\\slurNoDots', str) - str = re.sub ('\\\\shiftoff', '\\\\shiftOff', str) - str = re.sub ('\\\\shifton', '\\\\shiftOn', str) - str = re.sub ('\\\\shiftonn', '\\\\shiftOnn', str) - str = re.sub ('\\\\shiftonnn', '\\\\shiftOnnn', str) +def conv (str): + # Ugh, but meaning of \stemup changed too + # maybe we should do \stemup -> \stemUp\slurUp\tieUp ? + str = re.sub ('\\\\stemup', '\\\\stemUp', str) + str = re.sub ('\\\\stemdown', '\\\\stemDown', str) + str = re.sub ('\\\\stemboth', '\\\\stemBoth', str) - str = re.sub ('\\\\onevoice', '\\\\oneVoice', str) - str = re.sub ('\\\\voiceone', '\\\\voiceOne', str) - str = re.sub ('\\\\voicetwo', '\\\\voiceTwo', str) - str = re.sub ('\\\\voicethree', '\\\\voiceThree', str) - str = re.sub ('\\\\voicefour', '\\\\voiceFour', str) + str = re.sub ('\\\\slurup', '\\\\slurUp', str) + str = re.sub ('\\\\slurboth', '\\\\slurBoth', str) + str = re.sub ('\\\\slurdown', '\\\\slurDown', str) + str = re.sub ('\\\\slurdotted', '\\\\slurDotted', str) + str = re.sub ('\\\\slurnormal', '\\\\slurNoDots', str) - # I don't know exactly when these happened... - # ugh, we loose context setting here... - str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\stemUp\\\\slurUp\\\\tieUp', str) - str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\stemDown\\\\slurDown\\\\tieDown', str) - str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\stemBoth\\\\slurBoth\\\\tieBoth', str) + str = re.sub ('\\\\shiftoff', '\\\\shiftOff', str) + str = re.sub ('\\\\shifton', '\\\\shiftOn', str) + str = re.sub ('\\\\shiftonn', '\\\\shiftOnn', str) + str = re.sub ('\\\\shiftonnn', '\\\\shiftOnnn', str) - str = re.sub ('verticalDirection[^=]*= *#?"?(1|(\\\\up))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #1', str) - str = re.sub ('verticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #-1', str) - str = re.sub ('verticalDirection[^=]*= *#?"?(0|(\\\\center))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #0', str) + str = re.sub ('\\\\onevoice', '\\\\oneVoice', str) + str = re.sub ('\\\\voiceone', '\\\\voiceOne', str) + str = re.sub ('\\\\voicetwo', '\\\\voiceTwo', str) + str = re.sub ('\\\\voicethree', '\\\\voiceThree', str) + str = re.sub ('\\\\voicefour', '\\\\voiceFour', str) - str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\\\1Up', str) - str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\\\1Down', str) - str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\\\1Both', str) + # I don't know exactly when these happened... + # ugh, we loose context setting here... + str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\stemUp\\\\slurUp\\\\tieUp', str) + str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\stemDown\\\\slurDown\\\\tieDown', str) + str = re.sub ('\\\\property *[^ ]*verticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\stemBoth\\\\slurBoth\\\\tieBoth', str) - # (lacks capitalisation slur -> Slur) - str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\1 \\\\override #\'direction = #1', str) - str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\1 \\override #\'direction = #-1', str) - str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\1 \\\\override #\'direction = #0', str) + str = re.sub ('verticalDirection[^=]*= *#?"?(1|(\\\\up))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #1', str) + str = re.sub ('verticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #-1', str) + str = re.sub ('verticalDirection[^=]*= *#?"?(0|(\\\\center))"?', 'Stem \\\\override #\'direction = #0\nSlur \\\\override #\'direction = #0\n Tie \\\\override #\'direction = #0', str) - ## dynamic.. - str = re.sub ('\\\\property *[^ .]*[.]?dynamicDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\dynamicUp', str) - str = re.sub ('\\\\property *[^ .]*[.]?dyn[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\dynamicDown', str) - str = re.sub ('\\\\property *[^ .]*[.]?dyn[^=]*= *#?"?(0|(\\\\center))"?', '\\\\dynamicBoth', str) + str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\\\1Up', str) + str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\\\1Down', str) + str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\\\1Both', str) - str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)Dash[^=]*= *#?"?(0|(""))"?', '\\\\\\1NoDots', str) - str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)Dash[^=]*= *#?"?([1-9]+)"?', '\\\\\\1Dotted', str) + # (lacks capitalisation slur -> Slur) + str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\1 \\\\override #\'direction = #1', str) + str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\1 \\override #\'direction = #-1', str) + str = re.sub ('([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\1 \\\\override #\'direction = #0', str) - str = re.sub ('\\\\property *[^ .]*[.]?noAutoBeaming[^=]*= *#?"?(0|(""))"?', '\\\\autoBeamOn', str) - str = re.sub ('\\\\property *[^ .]*[.]?noAutoBeaming[^=]*= *#?"?([1-9]+)"?', '\\\\autoBeamOff', str) + ## dynamic.. + str = re.sub ('\\\\property *[^ .]*[.]?dynamicDirection[^=]*= *#?"?(1|(\\\\up))"?', '\\\\dynamicUp', str) + str = re.sub ('\\\\property *[^ .]*[.]?dyn[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\dynamicDown', str) + str = re.sub ('\\\\property *[^ .]*[.]?dyn[^=]*= *#?"?(0|(\\\\center))"?', '\\\\dynamicBoth', str) + str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)Dash[^=]*= *#?"?(0|(""))"?', '\\\\\\1NoDots', str) + str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)Dash[^=]*= *#?"?([1-9]+)"?', '\\\\\\1Dotted', str) + str = re.sub ('\\\\property *[^ .]*[.]?noAutoBeaming[^=]*= *#?"?(0|(""))"?', '\\\\autoBeamOn', str) + str = re.sub ('\\\\property *[^ .]*[.]?noAutoBeaming[^=]*= *#?"?([1-9]+)"?', '\\\\autoBeamOff', str) - return str - conversions.append (((1,3,93), conv, - 'property definiton case (eg. onevoice -> oneVoice)')) + return str -if 1: - def conv (str): - str = re.sub ('ChordNames*', 'ChordNames', str) - if re.search ('\\\\textscript "[^"]* *"[^"]*"', str): - error_file.write ('\n') - error_file.write (NOT_SMART % "new \\textscript markup text") - error_file.write ('\n') +conversions.append (((1,3,93), conv, + 'property definiton case (eg. onevoice -> oneVoice)')) - str = re.sub ('\\textscript +("[^"]*")', '\\textscript #\\1', str) - return str - conversions.append (((1,3,97), conv, 'ChordName -> ChordNames')) +def conv (str): + str = re.sub ('ChordNames*', 'ChordNames', str) + if re.search ('\\\\textscript "[^"]* *"[^"]*"', str): + error_file.write ('\n') + error_file.write (NOT_SMART % "new \\textscript markup text") + error_file.write ('\n') + + str = re.sub ('\\textscript +("[^"]*")', '\\textscript #\\1', str) + + return str + +conversions.append (((1,3,97), conv, 'ChordName -> ChordNames')) # TODO: add lots of these -if 1: - def conv (str): - str = re.sub ('\\\\property *"?Voice"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Voice.TextScript \\\\set #\'font-style = #\'\\1', str) - str = re.sub ('\\\\property *"?Lyrics"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Lyrics.LyricText \\\\set #\'font-style = #\'\\1', str) - str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?timeSignatureStyle"? *= *"([^"]*)"', '\\\\property \\1.TimeSignature \\\\override #\'style = #\'\\2', str) +def conv (str): + str = re.sub ('\\\\property *"?Voice"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Voice.TextScript \\\\set #\'font-style = #\'\\1', str) + str = re.sub ('\\\\property *"?Lyrics"? *[.] *"?textStyle"? *= *"([^"]*)"', '\\\\property Lyrics.LyricText \\\\set #\'font-style = #\'\\1', str) - str = re.sub ('"?timeSignatureStyle"? *= *#?""', 'TimeSignature \\\\override #\'style = ##f', str) + str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?timeSignatureStyle"? *= *"([^"]*)"', '\\\\property \\1.TimeSignature \\\\override #\'style = #\'\\2', str) - str = re.sub ('"?timeSignatureStyle"? *= *#?"([^"]*)"', 'TimeSignature \\\\override #\'style = #\'\\1', str) + str = re.sub ('"?timeSignatureStyle"? *= *#?""', 'TimeSignature \\\\override #\'style = ##f', str) - str = re.sub ('#\'style *= #*"([^"])"', '#\'style = #\'\\1', str) + str = re.sub ('"?timeSignatureStyle"? *= *#?"([^"]*)"', 'TimeSignature \\\\override #\'style = #\'\\1', str) - str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?horizontalNoteShift"? *= *"?#?([-0-9]+)"?', '\\\\property \\1.NoteColumn \\\\override #\'horizontal-shift = #\\2', str) + str = re.sub ('#\'style *= #*"([^"])"', '#\'style = #\'\\1', str) - # ugh - str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *""', '\\\\property \\1.Stem \\\\override #\'flag-style = ##f', str) + str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?horizontalNoteShift"? *= *"?#?([-0-9]+)"?', '\\\\property \\1.NoteColumn \\\\override #\'horizontal-shift = #\\2', str) - str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *"([^"]*)"', '\\\\property \\1.Stem \\\\override #\'flag-style = #\'\\2', str) - return str + # ugh + str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *""', '\\\\property \\1.Stem \\\\override #\'flag-style = ##f', str) - conversions.append (((1,3,98), conv, 'CONTEXT.textStyle -> GROB.#font-style ')) + str = re.sub ('\\\\property *"?([^.]+)"? *[.] *"?flagStyle"? *= *"([^"]*)"', '\\\\property \\1.Stem \\\\override #\'flag-style = #\'\\2', str) + return str -if 1: - def conv (str): - str = re.sub ('"?beamAutoEnd_([0-9]*)"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(end 1 \\1 * *) = \\2', str) - str = re.sub ('"?beamAutoBegin_([0-9]*)"? *= *(#\\([^)]*\))', 'autoBeamSettings \\push #\'(begin 1 \\1 * *) = \\2', str) - str = re.sub ('"?beamAutoEnd"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(end * * * *) = \\1', str) - str = re.sub ('"?beamAutoBegin"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(begin * * * *) = \\1', str) +conversions.append (((1,3,98), conv, 'CONTEXT.textStyle -> GROB.#font-style ')) - return str +def conv (str): + str = re.sub ('"?beamAutoEnd_([0-9]*)"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(end 1 \\1 * *) = \\2', str) + str = re.sub ('"?beamAutoBegin_([0-9]*)"? *= *(#\\([^)]*\))', 'autoBeamSettings \\push #\'(begin 1 \\1 * *) = \\2', str) + str = re.sub ('"?beamAutoEnd"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(end * * * *) = \\1', str) + str = re.sub ('"?beamAutoBegin"? *= *(#\\([^)]*\\))', 'autoBeamSettings \\push #\'(begin * * * *) = \\1', str) - conversions.append (((1,3,102), conv, 'beamAutoEnd -> autoBeamSettings \\push (end * * * *)')) + return str -if 1: - def conv (str): - str = re.sub ('\\\\push', '\\\\override', str) - str = re.sub ('\\\\pop', '\\\\revert', str) +conversions.append (((1,3,102), conv, 'beamAutoEnd -> autoBeamSettings \\push (end * * * *)')) - return str - conversions.append (((1,3,111), conv, '\\push -> \\override, \\pop -> \\revert')) -if 1: - def conv (str): - str = re.sub ('LyricVoice', 'LyricsVoice', str) - # old fix - str = re.sub ('Chord[Nn]ames*.Chord[Nn]ames*', 'ChordNames.ChordName', str) - str = re.sub ('Chord[Nn]ames([ \t\n]+\\\\override)', 'ChordName\\1', str) - return str +def conv (str): + str = re.sub ('\\\\push', '\\\\override', str) + str = re.sub ('\\\\pop', '\\\\revert', str) - conversions.append (((1,3,113), conv, 'LyricVoice -> LyricsVoice')) + return str + +conversions.append (((1,3,111), conv, '\\push -> \\override, \\pop -> \\revert')) + + +def conv (str): + str = re.sub ('LyricVoice', 'LyricsVoice', str) + # old fix + str = re.sub ('Chord[Nn]ames*.Chord[Nn]ames*', 'ChordNames.ChordName', str) + str = re.sub ('Chord[Nn]ames([ \t\n]+\\\\override)', 'ChordName\\1', str) + return str -def regularize_id (str): - s = '' - lastx = '' - for x in str: - if x == '_': +conversions.append (((1,3,113), conv, 'LyricVoice -> LyricsVoice')) + +def conv (str): + def regularize_id (str): + s = '' + lastx = '' + for x in str: + if x == '_': + lastx = x + continue + elif x in string.digits: + x = chr(ord (x) - ord ('0') +ord ('A')) + elif x not in string.letters: + x = 'x' + elif x in string.lowercase and lastx == '_': + x = string.upper (x) + s = s + x lastx = x - continue - elif x in string.digits: - x = chr(ord (x) - ord ('0') +ord ('A')) - elif x not in string.letters: - x = 'x' - elif x in string.lowercase and lastx == '_': - x = string.upper (x) - s = s + x - lastx = x - return s - -if 1: - def conv (str): + return s def regularize_dollar_reference (match): return regularize_id (match.group (1)) @@ -636,727 +634,783 @@ if 1: str = re.sub ('\n([^ \t\n]+)[ \t]*= *', regularize_assignment, str) return str - conversions.append (((1,3,117), conv, 'identifier names: $!foo_bar_123 -> xfooBarABC')) +conversions.append (((1,3,117), conv, 'identifier names: $!foo_bar_123 -> xfooBarABC')) -if 1: - def conv (str): - def regularize_paper (match): - return regularize_id (match.group (1)) - str = re.sub ('(paper_[a-z]+)', regularize_paper, str) - str = re.sub ('sustainup', 'sustainUp', str) - str = re.sub ('nobreak', 'noBreak', str) - str = re.sub ('sustaindown', 'sustainDown', str) - str = re.sub ('sostenutoup', 'sostenutoUp', str) - str = re.sub ('sostenutodown', 'sostenutoDown', str) - str = re.sub ('unachorda', 'unaChorda', str) - str = re.sub ('trechorde', 'treChorde', str) +def conv (str): + def regularize_paper (match): + return regularize_id (match.group (1)) - return str + str = re.sub ('(paper_[a-z]+)', regularize_paper, str) + str = re.sub ('sustainup', 'sustainUp', str) + str = re.sub ('nobreak', 'noBreak', str) + str = re.sub ('sustaindown', 'sustainDown', str) + str = re.sub ('sostenutoup', 'sostenutoUp', str) + str = re.sub ('sostenutodown', 'sostenutoDown', str) + str = re.sub ('unachorda', 'unaChorda', str) + str = re.sub ('trechorde', 'treChorde', str) - conversions.append (((1,3,120), conv, 'paper_xxx -> paperXxxx, pedalup -> pedalUp.')) + return str -if 1: - def conv (str): - str = re.sub ('drarnChords', 'chordChanges', str) - str = re.sub ('\\musicalpitch', '\\pitch', str) - return str +conversions.append (((1,3,120), conv, 'paper_xxx -> paperXxxx, pedalup -> pedalUp.')) - conversions.append (((1,3,122), conv, 'drarnChords -> chordChanges, \\musicalpitch -> \\pitch')) -if 1: - def conv (str): - str = re.sub ('ly-([sg])et-elt-property', 'ly-\\1et-grob-property', str) - return str +def conv (str): + str = re.sub ('drarnChords', 'chordChanges', str) + str = re.sub ('\\musicalpitch', '\\pitch', str) + return str - conversions.append (((1,3,136), conv, 'ly-X-elt-property -> ly-X-grob-property')) +conversions.append (((1,3,122), conv, 'drarnChords -> chordChanges, \\musicalpitch -> \\pitch')) -if 1: - def conv (str): - str = re.sub ('point-and-click +#t', 'point-and-click line-column-location', str) - return str - conversions.append (((1,3,138), conv, 'point-and-click argument changed to procedure.')) +def conv (str): + str = re.sub ('ly-([sg])et-elt-property', 'ly-\\1et-grob-property', str) + return str -if 1: - def conv (str): - str = re.sub ('followThread', 'followVoice', str) - str = re.sub ('Thread.FollowThread', 'Voice.VoiceFollower', str) - str = re.sub ('FollowThread', 'VoiceFollower', str) - return str +conversions.append (((1,3,136), conv, 'ly-X-elt-property -> ly-X-grob-property')) - conversions.append (((1,3,138), conv, 'followThread -> followVoice.')) -if 1: - def conv (str): - str = re.sub ('font-point-size', 'font-design-size', str) - return str +def conv (str): + str = re.sub ('point-and-click +#t', 'point-and-click line-column-location', str) + return str - conversions.append (((1,3,139), conv, 'font-point-size -> font-design-size.')) +conversions.append (((1,3,138), conv, 'point-and-click argument changed to procedure.')) -if 1: - def conv (str): - str = re.sub ('([a-zA-Z]*)NoDots', '\\1Solid', str) - return str - conversions.append (((1,3,141), conv, 'xNoDots -> xSolid')) +def conv (str): + str = re.sub ('followThread', 'followVoice', str) + str = re.sub ('Thread.FollowThread', 'Voice.VoiceFollower', str) + str = re.sub ('FollowThread', 'VoiceFollower', str) + return str -if 1: - def conv (str): - str = re.sub ('([Cc])hord([ea])', '\\1ord\\2', str) - return str +conversions.append (((1,3,138), conv, 'followThread -> followVoice.')) - conversions.append (((1,3,144), conv, 'Chorda -> Corda')) +def conv (str): + str = re.sub ('font-point-size', 'font-design-size', str) + return str -if 1: - def conv (str): - str = re.sub ('([A-Za-z]+)MinimumVerticalExtent', 'MinimumV@rticalExtent', str) - str = re.sub ('([A-Za-z]+)ExtraVerticalExtent', 'ExtraV@rticalExtent', str) - str = re.sub ('([A-Za-z]+)VerticalExtent', 'VerticalExtent', str) - str = re.sub ('ExtraV@rticalExtent', 'ExtraVerticalExtent', str) - str = re.sub ('MinimumV@rticalExtent', 'MinimumVerticalExtent', str) - return str +conversions.append (((1,3,139), conv, 'font-point-size -> font-design-size.')) - conversions.append (((1,3,145), conv, - 'ContextNameXxxxVerticalExtent -> XxxxVerticalExtent')) -if 1: - def conv (str): - str = re.sub ('\\\\key[ \t]*;', '\\key \\default;', str) - str = re.sub ('\\\\mark[ \t]*;', '\\mark \\default;', str) +def conv (str): + str = re.sub ('([a-zA-Z]*)NoDots', '\\1Solid', str) + return str - # Make sure groups of more than one ; have space before - # them, so that non of them gets removed by next rule - str = re.sub ("([^ \n\t;]);(;+)", "\\1 ;\\2", str) +conversions.append (((1,3,141), conv, 'xNoDots -> xSolid')) - # Only remove ; that are not after spaces, # or ; - # Otherwise we interfere with Scheme comments, - # which is badbadbad. - str = re.sub ("([^ \t;#]);", "\\1", str) - return str - conversions.append (((1,3,146), conv, 'semicolons removed')) +def conv (str): + str = re.sub ('([Cc])hord([ea])', '\\1ord\\2', str) + return str -if 1: - def conv (str): - str = re.sub ('default-neutral-direction', 'neutral-direction',str) - return str - conversions.append (((1,3,147), conv, 'default-neutral-direction -> neutral-direction')) +conversions.append (((1,3,144), conv, 'Chorda -> Corda')) -if 1: - def conv (str): - str = re.sub ('\(align', '(axis', str) - str = re.sub ('\(rows', '(columns', str) - return str - conversions.append (((1,3,148), conv, '"(align" -> "(axis", "(rows" -> "(columns"')) -if 1: - def conv (str): - str = re.sub ('SystemStartDelimiter', 'systemStartDelimiter', str) - return str - conversions.append (((1,5,33), conv, 'SystemStartDelimiter -> systemStartDelimiter')) +def conv (str): + str = re.sub ('([A-Za-z]+)MinimumVerticalExtent', 'MinimumV@rticalExtent', str) + str = re.sub ('([A-Za-z]+)ExtraVerticalExtent', 'ExtraV@rticalExtent', str) + str = re.sub ('([A-Za-z]+)VerticalExtent', 'VerticalExtent', str) + str = re.sub ('ExtraV@rticalExtent', 'ExtraVerticalExtent', str) + str = re.sub ('MinimumV@rticalExtent', 'MinimumVerticalExtent', str) + return str -if 1: - def conv (str): - str = re.sub ('arithmetic-multiplier', 'spacing-increment', str) - str = re.sub ('arithmetic-basicspace', 'shortest-duration-space', str) - return str +conversions.append (((1,3,145), conv, +'ContextNameXxxxVerticalExtent -> XxxxVerticalExtent')) - conversions.append (((1,5,38), conv, 'SystemStartDelimiter -> systemStartDelimiter')) - - -if 1: - def conv (str): - - def func(match): - break_dict = { - "Instrument_name": "instrument-name", - "Left_edge_item": "left-edge", - "Span_bar": "span-bar", - "Breathing_sign": "breathing-sign", - "Staff_bar": "staff-bar", - "Clef_item": "clef", - "Key_item": "key-signature", - "Time_signature": "time-signature", - "Custos": "custos" - } - props = match.group (1) - for (k,v) in break_dict.items(): - props = re.sub (k, v, props) - return "breakAlignOrder = #'(%s)" % props - - str = re.sub ("breakAlignOrder *= *#'\\(([a-z_\n\tA-Z ]+)\\)", - func, str) - return str - # 40 ? - conversions.append (((1,5,40), conv, 'breakAlignOrder property names')) +def conv (str): + str = re.sub ('\\\\key[ \t]*;', '\\key \\default;', str) + str = re.sub ('\\\\mark[ \t]*;', '\\mark \\default;', str) + # Make sure groups of more than one ; have space before + # them, so that non of them gets removed by next rule + str = re.sub ("([^ \n\t;]);(;+)", "\\1 ;\\2", str) -if 1: - def conv (str): - str = re.sub ('noAutoBeaming *= *##f', 'autoBeaming = ##t', str) - str = re.sub ('noAutoBeaming *= *##t', 'autoBeaming = ##f', str) - return str + # Only remove ; that are not after spaces, # or ; + # Otherwise we interfere with Scheme comments, + # which is badbadbad. + str = re.sub ("([^ \t;#]);", "\\1", str) - conversions.append (((1,5,49), conv, 'noAutoBeaming -> autoBeaming')) + return str +conversions.append (((1,3,146), conv, 'semicolons removed')) -if 1: - def conv (str): - str = re.sub ('tuplet-bracket-visibility', 'bracket-visibility', str) - str = re.sub ('tuplet-number-visibility', 'number-visibility', str) - return str - conversions.append (((1,5,52), conv, 'tuplet-X-visibility -> X-visibility')) +def conv (str): + str = re.sub ('default-neutral-direction', 'neutral-direction',str) + return str +conversions.append (((1,3,147), conv, 'default-neutral-direction -> neutral-direction')) -if 1: - def conv (str): - str = re.sub ('Pitch::transpose', 'ly-transpose-pitch', str) - return str +def conv (str): + str = re.sub ('\(align', '(axis', str) + str = re.sub ('\(rows', '(columns', str) + return str +conversions.append (((1,3,148), conv, '"(align" -> "(axis", "(rows" -> "(columns"')) - conversions.append (((1,5,56), conv, 'Pitch::transpose -> ly-transpose-pitch')) -if 1: - def conv (str): - str = re.sub ('textNonEmpty *= *##t', "TextScript \\set #'no-spacing-rods = ##f", str) - str = re.sub ('textNonEmpty *= *##f', "TextScript \\set #'no-spacing-rods = ##t", str) - return str - conversions.append (((1,5,58), conv, 'deprecate textNonEmpty')) +def conv (str): + str = re.sub ('SystemStartDelimiter', 'systemStartDelimiter', str) + return str +conversions.append (((1,5,33), conv, 'SystemStartDelimiter -> systemStartDelimiter')) -if 1: - def conv (str): - str = re.sub ('MinimumVerticalExtent', 'minimumV@rticalExtent', str) - str = re.sub ('minimumVerticalExtent', 'minimumV@rticalExtent', str) - str = re.sub ('ExtraVerticalExtent', 'extraV@rticalExtent', str) - str = re.sub ('extraVerticalExtent', 'extraV@rticalExtent', str) - str = re.sub ('VerticalExtent', 'verticalExtent', str) - str = re.sub ('extraV@rticalExtent', 'extraVerticalExtent', str) - str = re.sub ('minimumV@rticalExtent', 'minimumVerticalExtent', str) - return str +def conv (str): + str = re.sub ('arithmetic-multiplier', 'spacing-increment', str) + str = re.sub ('arithmetic-basicspace', 'shortest-duration-space', str) + return str - conversions.append (((1,5,59), conv, - 'XxxxVerticalExtent -> xxxVerticalExtent')) +conversions.append (((1,5,38), conv, 'SystemStartDelimiter -> systemStartDelimiter')) -if 1: - def conv (str): - str = re.sub ('visibility-lambda', 'break-visibility', str) - return str - conversions.append (((1,5,62), conv, - 'visibility-lambda -> break-visibility')) +def conv (str): -if 1: - def conv (str): - if re.search (r'\addlyrics',str) \ - and re.search ('automaticMelismata', str) == None: - error_file.write ('\n') - error_file.write (NOT_SMART % "automaticMelismata; turned on by default since 1.5.67.") - error_file.write ('\n') - raise FatalConversionError () - return str + def func(match): + break_dict = { + "Instrument_name": "instrument-name", + "Left_edge_item": "left-edge", + "Span_bar": "span-bar", + "Breathing_sign": "breathing-sign", + "Staff_bar": "staff-bar", + "Clef_item": "clef", + "Key_item": "key-signature", + "Time_signature": "time-signature", + "Custos": "custos" + } + props = match.group (1) + for (k,v) in break_dict.items(): + props = re.sub (k, v, props) + return "breakAlignOrder = #'(%s)" % props - conversions.append (((1,5,67), conv, - 'automaticMelismata turned on by default')) + str = re.sub ("breakAlignOrder *= *#'\\(([a-z_\n\tA-Z ]+)\\)", + func, str) + return str -if 1: - def conv (str): - str = re.sub ('ly-set-grob-property([^!])', 'ly-set-grob-property!\1', str) - str = re.sub ('ly-set-mus-property([^!])', 'ly-set-mus-property!\1', str) - return str +# 40 ? +conversions.append (((1,5,40), conv, 'breakAlignOrder property names')) - conversions.append (((1,5,68), conv, 'ly-set-X-property -> ly-set-X-property!')) -if 1: - def conv (str): - str = re.sub ('extent-X', 'X-extent', str) - str = re.sub ('extent-Y', 'Y-extent', str) - return str - conversions.append (((1,5,71), conv, 'extent-[XY] -> [XY]-extent')) +def conv (str): + str = re.sub ('noAutoBeaming *= *##f', 'autoBeaming = ##t', str) + str = re.sub ('noAutoBeaming *= *##t', 'autoBeaming = ##f', str) + return str +conversions.append (((1,5,49), conv, 'noAutoBeaming -> autoBeaming')) -if 1: - def conv (str): - str = re.sub ("""#\(set! +point-and-click +line-column-location\)""", - """#(set-point-and-click! \'line-column)""", str) - str = re.sub ("""#\(set![ \t]+point-and-click +line-location\)""", - '#(set-point-and-click! \'line)', str) - str = re.sub ('#\(set! +point-and-click +#f\)', - '#(set-point-and-click! \'none)', str) - return str - conversions.append (((1,5,72), conv, 'set! point-and-click -> set-point-and-click!')) +def conv (str): + str = re.sub ('tuplet-bracket-visibility', 'bracket-visibility', str) + str = re.sub ('tuplet-number-visibility', 'number-visibility', str) + return str +conversions.append (((1,5,52), conv, 'tuplet-X-visibility -> X-visibility')) -if 1: - def conv (str): - str = re.sub ('flag-style', 'stroke-style', str) - str = re.sub (r"""Stem([ ]+)\\override #'style""", r"""Stem \\override #'flag-style""", str); - str = re.sub (r"""Stem([ ]+)\\set([ ]+)#'style""", r"""Stem \\set #'flag-style""", str); - return str - conversions.append (((1,6,5), conv, 'Stems: flag-style -> stroke-style; style -> flag-style')) +def conv (str): + str = re.sub ('Pitch::transpose', 'ly-transpose-pitch', str) + return str -if 1: - def subst_req_name (match): - return "(make-music-by-name \'%sEvent)" % regularize_id (match.group(1)) +conversions.append (((1,5,56), conv, 'Pitch::transpose -> ly-transpose-pitch')) - def conv (str): - str = re.sub ('\\(ly-make-music *\"([A-Z][a-z_]+)_req\"\\)', subst_req_name, str) - str = re.sub ('Request_chord', 'EventChord', str) - return str - conversions.append (((1,7,1), conv, 'ly-make-music foo_bar_req -> make-music-by-name FooBarEvent')) +def conv (str): + str = re.sub ('textNonEmpty *= *##t', "TextScript \\set #'no-spacing-rods = ##f", str) + str = re.sub ('textNonEmpty *= *##f', "TextScript \\set #'no-spacing-rods = ##t", str) + return str +conversions.append (((1,5,58), conv, 'deprecate textNonEmpty')) -if 1: - spanner_subst ={ - "text" : 'TextSpanEvent', - "decrescendo" : 'DecrescendoEvent', - "crescendo" : 'CrescendoEvent', - "Sustain" : 'SustainPedalEvent', - "slur" : 'SlurEvent', - "UnaCorda" : 'UnaCordaEvent', - "Sostenuto" : 'SostenutoEvent', - } - def subst_ev_name (match): - stype = 'STOP' - if re.search ('start', match.group(1)): - stype= 'START' - - mtype = spanner_subst[match.group(2)] - return "(make-span-event '%s %s)" % (mtype , stype) - - def subst_definition_ev_name(match): - return ' = #%s' % subst_ev_name (match) - def subst_inline_ev_name (match): - s = subst_ev_name (match) - return '#(ly-export %s)' % s - def subst_csp_definition (match): - return ' = #(make-event-chord (list %s))' % subst_ev_name (match) - def subst_csp_inline (match): - return '#(ly-export (make-event-chord (list %s)))' % subst_ev_name (match) - - def conv (str): - str = re.sub (r' *= *\\spanrequest *([^ ]+) *"([^"]+)"', subst_definition_ev_name, str) - str = re.sub (r'\\spanrequest *([^ ]+) *"([^"]+)"', subst_inline_ev_name, str) - str = re.sub (r' *= *\\commandspanrequest *([^ ]+) *"([^"]+)"', subst_csp_definition, str) - str = re.sub (r'\\commandspanrequest *([^ ]+) *"([^"]+)"', subst_csp_inline, str) - str = re.sub (r'ly-id ', 'ly-import ', str) - - str = re.sub (r' *= *\\script "([^"]+)"', ' = #(make-articulation "\\1")', str) - str = re.sub (r'\\script "([^"]+)"', '#(ly-export (make-articulation "\\1"))', str) - return str - conversions.append (((1,7,2), conv, '\\spanrequest -> #(make-span-event .. ), \script -> #(make-articulation .. )')) - -if 1: - def conv(str): - str = re.sub (r'\(ly-', '(ly:', str) - - changed = [ - r'duration\?', - r'font-metric\?', - r'molecule\?', - r'moment\?', - r'music\?', - r'pitch\?', - 'make-duration', - 'music-duration-length', - 'duration-log', - 'duration-dotcount', - 'intlog2', - 'duration-factor', - 'transpose-key-alist', - 'get-system', - 'get-broken-into', - 'get-original', - 'set-point-and-click!', - 'make-moment', - 'make-pitch', - 'pitch-octave', - 'pitch-alteration', - 'pitch-notename', - 'pitch-semitones', - r'pitch<\?', - r'dir\?', - 'music-duration-compress', - 'set-point-and-click!' - ] - - origre = r'\b(%s)' % string.join (changed, '|') - - str = re.sub (origre, r'ly:\1',str) - str = re.sub ('set-point-and-click!', 'set-point-and-click', str) - return str +def conv (str): + str = re.sub ('MinimumVerticalExtent', 'minimumV@rticalExtent', str) + str = re.sub ('minimumVerticalExtent', 'minimumV@rticalExtent', str) + str = re.sub ('ExtraVerticalExtent', 'extraV@rticalExtent', str) + str = re.sub ('extraVerticalExtent', 'extraV@rticalExtent', str) + str = re.sub ('VerticalExtent', 'verticalExtent', str) + str = re.sub ('extraV@rticalExtent', 'extraVerticalExtent', str) + str = re.sub ('minimumV@rticalExtent', 'minimumVerticalExtent', str) + return str - conversions.append (((1,7,3), conv, 'ly- -> ly:')) +conversions.append (((1,5,59), conv, +'XxxxVerticalExtent -> xxxVerticalExtent')) -if 1: - def conv(str): - if re.search ('new-chords-done',str): - return str - str = re.sub (r'<<', '< <', str) - str = re.sub (r'>>', '> >', str) - return str +def conv (str): + str = re.sub ('visibility-lambda', 'break-visibility', str) + return str - conversions.append (((1,7,4), conv, '<< >> -> < < > >')) +conversions.append (((1,5,62), conv, +'visibility-lambda -> break-visibility')) -if 1: - def conv(str): - str = re.sub (r"\\transpose", r"\\transpose c'", str) - str = re.sub (r"\\transpose c' *([a-z]+)'", r"\\transpose c \1", str) - return str - conversions.append (((1,7,5), conv, '\\transpose TO -> \\transpose FROM TO')) - -if 1: - def conv(str): - kws = ['arpeggio', - 'sustainDown', - 'sustainUp', - 'f', - 'p', - 'pp', - 'ppp', - 'fp', - 'ff', - 'mf', - 'mp', - 'sfz', - ] - - origstr = string.join (kws, '|') - str = re.sub (r'([^_^-])\\(%s)\b' % origstr, r'\1-\\\2', str) - return str - conversions.append (((1,7,6), conv, 'note\\script -> note-\script')) -if 1: - def conv(str): - str = re.sub (r"\\property *ChordNames *\. *ChordName *\\(set|override) *#'style *= *#('[a-z]+)", - r"#(set-chord-name-style \2)", str) - str = re.sub (r"\\property *ChordNames *\. *ChordName *\\revert *#'style", - r"", str) - return str - conversions.append (((1,7,10), conv, "\property ChordName #'style -> #(set-chord-name-style 'style)")) +def conv (str): + if re.search (r'\addlyrics',str) \ + and re.search ('automaticMelismata', str) == None: + error_file.write ('\n') + error_file.write (NOT_SMART % "automaticMelismata; turned on by default since 1.5.67.") + error_file.write ('\n') + raise FatalConversionError () + return str +conversions.append (((1,5,67), conv, + 'automaticMelismata turned on by default')) -if 1: - def conv(str): - str = re.sub (r"ly:transpose-pitch", "ly:pitch-transpose", str) +def conv (str): + str = re.sub ('ly-set-grob-property([^!])', 'ly-set-grob-property!\1', str) + str = re.sub ('ly-set-mus-property([^!])', 'ly-set-mus-property!\1', str) + return str - return str - conversions.append (((1,7,11), conv, "transpose-pitch -> pitch-transpose")) +conversions.append (((1,5,68), conv, 'ly-set-X-property -> ly-set-X-property!')) -if 1: - def conv(str): - str = re.sub (r"ly:get-molecule-extent", "ly:molecule-get-extent", str) - str = re.sub (r"ly:set-molecule-extent!", "ly:molecule-set-extent!", str) - str = re.sub (r"ly:add-molecule", "ly:molecule-add", str) - str = re.sub (r"ly:combine-molecule-at-edge", "ly:molecule-combine-at-edge", str) - str = re.sub (r"ly:align-to!", "ly:molecule-align-to!", str) - return str +def conv (str): + str = re.sub ('extent-X', 'X-extent', str) + str = re.sub ('extent-Y', 'Y-extent', str) + return str - conversions.append (((1,7,13), conv, "ly:XX-molecule-YY -> ly:molecule-XX-YY")) +conversions.append (((1,5,71), conv, 'extent-[XY] -> [XY]-extent')) -if 1: - def conv(str): - str = re.sub (r"linewidth *= *-[0-9.]+ *(\\mm|\\cm|\\in|\\pt)?", 'raggedright = ##t', str ) - return str - conversions.append (((1,7,15), conv, "linewidth = -1 -> raggedright = ##t")) -if 1: - def conv(str): - str = re.sub ("divisiomaior", - "divisioMaior", str) - str = re.sub ("divisiominima", - "divisioMinima", str) - str = re.sub ("divisiomaxima", - "divisioMaxima", str) - return str +def conv (str): + str = re.sub ("""#\(set! +point-and-click +line-column-location\)""", + """#(set-point-and-click! \'line-column)""", str) + str = re.sub ("""#\(set![ \t]+point-and-click +line-location\)""", + '#(set-point-and-click! \'line)', str) + str = re.sub ('#\(set! +point-and-click +#f\)', + '#(set-point-and-click! \'none)', str) + return str - conversions.append (((1,7,16), conv, "divisiomaior -> divisioMaior")) +conversions.append (((1,5,72), conv, 'set! point-and-click -> set-point-and-click!')) -if 1: - def conv(str): - str = re.sub ("Skip_req_swallow_translator", - "Skip_event_swallow_translator", str) - return str - conversions.append (((1,7,17), conv, "Skip_req -> Skip_event")) -if 1: - def conv(str): - str = re.sub ("groupOpen", - "startGroup", str) - str = re.sub ("groupClose", - "stopGroup", str) - str = re.sub ("#'outer", - "#'enclose-bounds", str) +def conv (str): + str = re.sub ('flag-style', 'stroke-style', str) + str = re.sub (r"""Stem([ ]+)\\override #'style""", r"""Stem \\override #'flag-style""", str); + str = re.sub (r"""Stem([ ]+)\\set([ ]+)#'style""", r"""Stem \\set #'flag-style""", str); + return str - return str +conversions.append (((1,6,5), conv, 'Stems: flag-style -> stroke-style; style -> flag-style')) - conversions.append (((1,7,18), conv, - """groupOpen/Close -> start/stopGroup, - #'outer -> #'enclose-bounds - """)) -if 1: - def conv(str): - if re.search( r'\\GraceContext', str): - error_file.write ('\n') - error_file.write (NOT_SMART % "GraceContext") - error_file.write (FROM_TO \ - % ("GraceContext", "#(add-to-grace-init .. )")) - error_file.write ('\n') - error_file.write (UPDATE_MANUALLY) - error_file.write ('\n') - raise FatalConversionError () - str = re.sub ('HaraKiriStaffContext', 'RemoveEmptyStaffContext', str) - return str +def subst_req_name (match): + return "(make-music-by-name \'%sEvent)" % regularize_id (match.group(1)) - conversions.append (((1,7,19), conv,"remove GraceContext")) +def conv (str): + str = re.sub ('\\(ly-make-music *\"([A-Z][a-z_]+)_req\"\\)', subst_req_name, str) + str = re.sub ('Request_chord', 'EventChord', str) + return str +conversions.append (((1,7,1), conv, 'ly-make-music foo_bar_req -> make-music-by-name FooBarEvent')) -if 1: - def conv(str): - str = re.sub ( - r"(set|override|revert) *#'type", - r"\1 #'style", - str) - return str - conversions.append (((1,7,22), conv,"#'type -> #'style")) - -if 1: - def conv(str): - str = re.sub ( - "barNonAuto *= *##t", - "automaticBars = ##f", - str) - str = re.sub ( - "barNonAuto *= *##f", - "automaticBars = ##t", - str) - return str +spanner_subst ={ + "text" : 'TextSpanEvent', + "decrescendo" : 'DecrescendoEvent', + "crescendo" : 'CrescendoEvent', + "Sustain" : 'SustainPedalEvent', + "slur" : 'SlurEvent', + "UnaCorda" : 'UnaCordaEvent', + "Sostenuto" : 'SostenutoEvent', + } +def subst_ev_name (match): + stype = 'STOP' + if re.search ('start', match.group(1)): + stype= 'START' - conversions.append (((1,7,23), conv,"barNonAuto -> automaticBars")) + mtype = spanner_subst[match.group(2)] + return "(make-span-event '%s %s)" % (mtype , stype) +def subst_definition_ev_name(match): + return ' = #%s' % subst_ev_name (match) +def subst_inline_ev_name (match): + s = subst_ev_name (match) + return '#(ly-export %s)' % s +def subst_csp_definition (match): + return ' = #(make-event-chord (list %s))' % subst_ev_name (match) +def subst_csp_inline (match): + return '#(ly-export (make-event-chord (list %s)))' % subst_ev_name (match) -if 1: - def conv(str): - if re.search( r'-(start|stop)Cluster', str): - error_file.write ('\n') - error_file.write (NOT_SMART % "Cluster syntax") - error_file.write ('\n') - error_file.write (UPDATE_MANUALLY) - error_file.write ('\n') +def conv (str): + str = re.sub (r' *= *\\spanrequest *([^ ]+) *"([^"]+)"', subst_definition_ev_name, str) + str = re.sub (r'\\spanrequest *([^ ]+) *"([^"]+)"', subst_inline_ev_name, str) + str = re.sub (r' *= *\\commandspanrequest *([^ ]+) *"([^"]+)"', subst_csp_definition, str) + str = re.sub (r'\\commandspanrequest *([^ ]+) *"([^"]+)"', subst_csp_inline, str) + str = re.sub (r'ly-id ', 'ly-import ', str) - raise FatalConversionError () + str = re.sub (r' *= *\\script "([^"]+)"', ' = #(make-articulation "\\1")', str) + str = re.sub (r'\\script "([^"]+)"', '#(ly-export (make-articulation "\\1"))', str) + return str - return str +conversions.append (((1,7,2), conv, '\\spanrequest -> #(make-span-event .. ), \script -> #(make-articulation .. )')) + + +def conv(str): + str = re.sub (r'\(ly-', '(ly:', str) - conversions.append (((1,7,24), conv,"cluster syntax")) + changed = [ + r'duration\?', + r'font-metric\?', + r'molecule\?', + r'moment\?', + r'music\?', + r'pitch\?', + 'make-duration', + 'music-duration-length', + 'duration-log', + 'duration-dotcount', + 'intlog2', + 'duration-factor', + 'transpose-key-alist', + 'get-system', + 'get-broken-into', + 'get-original', + 'set-point-and-click!', + 'make-moment', + 'make-pitch', + 'pitch-octave', + 'pitch-alteration', + 'pitch-notename', + 'pitch-semitones', + r'pitch<\?', + r'dir\?', + 'music-duration-compress', + 'set-point-and-click!' + ] -if 1: - def conv(str): - str = re.sub (r"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\(override|set) *#'pedal-type *", - r"\property Staff.pedal\1Style ", str) - str = re.sub (r"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\revert *#'pedal-type", '', str) + origre = r'\b(%s)' % string.join (changed, '|') + + str = re.sub (origre, r'ly:\1',str) + str = re.sub ('set-point-and-click!', 'set-point-and-click', str) + + return str + +conversions.append (((1,7,3), conv, 'ly- -> ly:')) + + +def conv(str): + if re.search ('new-chords-done',str): return str - conversions.append (((1,7,28), conv,"new Pedal style syntax")) + str = re.sub (r'<<', '< <', str) + str = re.sub (r'>>', '> >', str) + return str +conversions.append (((1,7,4), conv, '<< >> -> < < > >')) -if 1: +def conv(str): + str = re.sub (r"\\transpose", r"\\transpose c'", str) + str = re.sub (r"\\transpose c' *([a-z]+)'", r"\\transpose c \1", str) + return str +conversions.append (((1,7,5), conv, '\\transpose TO -> \\transpose FROM TO')) - def sub_chord (m): - str = m.group(1) - origstr = '<%s>' % str - if re.search (r'\\\\', str): - return origstr +def conv(str): + kws = ['arpeggio', + 'sustainDown', + 'sustainUp', + 'f', + 'p', + 'pp', + 'ppp', + 'fp', + 'ff', + 'mf', + 'mp', + 'sfz', + ] - if re.search (r'\\property', str): - return origstr + origstr = string.join (kws, '|') + str = re.sub (r'([^_^-])\\(%s)\b' % origstr, r'\1-\\\2', str) + return str +conversions.append (((1,7,6), conv, 'note\\script -> note-\script')) - if re.match (r'^\s*\)?\s*\\[a-zA-Z]+', str): - return origstr - durs = [] - def sub_durs (m, durs = durs): - durs.append(m.group(2)) - return m.group (1) - str = re.sub (r"([a-z]+[,'!? ]*)([0-9]+\.*)", sub_durs, str) - dur_str = '' +def conv(str): + str = re.sub (r"\\property *ChordNames *\. *ChordName *\\(set|override) *#'style *= *#('[a-z]+)", + r"#(set-chord-name-style \2)", str) + str = re.sub (r"\\property *ChordNames *\. *ChordName *\\revert *#'style", + r"", str) + return str +conversions.append (((1,7,10), conv, "\property ChordName #'style -> #(set-chord-name-style 'style)")) - for d in durs: - if dur_str == '': - dur_str = d - if dur_str <> d: - return '<%s>' % m.group (1) - pslur_strs = [''] - dyns = [''] - slur_strs = [''] - last_str = '' - while last_str <> str: - last_str = str - def sub_tremolos (m, slur_strs = slur_strs): - tr = m.group (2) - if tr not in slur_strs: - slur_strs.append (tr) - return m.group (1) +def conv(str): + str = re.sub (r"ly:transpose-pitch", "ly:pitch-transpose", str) - str = re.sub (r"([a-z]+[',!? ]*)(:[0-9]+)", - sub_tremolos, str) + return str +conversions.append (((1,7,11), conv, "transpose-pitch -> pitch-transpose")) - def sub_dyn_end (m, dyns = dyns): - dyns.append (' \!') - return ' ' + m.group(2) - str = re.sub (r'(\\!)\s*([a-z]+)', sub_dyn_end, str) - def sub_slurs(m, slur_strs = slur_strs): - if '-)' not in slur_strs: - slur_strs.append (')') - return m.group(1) +def conv(str): + str = re.sub (r"ly:get-molecule-extent", "ly:molecule-get-extent", str) + str = re.sub (r"ly:set-molecule-extent!", "ly:molecule-set-extent!", str) + str = re.sub (r"ly:add-molecule", "ly:molecule-add", str) + str = re.sub (r"ly:combine-molecule-at-edge", "ly:molecule-combine-at-edge", str) + str = re.sub (r"ly:align-to!", "ly:molecule-align-to!", str) - def sub_p_slurs(m, slur_strs = slur_strs): - if '-\)' not in slur_strs: - slur_strs.append ('\)') - return m.group(1) + return str - str = re.sub (r"\)[ ]*([a-z]+)", sub_slurs, str) - str = re.sub (r"\\\)[ ]*([a-z]+)", sub_p_slurs, str) - def sub_begin_slurs(m, slur_strs = slur_strs): - if '-(' not in slur_strs: - slur_strs.append ('(') - return m.group(1) +conversions.append (((1,7,13), conv, "ly:XX-molecule-YY -> ly:molecule-XX-YY")) - str = re.sub (r"([a-z]+[,'!?0-9 ]*)\(", - sub_begin_slurs, str) - def sub_begin_p_slurs(m, slur_strs = slur_strs): - if '-\(' not in slur_strs: - slur_strs.append ('\(') - return m.group(1) - str = re.sub (r"([a-z]+[,'!?0-9 ]*)\\\(", - sub_begin_p_slurs, str) +def conv(str): + str = re.sub (r"linewidth *= *-[0-9.]+ *(\\mm|\\cm|\\in|\\pt)?", 'raggedright = ##t', str ) + return str - def sub_dyns (m, slur_strs = slur_strs): - s = m.group(0) - if s == '@STARTCRESC@': - slur_strs.append ("\\<") - elif s == '@STARTDECRESC@': - slur_strs.append ("\\>") - elif s == r'-?\\!': - slur_strs.append ('\\!') - return '' +conversions.append (((1,7,15), conv, "linewidth = -1 -> raggedright = ##t")) - str = re.sub (r'@STARTCRESC@', sub_dyns, str) - str = re.sub (r'-?\\!', sub_dyns, str) - def sub_articulations (m, slur_strs = slur_strs): - a = m.group(1) - if a not in slur_strs: - slur_strs.append (a) - return '' +def conv(str): + str = re.sub ("divisiomaior", + "divisioMaior", str) + str = re.sub ("divisiominima", + "divisioMinima", str) + str = re.sub ("divisiomaxima", + "divisioMaxima", str) + return str + +conversions.append (((1,7,16), conv, "divisiomaior -> divisioMaior")) + + +def conv(str): + str = re.sub ("Skip_req_swallow_translator", + "Skip_event_swallow_translator", str) + return str + +conversions.append (((1,7,17), conv, "Skip_req -> Skip_event")) + + +def conv(str): + str = re.sub ("groupOpen", + "startGroup", str) + str = re.sub ("groupClose", + "stopGroup", str) + str = re.sub ("#'outer", + "#'enclose-bounds", str) + + return str + +conversions.append (((1,7,18), conv, + """groupOpen/Close -> start/stopGroup, + #'outer -> #'enclose-bounds + """)) + + +def conv(str): + if re.search( r'\\GraceContext', str): + error_file.write ('\n') + error_file.write (NOT_SMART % "GraceContext") + error_file.write (FROM_TO \ + % ("GraceContext", "#(add-to-grace-init .. )")) + error_file.write ('\n') + error_file.write (UPDATE_MANUALLY) + error_file.write ('\n') + raise FatalConversionError () + + str = re.sub ('HaraKiriStaffContext', 'RemoveEmptyStaffContext', str) + return str + +conversions.append (((1,7,19), conv,"remove GraceContext")) + + + + +def conv(str): + str = re.sub ( + r"(set|override|revert) *#'type", + r"\1 #'style", + str) + return str + +conversions.append (((1,7,22), conv,"#'type -> #'style")) + + +def conv(str): + str = re.sub ( + "barNonAuto *= *##t", + "automaticBars = ##f", + str) + str = re.sub ( + "barNonAuto *= *##f", + "automaticBars = ##t", + str) + return str + +conversions.append (((1,7,23), conv,"barNonAuto -> automaticBars")) + + + +def conv(str): + if re.search( r'-(start|stop)Cluster', str): + error_file.write ('\n') + error_file.write (NOT_SMART % "Cluster syntax") + error_file.write ('\n') + error_file.write (UPDATE_MANUALLY) + error_file.write ('\n') + + raise FatalConversionError () + + return str + +conversions.append (((1,7,24), conv,"cluster syntax")) + + +def conv(str): + str = re.sub (r"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\(override|set) *#'pedal-type *", + r"\property Staff.pedal\1Style ", str) + str = re.sub (r"\\property *Staff\.(Sustain|Sostenuto|UnaCorda)Pedal *\\revert *#'pedal-type", '', str) + return str + +conversions.append (((1,7,28), conv,"new Pedal style syntax")) + + + + + +def sub_chord (m): + str = m.group(1) + + origstr = '<%s>' % str + if re.search (r'\\\\', str): + return origstr + + if re.search (r'\\property', str): + return origstr + + if re.match (r'^\s*\)?\s*\\[a-zA-Z]+', str): + return origstr + + durs = [] + def sub_durs (m, durs = durs): + durs.append(m.group(2)) + return m.group (1) + + str = re.sub (r"([a-z]+[,'!? ]*)([0-9]+\.*)", sub_durs, str) + dur_str = '' + + for d in durs: + if dur_str == '': + dur_str = d + if dur_str <> d: + return '<%s>' % m.group (1) + + pslur_strs = [''] + dyns = [''] + slur_strs = [''] + + last_str = '' + while last_str <> str: + last_str = str + + def sub_tremolos (m, slur_strs = slur_strs): + tr = m.group (2) + if tr not in slur_strs: + slur_strs.append (tr) + return m.group (1) + + str = re.sub (r"([a-z]+[',!? ]*)(:[0-9]+)", + sub_tremolos, str) + + def sub_dyn_end (m, dyns = dyns): + dyns.append (' \!') + return ' ' + m.group(2) + + str = re.sub (r'(\\!)\s*([a-z]+)', sub_dyn_end, str) + def sub_slurs(m, slur_strs = slur_strs): + if '-)' not in slur_strs: + slur_strs.append (')') + return m.group(1) + + def sub_p_slurs(m, slur_strs = slur_strs): + if '-\)' not in slur_strs: + slur_strs.append ('\)') + return m.group(1) + + str = re.sub (r"\)[ ]*([a-z]+)", sub_slurs, str) + str = re.sub (r"\\\)[ ]*([a-z]+)", sub_p_slurs, str) + def sub_begin_slurs(m, slur_strs = slur_strs): + if '-(' not in slur_strs: + slur_strs.append ('(') + return m.group(1) + + str = re.sub (r"([a-z]+[,'!?0-9 ]*)\(", + sub_begin_slurs, str) + def sub_begin_p_slurs(m, slur_strs = slur_strs): + if '-\(' not in slur_strs: + slur_strs.append ('\(') + return m.group(1) + + str = re.sub (r"([a-z]+[,'!?0-9 ]*)\\\(", + sub_begin_p_slurs, str) + + def sub_dyns (m, slur_strs = slur_strs): + s = m.group(0) + if s == '@STARTCRESC@': + slur_strs.append ("\\<") + elif s == '@STARTDECRESC@': + slur_strs.append ("\\>") + elif s == r'-?\\!': + slur_strs.append ('\\!') + return '' + + str = re.sub (r'@STARTCRESC@', sub_dyns, str) + str = re.sub (r'-?\\!', sub_dyns, str) + + def sub_articulations (m, slur_strs = slur_strs): + a = m.group(1) + if a not in slur_strs: + slur_strs.append (a) + return '' + + str = re.sub (r"([_^-]\@ACCENT\@)", sub_articulations, + str) + str = re.sub (r"([_^-]\\[a-z]+)", sub_articulations, + str) + str = re.sub (r"([_^-][>_.+|^-])", sub_articulations, + str) + str = re.sub (r'([_^-]"[^"]+")', sub_articulations, + str) + + def sub_pslurs(m, slur_strs = slur_strs): + slur_strs.append (' \\)') + return m.group(1) + str = re.sub (r"\\\)[ ]*([a-z]+)", sub_pslurs, str) + + ## end of while <> - str = re.sub (r"([_^-]\@ACCENT\@)", sub_articulations, - str) - str = re.sub (r"([_^-]\\[a-z]+)", sub_articulations, - str) - str = re.sub (r"([_^-][>_.+|^-])", sub_articulations, - str) - str = re.sub (r'([_^-]"[^"]+")', sub_articulations, - str) - - def sub_pslurs(m, slur_strs = slur_strs): - slur_strs.append (' \\)') - return m.group(1) - str = re.sub (r"\\\)[ ]*([a-z]+)", sub_pslurs, str) - - ## end of while <> - - suffix = string.join (slur_strs, '') + string.join (pslur_strs, - '') \ - + string.join (dyns, '') - - return '@STARTCHORD@%s@ENDCHORD@%s%s' % (str , dur_str, suffix) - - - - def sub_chords (str): - simend = '>' - simstart = '<' - chordstart = '<<' - chordend = '>>' - marker_str = '%% new-chords-done %%' - - if re.search (marker_str,str): - return str - str = re.sub ('<<', '@STARTCHORD@', str) - str = re.sub ('>>', '@ENDCHORD@', str) - - str = re.sub (r'\\<', '@STARTCRESC@', str) - str = re.sub (r'\\>', '@STARTDECRESC@', str) - str = re.sub (r'([_^-])>', r'\1@ACCENT@', str) - str = re.sub (r'<([^<>{}]+)>', sub_chord, str) - - # add dash: -[, so that [<> c d] becomes - # <>-[ c d] - # and gets skipped by articulation_substitute - str = re.sub (r'\[ *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)', - r'\1-[', str) - str = re.sub (r'\\! *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)', - r'\1-\\!', str) - - str = re.sub (r'<([^?])', r'%s\1' % simstart, str) - str = re.sub (r'>([^?])', r'%s\1' % simend, str) - str = re.sub ('@STARTCRESC@', r'\\<', str) - str = re.sub ('@STARTDECRESC@', r'\\>' ,str) - str = re.sub (r'\\context *Voice *@STARTCHORD@', - '@STARTCHORD@', str) - str = re.sub ('@STARTCHORD@', chordstart, str) - str = re.sub ('@ENDCHORD@', chordend, str) - str = re.sub (r'@ACCENT@', '>', str) + suffix = string.join (slur_strs, '') + string.join (pslur_strs, + '') \ + + string.join (dyns, '') + + return '@STARTCHORD@%s@ENDCHORD@%s%s' % (str , dur_str, suffix) + + + +def sub_chords (str): + simend = '>' + simstart = '<' + chordstart = '<<' + chordend = '>>' + marker_str = '%% new-chords-done %%' + + if re.search (marker_str,str): return str + str = re.sub ('<<', '@STARTCHORD@', str) + str = re.sub ('>>', '@ENDCHORD@', str) - markup_start = re.compile(r"([-^_]|\\mark)\s*(#\s*'\s*)\(") - musicglyph = re.compile(r"\(\s*music\b") - columns = re.compile(r"\(\s*columns\b") - submarkup_start = re.compile(r"\(\s*([a-zA-Z]+)") - leftpar = re.compile(r"\(") - rightpar = re.compile(r"\)") - - def text_markup (str): - result = '' - # Find the beginning of each markup: - match = markup_start.search (str) - while match: - result = result + str[:match.end (1)] + " \markup" - str = str[match.end( 2):] - # Count matching parentheses to find the end of the - # current markup: + str = re.sub (r'\\<', '@STARTCRESC@', str) + str = re.sub (r'\\>', '@STARTDECRESC@', str) + str = re.sub (r'([_^-])>', r'\1@ACCENT@', str) + str = re.sub (r'<([^<>{}]+)>', sub_chord, str) + + # add dash: -[, so that [<> c d] becomes + # <>-[ c d] + # and gets skipped by articulation_substitute + str = re.sub (r'\[ *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)', + r'\1-[', str) + str = re.sub (r'\\! *(@STARTCHORD@[^@]+@ENDCHORD@[0-9.]*)', + r'\1-\\!', str) + + str = re.sub (r'<([^?])', r'%s\1' % simstart, str) + str = re.sub (r'>([^?])', r'%s\1' % simend, str) + str = re.sub ('@STARTCRESC@', r'\\<', str) + str = re.sub ('@STARTDECRESC@', r'\\>' ,str) + str = re.sub (r'\\context *Voice *@STARTCHORD@', + '@STARTCHORD@', str) + str = re.sub ('@STARTCHORD@', chordstart, str) + str = re.sub ('@ENDCHORD@', chordend, str) + str = re.sub (r'@ACCENT@', '>', str) + return str + +markup_start = re.compile(r"([-^_]|\\mark)\s*(#\s*'\s*)\(") +musicglyph = re.compile(r"\(\s*music\b") +columns = re.compile(r"\(\s*columns\b") +submarkup_start = re.compile(r"\(\s*([a-zA-Z]+)") +leftpar = re.compile(r"\(") +rightpar = re.compile(r"\)") + +def text_markup (str): + result = '' + # Find the beginning of each markup: + match = markup_start.search (str) + while match: + result = result + str[:match.end (1)] + " \markup" + str = str[match.end( 2):] + # Count matching parentheses to find the end of the + # current markup: + nesting_level = 0 + pars = re.finditer(r"[()]",str) + for par in pars: + if par.group () == '(': + nesting_level = nesting_level + 1 + else: + nesting_level = nesting_level - 1 + if nesting_level == 0: + markup_end = par.end () + break + # The full markup in old syntax: + markup = str[:markup_end] + # Modify to new syntax: + markup = musicglyph.sub (r"{\\musicglyph", markup) + markup = columns.sub (r"{", markup) + markup = submarkup_start.sub (r"{\\\1", markup) + markup = leftpar.sub ("{", markup) + markup = rightpar.sub ("}", markup) + + result = result + markup + # Find next markup + str = str[markup_end:] + match = markup_start.search(str) + result = result + str + return result + +def articulation_substitute (str): + str = re.sub (r"""([^-])\[ *(\\?\)?[a-z]+[,']*[!?]?[0-9:]*\.*)""", + r"\1 \2[", str) + str = re.sub (r"""([^-])\\\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""", + r"\1 \2\\)", str) + str = re.sub (r"""([^-\\])\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""", + r"\1 \2)", str) + str = re.sub (r"""([^-])\\! *([a-z]+[,']*[!?]?[0-9:]*\.*)""", + r"\1 \2\\!", str) + return str + +string_or_scheme = re.compile ('("(?:[^"\\\\]|\\\\.)*")|(#\\s*\'?\\s*\\()') + +# Only apply articulation_substitute () outside strings and +# Scheme expressions: +def smarter_articulation_subst (str): + result = '' + # Find the beginning of next string or Scheme expr.: + match = string_or_scheme.search (str) + while match: + # Convert the preceding LilyPond code: + previous_chunk = str[:match.start()] + result = result + articulation_substitute (previous_chunk) + if match.group (1): # Found a string + # Copy the string to output: + result = result + match.group (1) + str = str[match.end(1):] + else: # Found a Scheme expression. Count + # matching parentheses to find its end + str = str[match.start ():] nesting_level = 0 pars = re.finditer(r"[()]",str) for par in pars: @@ -1365,156 +1419,99 @@ if 1: else: nesting_level = nesting_level - 1 if nesting_level == 0: - markup_end = par.end () + scheme_end = par.end () break - # The full markup in old syntax: - markup = str[:markup_end] - # Modify to new syntax: - markup = musicglyph.sub (r"{\\musicglyph", markup) - markup = columns.sub (r"{", markup) - markup = submarkup_start.sub (r"{\\\1", markup) - markup = leftpar.sub ("{", markup) - markup = rightpar.sub ("}", markup) - - result = result + markup - # Find next markup - str = str[markup_end:] - match = markup_start.search(str) - result = result + str - return result - - def articulation_substitute (str): - str = re.sub (r"""([^-])\[ *(\\?\)?[a-z]+[,']*[!?]?[0-9:]*\.*)""", - r"\1 \2[", str) - str = re.sub (r"""([^-])\\\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""", - r"\1 \2\\)", str) - str = re.sub (r"""([^-\\])\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""", - r"\1 \2)", str) - str = re.sub (r"""([^-])\\! *([a-z]+[,']*[!?]?[0-9:]*\.*)""", - r"\1 \2\\!", str) - return str - - string_or_scheme = re.compile ('("(?:[^"\\\\]|\\\\.)*")|(#\\s*\'?\\s*\\()') - - # Only apply articulation_substitute () outside strings and - # Scheme expressions: - def smarter_articulation_subst (str): - result = '' - # Find the beginning of next string or Scheme expr.: + # Copy the Scheme expression to output: + result = result + str[:scheme_end] + str = str[scheme_end:] + # Find next string or Scheme expression: match = string_or_scheme.search (str) - while match: - # Convert the preceding LilyPond code: - previous_chunk = str[:match.start()] - result = result + articulation_substitute (previous_chunk) - if match.group (1): # Found a string - # Copy the string to output: - result = result + match.group (1) - str = str[match.end(1):] - else: # Found a Scheme expression. Count - # matching parentheses to find its end - str = str[match.start ():] - nesting_level = 0 - pars = re.finditer(r"[()]",str) - for par in pars: - if par.group () == '(': - nesting_level = nesting_level + 1 - else: - nesting_level = nesting_level - 1 - if nesting_level == 0: - scheme_end = par.end () - break - # Copy the Scheme expression to output: - result = result + str[:scheme_end] - str = str[scheme_end:] - # Find next string or Scheme expression: - match = string_or_scheme.search (str) - # Convert the remainder of the file - result = result + articulation_substitute (str) - return result - - def conv_relative(str): - if re.search (r"\\relative", str): - str= "#(ly:set-option 'old-relative)\n" + str + # Convert the remainder of the file + result = result + articulation_substitute (str) + return result - return str +def conv_relative(str): + if re.search (r"\\relative", str): + str= "#(ly:set-option 'old-relative)\n" + str - def conv (str): - str = re.sub (r"#'\(\)", "@SCM_EOL@", str) - str = conv_relative (str) - str = sub_chords (str) + return str - str = text_markup (str) - str = smarter_articulation_subst (str) - str = re.sub ("@SCM_EOL@", "#'()", str) +def conv (str): + str = re.sub (r"#'\(\)", "@SCM_EOL@", str) + str = conv_relative (str) + str = sub_chords (str) - return str + str = text_markup (str) + str = smarter_articulation_subst (str) + str = re.sub ("@SCM_EOL@", "#'()", str) - conversions.append (((1,9,0), conv, """New relative mode, + return str + +conversions.append (((1,9,0), conv, """New relative mode, Postfix articulations, new text markup syntax, new chord syntax.""")) -if 1: - def conv (str): - if re.search ("font-style",str): - error_file.write ('\n') - error_file.write (NOT_SMART % "font-sytle") - error_file.write ('\n') - error_file.write (UPDATE_MANUALLY) - error_file.write ('\n') - raise FatalConversionError () +def conv (str): + if re.search ("font-style",str): + error_file.write ('\n') + error_file.write (NOT_SMART % "font-sytle") + error_file.write ('\n') + error_file.write (UPDATE_MANUALLY) + error_file.write ('\n') - str = re.sub (r'-\\markup', r'@\\markup', str) - str = re.sub (r'-\\', r'\\', str) - str = re.sub (r'-\)', ')', str) - str = re.sub (r'-\(', '(', str) - str = re.sub ('-\[', '[', str) - str = re.sub ('-\]', ']', str) - str = re.sub ('-~', '~', str) - str = re.sub (r'@\\markup', r'-\\markup', str) - return str + raise FatalConversionError () - conversions.append (((1,9,1), conv, """Remove - before articulation""")) -if 1: - def conv (str): - str = re.sub ('ly:set-context-property', - 'ly:set-context-property!', str) - str = re.sub ('\\\\newcontext', '\\\\new', str) - str = re.sub ('\\\\grace[\t\n ]*([^{ ]+)', - r'\\grace { \1 }', str) - str = re.sub ("\\\\grace[\t\n ]*{([^}]+)}", - r"""\\grace { - \\property Voice.Stem \\override #'stroke-style = #"grace" + str = re.sub (r'-\\markup', r'@\\markup', str) + str = re.sub (r'-\\', r'\\', str) + str = re.sub (r'-\)', ')', str) + str = re.sub (r'-\(', '(', str) + str = re.sub ('-\[', '[', str) + str = re.sub ('-\]', ']', str) + str = re.sub ('-~', '~', str) + str = re.sub (r'@\\markup', r'-\\markup', str) + return str + +conversions.append (((1,9,1), conv, """Remove - before articulation""")) + +def conv (str): + str = re.sub ('ly:set-context-property', + 'ly:set-context-property!', str) + str = re.sub ('\\\\newcontext', '\\\\new', str) + str = re.sub ('\\\\grace[\t\n ]*([^{ ]+)', + r'\\grace { \1 }', str) + str = re.sub ("\\\\grace[\t\n ]*{([^}]+)}", + r"""\\grace { +\\property Voice.Stem \\override #'stroke-style = #"grace" \1 \\property Voice.Stem \\revert #'stroke-style } """, str) - return str + return str - conversions.append (((1,9,2), conv, """\\newcontext -> \\new""")) +conversions.append (((1,9,2), conv, """\\newcontext -> \\new""")) -if 1: - def conv (str): - str = re.sub ('accacciatura', - 'acciaccatura', str) +def conv (str): + str = re.sub ('accacciatura', + 'acciaccatura', str) - if re.search ("context-spec-music", str): - error_file.write ('\n') - error_file.write (NOT_SMART % "context-spec-music") - error_file.write ('\n') - error_file.write (UPDATE_MANUALLY) - error_file.write ('\n') + if re.search ("context-spec-music", str): + error_file.write ('\n') + error_file.write (NOT_SMART % "context-spec-music") + error_file.write ('\n') + error_file.write (UPDATE_MANUALLY) + error_file.write ('\n') - raise FatalConversionError () + raise FatalConversionError () - str = re.sub ('fingerHorizontalDirection *= *#(LEFT|-1)', - "fingeringOrientations = #'(up down left)", str) - str = re.sub ('fingerHorizontalDirection *= *#(RIGHT|1)', - "fingeringOrientations = #'(up down right)", str) + str = re.sub ('fingerHorizontalDirection *= *#(LEFT|-1)', + "fingeringOrientations = #'(up down left)", str) + str = re.sub ('fingerHorizontalDirection *= *#(RIGHT|1)', + "fingeringOrientations = #'(up down right)", str) - return str + return str - conversions.append (((1,9,3), conv, - """\\acciaccatura misspelling, fingerHorizontalDirection -> fingeringOrientations""")) +conversions.append (((1,9,3), conv, + """\\acciaccatura misspelling, fingerHorizontalDirection -> fingeringOrientations""")) def conv (str): @@ -2552,63 +2549,15 @@ conversions.append (((2, 7, 6), conv, '''Performer_group_performer -> Performer_group, Engraver_group_engraver -> Engraver_group''')) -################################################################ - -def str_to_tuple (s): - return tuple (map (string.atoi, string.split (s, '.'))) - -def tup_to_str (t): - return string.join (map (lambda x: '%s' % x, list (t)), '.') - -def version_cmp (t1, t2): - for x in [0, 1, 2]: - if t1[x] - t2[x]: - return t1[x] - t2[x] - return 0 - -def get_conversions (from_version, to_version): - def is_applicable (v, f = from_version, t = to_version): - return version_cmp (v[0], f) > 0 and version_cmp (v[0], t) <= 0 - return filter (is_applicable, conversions) - -def latest_version (): - return conversions[-1][0] - -def show_rules (file, from_version, to_version): - for x in conversions: - if (not from_version or x[0] > from_version) \ - and (not to_version or x[0] <= to_version): - file.write ('%s: %s\n' % (tup_to_str (x[0]), x[2])) - - -def do_conversion (str, from_version, to_version): - - """Apply conversions from FROM_VERSION to TO_VERSION. Return -tuple (LAST,STR), with the last succesful conversion and the resulting -string.""" - - - conv_list = get_conversions (from_version, to_version) - - if error_file: - error_file.write (_ ("Applying conversion: ")) - - last_conversion = () - try: - for x in conv_list: - error_file.write (tup_to_str (x[0])) - if x != conv_list[-1]: - error_file.write (', ') - str = x[1] (str) - last_conversion = x[0] - - except FatalConversionError: - error_file.write (_ ("error while converting")) - error_file.write ('\n') - error_file.write (_ ("Aborting")) - error_file.write ('\n') - - +def conv (str): + str = re.sub (r"#'inside-slur\s*=\s*##t *", + r"#'avoid-slur = #'inside ", str) + str = re.sub (r"#'inside-slur\s*=\s*##f *", + r"#'avoid-slur = #'around ", str) + str = re.sub (r"#'inside-slur", + r"#'avoid-slur", str) + return str - return (last_conversion, str) +conversions.append (((2, 7, 7), conv, + """inside-slur -> avoid-slur""")) diff --git a/scm/script.scm b/scm/script.scm index 1c9f1a6bd2..18959121db 100644 --- a/scm/script.scm +++ b/scm/script.scm @@ -36,25 +36,25 @@ ((script-stencil . (feta . ("uaccentus" . "uaccentus"))) (side-relative-direction . -1) (follow-into-staff . #t) - (priority . -100) + (script-priority . -100) (direction . 1))) ("ictus" . ((script-stencil . (feta . ("ictus" . "ictus"))) (side-relative-direction . -1) (follow-into-staff . #t) - (priority . -100) + (script-priority . -100) (direction . -1))) ("semicirculus" . ((script-stencil . (feta . ("dsemicirculus" . "dsemicirculus"))) (side-relative-direction . -1) (follow-into-staff . #t) - (priority . -100) + (script-priority . -100) (direction . 1))) ("circulus" . ((script-stencil . (feta . ("circulus" . "circulus"))) (side-relative-direction . -1) (follow-into-staff . #t) - (priority . -100) + (script-priority . -100) (direction . 1))) ("signumcongruentiae" . @@ -63,6 +63,7 @@ ("fermata" . ((script-stencil . (feta . ("dfermata" . "ufermata"))) (avoid-slur . around) + (script-priority . 4000) (direction . 1))) ("shortfermata" . ((script-stencil . (feta . ("dshortfermata" . "ushortfermata"))) @@ -81,7 +82,7 @@ (side-relative-direction . -1) (follow-into-staff . #t) (avoid-slur . inside) - (priority . -100))) + (script-priority . -100))) ("tenuto" . ((script-stencil . (feta . ("tenuto" . "tenuto"))) (follow-into-staff . #t) @@ -131,7 +132,7 @@ ("trill" . ((script-stencil . (feta . ("trill" . "trill"))) (direction . 1) - (priority . 2000))) + (script-priority . 2000))) ("prall" . ((script-stencil . (feta . ("prall" . "prall"))) (direction . 1))) diff --git a/scripts/convert-ly.py b/scripts/convert-ly.py index 800c04b5cc..2024bd034f 100644 --- a/scripts/convert-ly.py +++ b/scripts/convert-ly.py @@ -61,9 +61,64 @@ option_definitions = [ program_name = os.path.basename (sys.argv[0]) program_version = '@TOPLEVEL_VERSION@' - add_version = 1 +def str_to_tuple (s): + return tuple (map (string.atoi, string.split (s, '.'))) + +def tup_to_str (t): + return string.join (map (lambda x: '%s' % x, list (t)), '.') + +def version_cmp (t1, t2): + for x in [0, 1, 2]: + if t1[x] - t2[x]: + return t1[x] - t2[x] + return 0 + +def get_conversions (from_version, to_version): + def is_applicable (v, f = from_version, t = to_version): + return version_cmp (v[0], f) > 0 and version_cmp (v[0], t) <= 0 + return filter (is_applicable, conversions) + +def latest_version (): + return conversions[-1][0] + +def show_rules (file, from_version, to_version): + for x in conversions: + if (not from_version or x[0] > from_version) \ + and (not to_version or x[0] <= to_version): + file.write ('%s: %s\n' % (tup_to_str (x[0]), x[2])) + +def do_conversion (str, from_version, to_version): + """Apply conversions from FROM_VERSION to TO_VERSION. Return +tuple (LAST,STR), with the last succesful conversion and the resulting +string.""" + conv_list = get_conversions (from_version, to_version) + + if error_file: + error_file.write (_ ("Applying conversion: ")) + + last_conversion = () + try: + for x in conv_list: + error_file.write (tup_to_str (x[0])) + if x != conv_list[-1]: + error_file.write (', ') + str = x[1] (str) + last_conversion = x[0] + + except FatalConversionError: + error_file.write (_ ("error while converting")) + error_file.write ('\n') + error_file.write (_ ("Aborting")) + error_file.write ('\n') + + + + return (last_conversion, str) + + + def guess_lilypond_version (filename): s = open (filename).read () m = lilypond_version_re.search (s) @@ -75,8 +130,6 @@ def guess_lilypond_version (filename): class FatalConversionError: pass -conversions = [] - class UnknownVersion: pass -- 2.39.2