]> git.donarmstrong.com Git - lilypond.git/blobdiff - python/convertrules.py
Merge branch 'master' of ssh://jomand@git.sv.gnu.org/srv/git/lilypond into lilypond...
[lilypond.git] / python / convertrules.py
index 1214b8a7c4b271d6e070193eadbff7fe93129c33..ad2c0cdd96500bb361b89f155717df6b8d8c468f 100644 (file)
@@ -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)
@@ -2622,7 +2622,7 @@ def conv (str):
                   r"\override \2Beam #'breakable", str)
     str = re.sub (r'(\\set\s+)?allowBeamBreak',
                   r"\override Beam #'breakable", str)
-    str = re.sub (r'addquote' , 'addQuote', str)
+    str = re.sub (r'addquote', 'addQuote', str)
     if re.search ("Span_dynamic_performer", str):
         stderr_write ("Span_dynamic_performer has been merged into Dynamic_performer")
 
@@ -2650,7 +2650,7 @@ 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 = ...")
 def conv (str):
     def sub_edge_height (m):
         s = ''
@@ -2658,20 +2658,22 @@ def conv (str):
                          ('right', m.group (4))]:
 
             if h and float (h):
-                once = m.group(1)
+                once = m.group (1)
                 if not once:
                     once = ''
+                context = m.group (2)
+                if not context:
+                    context = ''
                     
-                s += (r"%s \override %s #'bound-details #'%s #'text = \markup { \draw-line #'(0 . %s) }"
-                      % (once, m.group (2), var, h))
+                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)
     return str
 
 
@@ -2727,18 +2729,16 @@ def conv (str):
     return str
 
 
-@rule ((2, 11, 50), "metronomeMarkFormatter uses text markup as second argument")
+@rule ((2, 11, 50), _ ("metronomeMarkFormatter uses text markup as second argument,\n\
+fret diagram properties moved to fret-diagram-details."))
 def conv (str):
+    ## warning 1/2: metronomeMarkFormatter uses text markup as second argument
     if re.search ('metronomeMarkFormatter', str):
        stderr_write (NOT_SMART % _ ("metronomeMarkFormatter got an additional text argument.\n"))
        stderr_write (_ ("The function assigned to Score.metronomeMarkFunction now uses the signature\n%s") %
                           "\t(format-metronome-markup text dur count context)\n")
-    return str
-
-conversions.append (((2, 11, 50), conv, """metronomeMarkFormatter uses text markup as second argument"""))
-
 
-def conv (str):
+    ## warning 2/2: fret diagram properties moved to fret-diagram-details
     fret_props = ['barre-type', 
                 'dot-color', 
                 'dot-radius',
@@ -2752,12 +2752,127 @@ def conv (str):
                 'open-string',
                 'orientation']
     for prop in fret_props:
-      if re.search ( prop, str):
-          stderr_write ('\n')
+      if re.search (prop, str):
           stderr_write (NOT_SMART %
             prop + " in fret-diagram properties. Use fret-diagram-details.")
           stderr_write ('\n')
     return str
 
-conversions.append (((2, 11, 50), conv, """Fret diagram properties moved to fret-diagram-details"""))
+@rule ((2, 11, 51), "\\octave -> \\octaveCheck, \\arpeggioUp -> \\arpeggioArrowUp,\n\
+\\arpeggioDown -> \\arpeggioArrowDown, \\arpeggioNeutral -> \\arpeggioNormal,\n\
+\\setTextCresc -> \\crescTextCresc, \\setTextDecresc -> \\dimTextDecresc,\n\
+\\setTextDecr -> \\dimTextDecr, \\setTextDim -> \\dimTextDim,\n\
+\\setHairpinCresc -> \\crescHairpin, \\setHairpinDecresc -> \\dimHairpin,\n\
+\\sustainUp -> \\sustainOff, \\sustainDown -> \\sustainOn\n\
+\\sostenutoDown -> \\sostenutoOn, \\sostenutoUp -> \\sostenutoOff")
+def conv (str):
+    str = re.sub (r"\\octave", 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)
+    str = re.sub (r"setTextCresc", r"crescTextCresc", str)
+    str = re.sub (r"setTextDecresc", r"dimTextDecresc", str)
+    str = re.sub (r"setTextDecr", r"dimTextDecr", str)
+    str = re.sub (r"setTextDim", r"dimTextDim", str)
+    str = re.sub (r"setHairpinCresc", r"crescHairpin", str)
+    str = re.sub (r"setHairpinDecresc", r"dimHairpin", str)
+    str = re.sub (r"sustainUp", r"sustainOff", str)
+    str = re.sub (r"sustainDown", r"sustainOn", str)
+    str = re.sub (r"sostenutoDown", r"sostenutoOn", str)
+    str = re.sub (r"sostenutoUp", r"sostenutoOff", str)
+    return str
 
+@rule ((2, 11, 52), "\\setHairpinDim -> \\dimHairpin")
+def conv (str):
+    str = str.replace ("setHairpinDim", "dimHairpin")
+    return str
+
+@rule ((2, 11, 53), "infinite-spacing-height -> extra-spacing-height")
+def conv (str):
+    str = re.sub (r"infinite-spacing-height\s+=\s+##t", r"extra-spacing-height = #'(-inf.0 . +inf.0)", str)
+    str = re.sub (r"infinite-spacing-height\s+=\s+##f", r"extra-spacing-height = #'(0 . 0)", str)
+    return 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):    
+    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"))
+       stderr_write (_ ("Axis and direction now come before markups:\n"))
+       stderr_write (_ ("\\put-adjacent axis dir markup markup."))
+    return str
+
+@rule ((2, 11, 57), "\\center-align -> \\center-column, \\hcenter -> \\center-align")
+def conv (str):
+    str = re.sub (r"([\\:]+)center-align", r"\1center-column", 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
+
+# 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,
+# concatenate them into a single "conv" function;
+#
+# - enclose strings to be localized with `_(' and  `)';
+#
+# - write rule for bumping major stable version with
+#
+#     _ ("bump version for release")
+#  
+# as exact description.