]> git.donarmstrong.com Git - lilypond.git/blobdiff - python/convertrules.py
Add obsoletion warning for minimum-Y-extent.
[lilypond.git] / python / convertrules.py
index 90bb54ac7f69e655af44bbb7e13b6e974f038c0e..7111657ca1912d9adc265a927e2af00b013cf0bc 100644 (file)
@@ -9,8 +9,8 @@ import lilylib
 _ = lilylib._
 
 
-NOT_SMART = _ ("Not smart enough to convert %s")
-UPDATE_MANUALLY        = _ ("Please refer to the manual for details, and update manually.")
+NOT_SMART = "\n" + _ ("Not smart enough to convert %s")
+UPDATE_MANUALLY = _ ("Please refer to the manual for details, and update manually.")
 FROM_TO = _ ( "%s has been replaced by %s")
 
 
@@ -374,7 +374,7 @@ def conv (str):
     return str
 
 
-# TODO: lots of other syntax change should be done here as well
+# TODO: lots of other syntax changes should be done here as well
 @rule ((1, 3, 92), 'basicXXXProperties -> XXX, Repeat_engraver -> Volta_engraver')
 def conv (str):
     str = re.sub ('basicCollisionProperties', 'NoteCollision', str)
@@ -418,7 +418,7 @@ def conv (str):
     str = re.sub ('\\\\voicefour', '\\\\voiceFour', str)
 
     # I don't know exactly when these happened...
-    # ugh, we loose context setting here...
+    # ugh, we lose 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)
@@ -431,7 +431,7 @@ def conv (str):
     str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?((-1)|(\\\\down))"?', '\\\\\\1Down', str)
     str = re.sub ('\\\\property *[^ .]*[.]?([a-z]+)VerticalDirection[^=]*= *#?"?(0|(\\\\center))"?', '\\\\\\1Both', str)
 
-    # (lacks capitalisation slur -> Slur)
+    # (lacks capitalization 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)
@@ -1187,7 +1187,7 @@ def text_markup (str):
     while match:
        result = result + str[:match.end (1)] + " \markup"
        str = str[match.end( 2):]
-       # Count matching parentheses to find the end of the 
+       # Count matching parentheses to find the end of the
        # current markup:
        nesting_level = 0
        pars = re.finditer(r"[()]",str)
@@ -1228,7 +1228,7 @@ def articulation_substitute (str):
 
 string_or_scheme = re.compile ('("(?:[^"\\\\]|\\\\.)*")|(#\\s*\'?\\s*\\()')
 
-# Only apply articulation_substitute () outside strings and 
+# Only apply articulation_substitute () outside strings and
 # Scheme expressions:
 def smarter_articulation_subst (str):
     result = ''
@@ -1242,7 +1242,7 @@ def smarter_articulation_subst (str):
            # Copy the string to output:
            result = result + match.group (1)
            str = str[match.end(1):]
-       else: # Found a Scheme expression. Count 
+       else: # Found a Scheme expression. Count
            # matching parentheses to find its end
            str = str[match.start ():]
            nesting_level = 0
@@ -1321,7 +1321,7 @@ def conv (str):
     return str
 
 
-@rule ((1, 9, 3), (_ ("%s misspelling") % "\\acciaccatura") + 
+@rule ((1, 9, 3), (_ ("%s misspelling") % "\\acciaccatura") +
                          ", fingerHorizontalDirection -> fingeringOrientations")
 def conv (str):
     str = re.sub ('accacciatura',
@@ -1821,7 +1821,6 @@ def conv (str):
        a = g - lower_pitches [-1]
 
 
-       print s , lower_pitches, g, a, s
        str = 'cdefgab' [s]
        str += ['eses', 'es', '', 'is', 'isis'][a + 2]
        if o < 0:
@@ -2003,7 +2002,7 @@ def conv (str):
     str = re.sub ('soloADue', 'printPartCombineTexts', str)
     str = re.sub (r'\\applymusic\s*#notes-to-clusters',
                      '\\makeClusters', str)
-    
+
     str = re.sub (r'pagenumber\s*=', 'firstpagenumber = ', str)
     return str
 
@@ -2056,7 +2055,7 @@ with
 
     str = re.sub (r'#\(paper-set-staff-size', '%Use set-global-staff-size at toplevel\n% #(layout-set-staff-size', str)
     return str
-    
+
 
 @rule ((2, 3, 23), r'\context Foo = NOTENAME -> \context Foo = "NOTENAME"')
 def conv (str):
@@ -2219,7 +2218,7 @@ def conv (str):
        stderr_write ('\n')
        stderr_write (_ ('''
 Auto beam settings must now specify each interesting moment in a measure
-explicitely; 1/4 is no longer multiplied to cover moments 1/2 and 3/4 too.
+explicitly; 1/4 is no longer multiplied to cover moments 1/2 and 3/4 too.
 '''))
        stderr_write (UPDATE_MANUALLY)
        stderr_write ('\n')
@@ -2241,7 +2240,7 @@ def conv (str):
 
 @rule ((2, 7, 0), 'ly:get-default-font -> ly:grob-default-font')
 def conv (str):
-    return re.sub('ly:get-default-font', 'ly:grob-default-font', str) 
+    return re.sub('ly:get-default-font', 'ly:grob-default-font', str)
 
 
 @rule ((2, 7, 1), '''ly:parser-define -> ly:parser-define!
@@ -2540,7 +2539,7 @@ def conv (str):
         while dur > 1 :
             dur /= 2
             log2 += 1
-        
+
         den = (1 << dots) * (1 << log2)
         num = ((1 << (dots+1))  - 1)
 
@@ -2553,7 +2552,7 @@ def conv (str):
     }
 
 """ % (num*count, den)
-    
+
     str = re.sub (r'\\midi\s*{\s*\\tempo ([0-9]+)\s*([.]*)\s*=\s*([0-9]+)\s*}', sub_tempo, str)
     return str
 
@@ -2574,6 +2573,12 @@ def conv (str):
     return re.sub ('ly:clone-parser',
                    'ly:parser-clone', str)
 
+@rule ((2, 11, 3), "no-spacing-rods -> extra-spacing-width")
+def conv (str):
+    str = re.sub (r"no-spacing-rods\s+=\s+##t", r"extra-spacing-width = #'(+inf.0 . -inf.0)", str)
+    str = re.sub (r"no-spacing-rods\s+=\s+##f", r"extra-spacing-width = #'(0 . 0)", str)
+    return str
+
 
 @rule ((2, 11, 5), _ ("deprecate cautionary-style. Use AccidentalCautionary properties"))
 def conv (str):
@@ -2590,10 +2595,10 @@ def conv (str):
 
 @rule ((2, 11, 6), _ ("Rename accidental glyphs, use glyph-name-alist."))
 def conv (str):
-    
+
     def sub_acc_name (m):
         idx = int (m.group (1).replace ('M','-'))
-        
+
         return ["accidentals.doublesharp",
                 "accidentals.sharp.slashslash.stemstemstem",
                 "accidentals.sharp",
@@ -2605,7 +2610,7 @@ def conv (str):
                 "accidentals.flatflat"][4-idx]
 
     str = re.sub (r"accidentals[.](M?[-0-9]+)",
-                  sub_acc_name, str) 
+                  sub_acc_name, str)
     str = re.sub (r"(KeySignature|Accidental[A-Za-z]*)\s*#'style\s*=\s*#'([a-z]+)",
                   r"\1 #'glyph-name-alist = #alteration-\2-glyph-name-alist", str)
     ## FIXME: standard vs default, alteration-FOO vs FOO-alteration
@@ -2650,7 +2655,8 @@ def conv (str):
     return str
 
 
-@rule ((2, 11, 15), "#'edge-height -> #'bound-details #'right/left #'text = ...")
+@rule ((2, 11, 15), "TextSpanner #'edge-height -> #'bound-details #'right/left #'text = ...\n\
+Remove 'forced-distance for fixed spacing between staves in a PianoStaff.")
 def conv (str):
     def sub_edge_height (m):
         s = ''
@@ -2658,20 +2664,27 @@ def conv (str):
                          ('right', m.group (4))]:
 
             if h and float (h):
-                once = m.group(1)
+                once = m.group (1)
                 if not once:
                     once = ''
-                    
-                s += (r"%s \override %s #'bound-details #'%s #'text = \markup { \draw-line #'(0 . %s) }"
-                      % (once, m.group (2), var, h))
+                context = m.group (2)
+                if not context:
+                    context = ''
+
+                s += (r"%s \override %sTextSpanner #'bound-details #'%s #'text = \markup { \draw-line #'(0 . %s) }"
+                      % (once, context, var, h))
 
                 s += '\n'
-            
+
         return s
-    
-                  
-    str = re.sub (r"(\\once)?\s*\\override\s*([a-zA-Z.]+)\s*#'edge-height\s*=\s*#'\(([0-9.-]+)\s+[.]\s+([0-9.-]+)\)",
-                  sub_edge_height, str)
+
+
+    str = re.sub (r"(\\once)?\s*\\override\s*([a-zA-Z]+\s*[.]\s*)?TextSpanner\s*#'edge-height\s*=\s*#'\(\s*([0-9.-]+)\s+[.]\s+([0-9.-]+)\s*\)", sub_edge_height, str)
+    if re.search (r"#'forced-distance", str):
+        stderr_write (NOT_SMART % ("VerticalAlignment #'forced-distance.\n"))
+        stderr_write (_ ("Use the `alignment-offsets' sub-property of\n"))
+        stderr_write (_ ("NonMusicalPaperColumn #'line-break-system-details\n"))
+        stderr_write (_ ("to set fixed distances between staves.\n"))
     return str
 
 
@@ -2737,8 +2750,8 @@ def conv (str):
                           "\t(format-metronome-markup text dur count context)\n")
 
     ## warning 2/2: fret diagram properties moved to fret-diagram-details
-    fret_props = ['barre-type', 
-                'dot-color', 
+    fret_props = ['barre-type',
+                'dot-color',
                 'dot-radius',
                 'finger-code',
                 'fret-count',
@@ -2764,7 +2777,7 @@ def conv (str):
 \\sustainUp -> \\sustainOff, \\sustainDown -> \\sustainOn\n\
 \\sostenutoDown -> \\sostenutoOn, \\sostenutoUp -> \\sostenutoOff")
 def conv (str):
-    str = re.sub (r"\\octave", r"\\octaveCheck", str)
+    str = re.sub (r"\\octave(?![a-zA-Z])", r"\\octaveCheck", str)
     str = re.sub (r"arpeggioUp", r"arpeggioArrowUp", str)
     str = re.sub (r"arpeggioDown", r"arpeggioArrowDown", str)
     str = re.sub (r"arpeggioNeutral", r"arpeggioNormal", str)
@@ -2793,7 +2806,7 @@ def conv (str):
 
 @rule ((2, 11, 55), "#(set-octavation oct) -> \\ottava #oct,\n\
 \\put-adjacent markup axis dir markup -> \\put-adjacent axis dir markup markup")
-def conv (str):    
+def conv (str):
     str = re.sub (r"#\(set-octavation (-*[0-9]+)\)", r"\\ottava #\1", str)
     if re.search ('put-adjacent', str):
        stderr_write (NOT_SMART % _ ("\\put-adjacent argument order.\n"))
@@ -2807,6 +2820,169 @@ def conv (str):
     str = re.sub (r"hcenter(\s+)", r"center-align\1", str)
     return str
 
+@rule ((2, 11, 60), "printallheaders -> print-all-headers")
+def conv (str):
+    str = re.sub (r"printallheaders", r"print-all-headers", str)
+    return str
+
+@rule ((2, 11, 61), "gregorian-init.ly -> gregorian.ly")
+def conv (str):
+    str = re.sub (r'\\include(\s+)"gregorian-init.ly"', r'\\include\1"gregorian.ly"', str)
+    return str
+
+@rule ((2, 11, 62), "makam-init.ly -> makam.ly, \\bigger -> \\larger")
+def conv (str):
+    str = re.sub (r'\\include(\s+)"makam-init.ly"', r'\\include\1"makam.ly"', str)
+    str = re.sub (r"([\\:])bigger", r"\1larger", str)
+    return str
+
+@rule ((2, 11, 64), "systemSeparatorMarkup -> system-separator-markup,\n\
+InnerStaffGroup -> StaffGroup, InnerChoirStaff -> ChoirStaff")
+def conv (str):
+    str = re.sub (r'systemSeparatorMarkup', r'system-separator-markup', str)
+    if re.search (r'\\InnerStaffGroup', str):
+        stderr_write ("\n")
+        stderr_write (NOT_SMART % _("re-definition of InnerStaffGroup.\n"))
+        stderr_write (FROM_TO % ("InnerStaffGroup", "StaffGroup.\n"))
+        stderr_write (UPDATE_MANUALLY)
+        raise FatalConversionError ()
+    if re.search (r'\\InnerChoirStaff', str):
+        stderr_write ("\n")
+        stderr_write (NOT_SMART % _("re-definition of InnerChoirStaff.\n"))
+        stderr_write (FROM_TO % ("InnerChoirStaff", "ChoirStaff.\n"))
+        stderr_write (UPDATE_MANUALLY)
+        raise FatalConversionError ()
+    else:
+        str = re.sub ('InnerStaffGroup', 'StaffGroup', str)
+        str = re.sub ('InnerChoirStaff', 'ChoirStaff', str)
+    return str
+
+@rule ((2, 12, 0),
+       _ ("Syntax changes for \\addChordShape and \\chord-shape") + "\n" + \
+       _ ("bump version for release"))
+def conv(str):
+    if re.search(r'\\addChordShape', str):
+        stderr_write ("\n")
+        stderr_write (NOT_SMART % _("stringTuning must be added to \
+addChordShape call.\n"))
+        stderr_write (UPDATE_MANUALLY)
+        raise FatalConversionError ()
+    if re.search (r'\\chord-shape', str):
+        stderr_write ("\n")
+        stderr_write (NOT_SMART % _("stringTuning must be added to \
+chord-shape call.\n"))
+        stderr_write (UPDATE_MANUALLY)
+        raise FatalConversionError ()
+    return str
+
+@rule ((2,12,3),
+    _ ("Remove oldaddlyrics"))
+def conv(str):
+    if re.search(r'\\oldaddlyrics', str):
+        stderr_write ("\n")
+        stderr_write (NOT_SMART % _("oldaddlyrics is no longer supported. \n \
+        Use addlyrics or lyrsicsto instead.\n"))
+        stderr_write (UPDATE_MANUALLY)
+        raise FatalConversionError ()
+    return str
+
+@rule ((2, 13, 0), _ ("keySignature property not reversed any more\n\
+MIDI 47: orchestral strings -> orchestral harp"))
+def conv(str):
+    if re.search(r'\set Staff.keySignature', str):
+        stderr_write ("\n")
+        stderr_write (NOT_SMART % _("The alist for Staff.keySignature is no \
+longer in reversed order.\n"))
+    str = str.replace('"orchestral strings"', '"orchestral harp"')
+    return str
+
+@rule ((2, 13, 1),
+       _ ("\\bar \".\" now produces a thick barline\n\
+ly:hairpin::after-line-breaking -> ly:spanner::kill-zero-spanned-time\n\
+Dash parameters for slurs and ties are now in dash-definition"))
+def conv(str):
+    if re.search(r'\\bar\s*"."', str):
+        stderr_write ("\n")
+        stderr_write (NOT_SMART % _("\\bar \".\" now produces a thick barline.\n"))
+        stderr_write (UPDATE_MANUALLY)
+    str = re.sub (r'ly:hairpin::after-line-breaking', r'ly:spanner::kill-zero-spanned-time', str)
+    if re.search("(Slur|Tie)\w+#\'dash-fraction", str) \
+        or re.search("(Slur|Tie)\w+#\'dash-period", str):
+        stderr_write ("\n")
+        stderr_write (NOT_SMART % _("Dash parameters for slurs and ties are now in \'dash-details.\n"))
+        stderr_write (UPDATE_MANUALLY)
+    return str
+
+@rule ((2, 13, 4),
+       _ ("Autobeaming rules have changed.  override-auto-beam-setting and\n\
+revert-auto-beam-setting have been eliminated.  \\overrideBeamSettings has been\n\
+added.  beatGrouping has been eliminated.\n\
+Different settings for vertical layout.\n\
+ly:system-start-text::print -> system-start-text::print\n\
+Beam #'thickness -> Beam #'beam-thickness\n\
+ly:note-head::brew-ez-stencil -> note-head::brew-ez-stencil\n\
+ly:ambitus::print -> ambitus::print\n\
+Explicit dynamics context definition from `Piano centered dynamics'\n\
+template replaced by new `Dynamics' context."))
+def conv(str):
+    if re.search("override-auto-beam-setting", str):
+        stderr_write ("\n")
+        stderr_write (NOT_SMART % _("override-auto-beam-setting.\n\
+   Autobeam settings are now overriden with \\overrideBeamSettings.\n"))
+        stderr_write (UPDATE_MANUALLY)
+    if re.search("revert-auto-beam-setting", str):
+        stderr_write ("\n")
+        stderr_write (NOT_SMART % _("override-auto-beam-setting.\n\
+   Autobeam settings are now reverted with \\revertBeamSettings.\n"))
+        stderr_write (UPDATE_MANUALLY)
+    str = re.sub(r"\\set\s+beatGrouping", r"\\setBeatGrouping", str)
+    if re.search(r"\w+\s*.\s*beatGrouping", str):
+        stderr_write (NOT_SMART % _("beatGrouping. \n\
+   beatGrouping with a specified context must now be accomplished with\n\
+   \\overrideBeamSettings.\n"))
+        stderr_write (UPDATE_MANUALLY)
+    if re.search(r'alignment-offsets', str):
+        stderr_write("\n")
+        stderr_write(NOT_SMART % _("alignment-offsets has been changed to alignment-distances: \
+you must now specify the distances between staves rather than the offset of staves.\n"))
+        stderr_write(UPDATE_MANUALLY)
+    str = re.sub ('ly:(system-start-text::print|note-head::brew-ez-stencil|ambitus::print)',
+                  '\\1', str)
+    str = re.sub ('(\\bBeam\\s+#\')(?=thickness\\b)', '\\1beam-', str)
+    str = re.sub (r'(\\context\s*\{{1}[^\}]+\\name\s+"*Dynamics"*[^\}]*\}{1})',
+                  '', str)
+    return str
+
+@rule ((2, 13, 10),
+       _ ("Remove obsolete engravers/translators: Note_swallow_translator,\n\
+Rest_swallow_translator, Skip_event_swallow_translator, Swallow_engraver,\n\
+Swallow_performer and String_number_engraver.\n\
+New vertical spacing variables."))
+def conv(str):
+    str = re.sub (r'\\(consists|remove)\s+"*(Swallow_(engraver|performer)|'
+                  '(Note|Rest|Skip_event)_swallow_translator|String_number_engraver)"*',
+                  '', str)
+
+    str = re.sub (r"page-top-space\s*=\s*#([0-9.]+)",
+                  r"top-system-spacing #'space = #\1",
+                  str)
+    str = re.sub (r"between-system-space\s*=\s*#([0-9.]+)",
+                  r"between-system-spacing #'space = #\1\nbetween-scores-system-spacing #'space = #\1",
+                  str)
+    str = re.sub (r"between-system-padding\s*=\s*#([0-9.]+)",
+                  r"between-system-spacing #'padding = #\1\nbetween-scores-system-spacing #'padding = #\1",
+                  str)
+    str = re.sub (r"(after|between|before)-title-space\s*=\s*#([0-9.]+)",
+                  r"\1-title-spacing #'space = #\2",
+                  str)
+
+    if re.search(r'minimum-Y-extent', str):
+        stderr_write("\n")
+        stderr_write(NOT_SMART % _("vertical spacing has been changed; minimum-Y-extent is obsolete.\n"))
+        stderr_write(UPDATE_MANUALLY)
+
+    return str
+
 # Guidelines to write rules (please keep this at the end of this file)
 #
 # - keep at most one rule per version; if several conversions should be done,
@@ -2817,5 +2993,5 @@ def conv (str):
 # - write rule for bumping major stable version with
 #
 #     _ ("bump version for release")
-#  
+#
 # as exact description.