]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/convert-ly.py
ly- -> ly:
[lilypond.git] / scripts / convert-ly.py
index c05e3e0f61424310ad743f52f7f3b4c531ab1216..7223cc30a2195555ac49acf24a0bd192376854c6 100644 (file)
@@ -840,6 +840,35 @@ if 1:
        
        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'))
+       
+
 if 1:
        def conv (str):
                str = re.sub ('noAutoBeaming *= *##f', 'autoBeaming = ##t', str)
@@ -848,6 +877,13 @@ if 1:
        
        conversions.append (((1,5,49), conv, 'noAutoBeaming -> autoBeaming'))
 
+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'))
 
 if 1:
        def conv (str):
@@ -855,7 +891,7 @@ if 1:
 
                return str
        
-       conversions.append (((1,5,56), conv, 'Pitch::transpose->ly-transpose-pitch'))
+       conversions.append (((1,5,56), conv, 'Pitch::transpose -> ly-transpose-pitch'))
 
 if 1:
        def conv (str):
@@ -866,6 +902,173 @@ if 1:
        conversions.append (((1,5,58), conv, 'deprecate textNonEmpty'))
 
 
+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
+
+       conversions.append (((1,5,59), conv,
+       'XxxxVerticalExtent -> xxxVerticalExtent'))
+
+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'))
+       
+
+if 1:
+       def conv (str):
+               if re.search (r'\addlyrics',str) \
+                      and re.search ('automaticMelismata', str)  == None:
+                       sys.stderr.write  ('automaticMelismata is turned on by default since 1.5.67. Please fix this by hand.')
+                       raise FatalConversionError()
+               return str
+
+       conversions.append (((1,5,67), conv,
+                            'automaticMelismata turned on by default'))
+
+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
+       
+       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'))
+
+
+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!'))
+
+
+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'))
+
+
+if 1:
+       def subst_req_name (match):
+               return "(make-music-by-name \'%sEvent)" % regularize_id (match.group(1))
+
+       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:
+       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',
+                       ]
+
+               origre = r'\b(%s)' % string.join (changed, '|')
+               
+               str = re.sub (origre, r'ly:\1',str)
+               return str
+       
+       conversions.append (((1,7,3), conv, 'ly- -> ly:'))
+       
 ################################
 #      END OF CONVERSIONS      
 ################################