]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/convert-ly.py
release: 1.3.122
[lilypond.git] / scripts / convert-ly.py
index 5a86f0ce617c8555ff7755f768c48aadeb0857e5..0c0505f58bb3784915e94cef2ddcdd3d57e3a85b 100644 (file)
@@ -570,17 +570,74 @@ if 1:
 
                return str
        
-       conversions.append (((1,3,110), conv, '\\push -> \\override, \\pop -> \\revert'))
+       conversions.append (((1,3,111), conv, '\\push -> \\override, \\pop -> \\revert'))
 
 if 1:
        def conv (str):
                str = re.sub ('LyricVoice', 'LyricsVoice', str)
                # old fix
-               str = re.sub ('ChordNames*.ChordNames*', 'Chordnames.Chordname', str)
+               str = re.sub ('Chord[Nn]ames*.Chord[Nn]ames*', 'ChordNames.ChordName', str)
                return str
        
        conversions.append (((1,3,113), conv, 'LyricVoice -> LyricsVoice'))
 
+def regularize_id (str):
+       s = ''
+       lastx = ''
+       for x in str:
+               if x == '_':
+                       lastx = x
+                       continue
+               elif x in string.digits:
+                       x = chr(ord (x) - ord ('0')  +ord ('A'))
+               elif x not in string.letters:
+                       x = 'x'
+               elif x in string.lowercase and lastx == '_':
+                       x = string.upper (x)
+               s = s + x
+               lastx = x
+       return s
+
+if 1:
+       def conv (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]+) = ', regularize_assignment, str)
+               return str
+       
+       conversions.append (((1,3,117), conv, 'identifier names: $!foo_bar_123 -> xfooBarABC'))
+
+
+if 1:
+       def conv (str):
+               def regularize_paper (match):
+                       return regularize_id (match.group (1))
+               
+               str = re.sub ('(paper_[a-z]+)', regularize_paper, str)
+               str = re.sub ('sustainup', 'sustainUp', str)
+               str = re.sub ('nobreak', 'noBreak', str)
+               str = re.sub ('sustaindown', 'sustainDown', str)
+               str = re.sub ('sostenutoup', 'sostenutoUp', str)
+               str = re.sub ('sostenutodown', 'sostenutoDown', str)
+               str = re.sub ('unachorda', 'unaChorda', str)
+               str = re.sub ('trechorde', 'treChorde', str)
+       
+               return str
+       
+       conversions.append (((1,3,120), conv, 'paper_xxx -> paperXxxx, pedalup -> pedalUp.'))
+
+if 1:
+       def conv (str):
+               str = re.sub ('drarnChords', 'chordChanges', str)
+               str = re.sub ('\\musicalpitch', '\\pitch', str)
+               return str
+       
+       conversions.append (((1,3,122), conv, 'drarnChords -> chordChanges, \\musicalpitch -> \\pitch'))
+
 
 ############################
        
@@ -611,9 +668,9 @@ def do_conversion (infile, from_version, outfile, to_version):
 
        if last_conversion:
                sys.stderr.write ('\n')
-               new_ver =  '\\\\version \"%s\"' % tup_to_str (last_conversion)
+               new_ver =  '\\version \"%s\"' % tup_to_str (last_conversion)
                if re.search (lilypond_version_re_str, str):
-                       str = re.sub (lilypond_version_re_str,new_ver , str)
+                       str = re.sub (lilypond_version_re_str,'\\'+new_ver , str)
                else:
                        str = new_ver + '\n' + str