]> git.donarmstrong.com Git - lilypond.git/blobdiff - python/convertrules.py
*** empty log message ***
[lilypond.git] / python / convertrules.py
index 6f99647b16ccd9740c71e80871eddd9d7a47a2c4..ad4ab9ae1db92d3665d7f47666a2f40ec14842fc 100644 (file)
@@ -15,13 +15,7 @@ class FatalConversionError:
        pass
 
 conversions = []
-
 error_file = sys.stderr 
-lilypond_version_re_str = '\\\\version *\"([^"]+)\"'
-lilypond_version_re = re.compile (lilypond_version_re_str)
-
-
-
 
 def conv(str):
        if re.search ('\\\\multi', str):
@@ -1818,7 +1812,11 @@ conversions.append (((2,1,18), conv, """\\newpartcombine -> \\partcombine,
 
 
 def conv (str):
+       if re.search ('include "drumpitch', str):
+               error_file.write ("Drums found. Enclose drum notes in \\drummode")
+               
        str = re.sub (r'\\include "drumpitch-init.ly"','', str)
+       
        str = re.sub (r'\\pitchnames ','pitchnames = ', str)
        str = re.sub (r'\\chordmodifiers ','chordmodifiers = ', str)
        str = re.sub (r'\bdrums\b\s*=','drumContents = ', str)
@@ -2249,8 +2247,8 @@ def conv (str):
        return str
 
 conversions.append (((2, 3, 16), conv,
-                    '''\foo -> \foomode (for chords, notes, etc.)
-fold \new FooContext \foomode into \foo.'''))
+                    '''\\foo -> \\foomode (for chords, notes, etc.)
+fold \\new FooContext \\foomode into \\foo.'''))
 
 def conv (str):
        str = re.sub (r'(slur|stem|phrasingSlur|tie|dynamic|dots|tuplet|arpeggio|)Both', r'\1Neutral', str)
@@ -2259,8 +2257,8 @@ def conv (str):
        return str
 
 conversions.append (((2, 3, 17), conv,
-                    '''\foo -> \foomode (for chords, notes, etc.)
-fold \new FooContext \foomode into \foo.'''))
+                    '''\\foo -> \\foomode (for chords, notes, etc.)
+fold \\new FooContext \\foomode into \\foo.'''))
 
 
 def conv (str):
@@ -2555,3 +2553,189 @@ conversions.append (((2, 7, 6), conv,
                     '''Performer_group_performer -> Performer_group, Engraver_group_engraver -> Engraver_group
 inside-slur -> avoid-slur'''))
 
+
+
+def conv (str):
+       str = re.sub(r'\\applyoutput', r'\\applyOutput', str)
+       str = re.sub(r'\\applycontext', r'\\applyContext', str)
+       str = re.sub(r'\\applymusic',  r'\\applyMusic', str)
+       str = re.sub(r'ly:grob-suicide', 'ly:grob-suicide!', str)
+       return str
+
+conversions.append (((2, 7, 10), conv,
+                    '''\\applyxxx -> \\applyXxx'''))
+
+
+
+def conv (str):
+       str = re.sub(r'\"tabloid\"', '"11x17"', str)
+       return str
+
+conversions.append (((2, 7, 11), conv,
+                    '''\"tabloid\" -> \"11x17\"'''))
+
+def conv (str):
+       str = re.sub(r'outputProperty' , 'overrideProperty', str)
+       return str
+
+conversions.append (((2, 7, 12), conv,
+                    '''outputProperty -> overrideProperty'''))
+
+
+def conv (str):
+       def subber (match):
+               newkey = {'spacing-procedure': 'springs-and-rods',
+                         'after-line-breaking-callback' : 'after-line-breaking',
+                         'before-line-breaking-callback' : 'before-line-breaking',
+                         'print-function' : 'stencil'} [match.group(3)]
+               what = match.group (1)
+               grob = match.group (2)
+
+               if what == 'revert':
+                       return "revert %s #'callbacks %% %s\n" % (grob, newkey)
+               elif what == 'override':
+                       return "override %s #'callbacks #'%s" % (grob, newkey)
+               else:
+                       raise 'urg'
+                       return ''
+               
+       str = re.sub(r"(override|revert)\s*([a-zA-Z.]+)\s*#'(spacing-procedure|after-line-breaking-callback"
+                   + r"|before-line-breaking-callback|print-function)",
+                   subber, str)
+
+       if re.search ('bar-size-procedure', str):
+               error_file.write (NOT_SMART % "bar-size-procedure")
+       if re.search ('space-function', str):
+               error_file.write (NOT_SMART % "space-function")
+       if re.search ('verticalAlignmentChildCallback', str):
+               error_file.write ('verticalAlignmentChildCallback has been deprecated') 
+       return str
+
+conversions.append (((2, 7, 13), conv,
+                    '''layout engine refactoring. [FIXME] '''))
+
+
+
+def conv (str):
+       str = re.sub (r"\\override +([A-Z.a-z]+) #'callbacks",
+                     r"\\override \1", str)
+       str = re.sub (r"\\revert ([A-Z.a-z]+) #'callbacks % ([a-zA-Z]+)",
+                     r"\\revert \1 #'\2", str)
+       str = re.sub (r"([XY]-extent)-callback", r'\1', str)
+       str = re.sub (r"RemoveEmptyVerticalGroup", "VerticalAxisGroup", str)
+       str = re.sub (r"\\set ([a-zA-Z]*\.?)minimumVerticalExtent",
+                     r"\\override \1VerticalAxisGroup #'minimum-Y-extent",
+                     str)
+       str = re.sub (r"minimumVerticalExtent",
+                     r"\\override VerticalAxisGroup #'minimum-Y-extent",
+                     str)
+       
+       return str
+
+conversions.append (((2, 7, 14), conv,
+                    '''Remove callbacks property, deprecate XY-extent-callback. '''))
+
+
+def conv (str):
+       if re.search ('[XY]-offset-callbacks', str):
+               error_file.write (NOT_SMART % "[XY]-offset-callbacks")
+       if re.search ('position-callbacks', str):
+               error_file.write (NOT_SMART % "position-callbacks")
+       return str
+
+conversions.append (((2, 7, 15), conv,
+                    '''Use grob closures iso. XY-offset-callbacks.'''))
+
+
+def conv (str):
+       def sub_syms (m):
+               syms =  m.group (1).split ()
+               tags = ["\\tag #'%s" % s for s in syms]
+               return ' '.join (tags)
+               
+       str = re.sub (r"\\tag #'\(([^)]+)\)",  sub_syms, str)
+       return str
+
+conversions.append (((2, 7, 22), conv,
+                    """\tag #'(a b) -> \tag #'a \tag #'b""" ))
+
+def conv (str):
+       str = re.sub (r"#'number-visibility",
+                     "#'number-visibility % number-visibility is deprecated. Tune the TupletNumber instead\n",
+                     str)
+       return str
+
+conversions.append (((2, 7, 24), conv,
+                    """deprecate number-visibility""")) 
+
+def conv (str):
+       str = re.sub (r"ly:spanner-get-bound", "ly:spanner-bound", str)
+       return str
+
+conversions.append (((2, 7, 28), conv,
+                    """ly:spanner-get-bound -> ly:spanner-bound"""))
+
+def conv (str):
+       str = re.sub (r'\epsfile *#"', r'\epsfile #X #10 #"', str)
+       return str
+
+conversions.append (((2, 7, 30), conv,
+                    """\\epsfile"""))
+
+
+def conv (str):
+       def sub_cxx_id (m):
+               str = m.group(1)
+               return 'ly:' + str.lower ().replace ('_','-')
+               
+       str = re.sub (r'([A-Z][a-z_0-9]+::[a-z_0-9]+)',
+                     sub_cxx_id, str)
+       return str
+
+conversions.append (((2, 7, 31), conv,
+                    """Foo_bar::bla_bla -> ly:foo-bar::bla-bla"""))
+
+
+def conv (str):
+       identifier_subs = [
+               ('inputencoding', 'input-encoding'),
+               ('printpagenumber', 'print-page-number'),
+               ('outputscale', 'output-scale'),
+               ('betweensystemspace', 'between-system-space'),
+               ('betweensystempadding', 'between-system-padding'),
+               ('pagetopspace', 'page-top-space'),
+               ('raggedright', 'ragged-right'),
+               ('raggedbottom', 'ragged-bottom'),
+               ('raggedlastbottom', 'ragged-last-bottom'),
+               ('aftertitlespace', 'after-title-space'),
+               ('beforetitlespace', 'before-title-space'),
+               ('betweentitlespace', 'between-title-space'),
+               ('topmargin', 'top-margin'),
+               ('bottommargin', 'bottom-margin'),
+               ('headsep', 'head-separation'),
+               ('footsep', 'foot-separation'),
+               ('rightmargin', 'right-margin'),
+               ('leftmargin', 'left-margin'),
+               ('printfirstpagenumber', 'print-first-page-number'),
+               ('firstpagenumber', 'first-page-number'),
+               ('hsize', 'paper-width'),
+               ('vsize', 'paper-height'),
+               ('horizontalshift', 'horizontal-shift'),
+               ('staffspace', 'staff-space'),
+               ('linethickness', 'line-thickness'),
+               ('ledgerlinethickness', 'ledger-line-thickness'),
+               ('blotdiameter', 'blot-diameter'),
+               ('staffheight', 'staff-height'),
+               ('linewidth', 'line-width'),
+               ('annotatespacing', 'annotate-spacing')
+               ]
+       
+       for (a,b)  in identifier_subs:
+               ### for C++:
+               ## str = re.sub ('"%s"' % a, '"%s"' b, str)
+               
+               str = re.sub (a, b, str)
+       return str
+
+conversions.append (((2, 7, 32), conv,
+                    """foobar -> foo-bar for \paper, \layout"""))