]> git.donarmstrong.com Git - lilypond.git/blobdiff - python/convertrules.py
Merge with master
[lilypond.git] / python / convertrules.py
index ecf7532ceffda5165889cb58aa0fb940e99eb9ec..a4d47978915c0915f0b14f07694f7f5040990f9c 100644 (file)
@@ -623,13 +623,13 @@ def conv (str):
            lastx = x
        return s
 
-       def regularize_dollar_reference (match):
-           return regularize_id (match.group (1))
-       def regularize_assignment (match):
-           return '\n' + regularize_id (match.group (1)) + ' = '
-       str = re.sub ('\$([^\t\n ]+)', regularize_dollar_reference, str)
-       str = re.sub ('\n([^ \t\n]+)[ \t]*= *', regularize_assignment, str)
-       return str
+    def regularize_dollar_reference (match):
+       return regularize_id (match.group (1))
+    def regularize_assignment (match):
+       return '\n' + regularize_id (match.group (1)) + ' = '
+    str = re.sub ('\$([^\t\n ]+)', regularize_dollar_reference, str)
+    str = re.sub ('\n([^ \t\n]+)[ \t]*= *', regularize_assignment, str)
+    return str
 
 conversions.append (((1,3,117), conv, 'identifier names: $!foo_bar_123 -> xfooBarABC'))
 
@@ -2632,7 +2632,10 @@ def conv (str):
     str = re.sub (r"minimumVerticalExtent",
                  r"\\override VerticalAxisGroup #'minimum-Y-extent",
                  str)
-
+    str = re.sub (r"\\set ([a-zA-Z]*\.?)extraVerticalExtent",
+                 r"\\override \1VerticalAxisGroup #'extra-Y-extent", str)
+    str = re.sub (r"\\set ([a-zA-Z]*\.?)verticalExtent",
+                 r"\\override \1VerticalAxisGroup #'Y-extent", str)
     return str
 
 conversions.append (((2, 7, 14), conv,
@@ -2680,6 +2683,7 @@ conversions.append (((2, 7, 28), conv,
 
 def conv (str):
     for a in ['beamed-lengths', 'beamed-minimum-free-lengths',
+              'lengths',
              'beamed-extreme-minimum-free-lengths']:
        str = re.sub (r"\\override\s+Stem\s+#'%s" % a,
                      r"\\override Stem #'details #'%s" % a,
@@ -2690,7 +2694,7 @@ conversions.append (((2, 7, 29), conv,
                     """override Stem #'beamed-* -> #'details #'beamed-*"""))
 
 def conv (str):
-    str = re.sub (r'\epsfile *#"', r'\epsfile #X #10 #"', str)
+    str = re.sub (r'\\epsfile *#"', r'\\epsfile #X #10 #"', str)
     return str
 
 conversions.append (((2, 7, 30), conv,
@@ -2794,7 +2798,7 @@ def conv (str):
     str = re.sub (r'\\context\s+\"?([a-zA-Z]+)\"?\s*\\applyOutput', r"\\applyOutput #'\1", str)
     return str
 
-conversions.append (((2, 9, 6), conv, """\context Foo \applyOutput #bla -> \applyOutput #'Foo #bla """))
+conversions.append (((2, 9, 6), conv, """\context Foo \\applyOutput #bla -> \\applyOutput #'Foo #bla """))
 
 
 def conv (str):
@@ -2806,3 +2810,144 @@ def conv (str):
 conversions.append (((2, 9, 9), conv, """annotatefoo -> annotate-foo"""))
 
 
+def conv (str):
+    str = re.sub (r"""(\\set\s)?(?P<context>[a-zA-Z]*.?)tupletNumberFormatFunction\s*=\s*#denominator-tuplet-formatter""",
+                  r"""\\override \g<context>TupletNumber #'text = #tuplet-number::calc-denominator-text""", str)
+
+    str = re.sub (r"""(\\set\s+)?(?P<context>[a-zA-Z]*.?)tupletNumberFormatFunction\s*=\s*#fraction-tuplet-formatter""",
+                  r"""\\override \g<context>TupletNumber #'text = #tuplet-number::calc-fraction-text""", str)
+
+    if re.search ('tupletNumberFormatFunction', str):
+        error_file.write ("\n")
+       error_file.write ("tupletNumberFormatFunction has been removed. Use #'text property on TupletNumber")
+        error_file.write ("\n")
+        
+    return str
+
+conversions.append (((2, 9, 11), conv, """\\set tupletNumberFormatFunction -> \\override #'text = """))
+
+
+def conv (str):
+    str = re.sub ('vocNam', 'shortVocalName', str)
+    str = re.sub (r'\.instr\s*=', r'.shortInstrumentName =', str)
+    str = re.sub (r'\.instrument\s*=', r'.instrumentName =', str)
+    return str
+
+conversions.append (((2, 9, 13), conv, """instrument -> instrumentName, instr -> shortInstrumentName, vocNam -> shortVocalName"""))
+
+
+def conv (str):
+
+    def sub_tempo (m):
+        dur = int (m.group (1))
+        dots = len (m.group (2))
+        count = int (m.group (3))
+
+        log2 = 0
+        while dur > 1 :
+            dur /= 2
+            log2 += 1
+        
+        den = (1 << dots) * (1 << log2)
+        num = ((1 << (dots+1))  - 1)
+
+        return  """
+  \midi {
+    \context {
+      \Score
+      tempoWholesPerMinute = #(ly:make-moment %d %d)
+      }
+    }
+
+""" % (num*count, den)
+    
+    str = re.sub (r'\\midi\s*{\s*\\tempo ([0-9]+)\s*([.]*)\s*=\s*([0-9]+)\s*}', sub_tempo, str)
+    return str
+
+conversions.append (((2, 9, 16), conv, """deprecate \\tempo in \\midi"""))
+
+def conv (str):
+    str = re.sub ('printfirst-page-number', 'print-first-page-number', str)
+    return str
+
+conversions.append (((2, 9, 19), conv, """printfirst-page-number -> print-first-page-number"""))
+
+
+def conv (str):
+    return str
+
+conversions.append (((2, 10, 0), conv, """bump version for release"""))
+
+
+def conv (str):
+    return re.sub ('ly:clone-parser',
+                   'ly:parser-clone', str)
+
+conversions.append (((2, 11, 2), conv, """ly:clone-parser -> ly:parser-clone"""))
+
+
+
+def conv (str):
+    str = re.sub ("Accidental\s*#'cautionary-style\s*=\s*#'smaller",
+                   "AccidentalCautionary #'font-size = #-2", str)
+    str = re.sub ("Accidental\s*#'cautionary-style\s*=\s*#'parentheses",
+                   "AccidentalCautionary #'parenthesized = ##t", str)
+    str = re.sub ("([A-Za-z]+)\s*#'cautionary-style\s*=\s*#'parentheses",
+                   r"\1 #'parenthesized = ##t", str)
+    str = re.sub ("([A-Za-z]+)\s*#'cautionary-style\s*=\s*#'smaller",
+                   r"\1 #'font-size = #-2", str)
+    
+    return str
+
+conversions.append (((2, 11, 5), conv, """deprecate cautionary-style. Use AccidentalCautionary properties"""))
+
+                    
+
+
+def conv (str):
+    
+    def sub_acc_name (m):
+        idx = int (m.group (1).replace ('M','-'))
+        
+        return ["accidentals.doublesharp",
+                "accidentals.sharp.slashslash.stemstemstem",
+                "accidentals.sharp",
+                "accidentals.sharp.slashslash.stem",
+                "accidentals.natural",
+                "accidentals.mirroredflat",
+                "accidentals.flat",
+                "accidentals.mirroredflat.flat",
+                "accidentals.flatflat"][4-idx]
+
+    str = re.sub (r"accidentals[.](M?[-0-9]+)",
+                  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)
+            
+    return str
+
+conversions.append (((2, 11, 6), conv, """Rename accidental glyphs, use glyph-name-alist."""))
+
+
+def conv (str):
+    str = re.sub (r'(\\set\s+)?([A-Z][a-zA-Z]+\s*\.\s*)allowBeamBreak',
+                  r"\override \2Beam #'breakable", str)
+    str = re.sub (r'(\\set\s+)?allowBeamBreak',
+                  r"\override Beam #'breakable", str)
+    str = re.sub (r'addquote' , 'addQuote', str)
+    if re.search ("Span_dynamic_performer", str):
+        error_file.write ("Span_dynamic_performer has been merged into Dynamic_performer")
+
+    return str
+
+conversions.append (((2, 11, 10), conv, """allowBeamBreak -> Beam #'breakable = ##t
+addquote -> addQuote
+
+"""))
+
+def conv (str):
+    str = re.sub (r'\(layout-set-staff-size \(\*\s*([0-9.]+)\s*(pt|mm|cm)\)\)',
+                  r'(layout-set-absolute-staff-size (* \1 \2))', str)
+    return str
+
+conversions.append (((2, 11, 11), conv, """layout-set-staff-size -> layout-set-absolute-staff-size"""))