############################
if 1: # need new a namespace
- def conv (lines):
+ def conv (str):
if re.search ('\\\\octave', str):
sys.stderr.write ('\nNot smart enough to convert \\octave')
raise FatalConversionError()
if 1: # need new a namespace
- def conv (lines):
- x = re.sub ('\\\\textstyle([^;]+);',
+ def conv (str):
+ str = re.sub ('\\\\textstyle([^;]+);',
'\\\\property Lyrics . textstyle = \\1', str)
- x = re.sub ('\\\\key([^;]+);', '\\\\accidentals \\1;', str)
+ str = re.sub ('\\\\key([^;]+);', '\\\\accidentals \\1;', str)
return str
if 1:
- def conv (lines):
- x = re.sub ('\\\\musical_pitch', '\\\\musicalpitch',str)
- x = re.sub ('\\\\meter', '\\\\time',str)
+ def conv (str):
+ str = re.sub ('\\\\musical_pitch', '\\\\musicalpitch',str)
+ str = re.sub ('\\\\meter', '\\\\time',str)
return str
'\\meter -> \\time'))
if 1:
- def conv (lines):
+ def conv (str):
return lines
conversions.append (
if 1:
- def conv (lines):
- x = re.sub ('\\\\accidentals', '\\\\keysignature',str)
- x = re.sub ('specialaccidentals *= *1', 'keyoctaviation = 0',str)
- x = re.sub ('specialaccidentals *= *0', 'keyoctaviation = 1',str)
+ def conv (str):
+ str = re.sub ('\\\\accidentals', '\\\\keysignature',str)
+ str = re.sub ('specialaccidentals *= *1', 'keyoctaviation = 0',str)
+ str = re.sub ('specialaccidentals *= *0', 'keyoctaviation = 1',str)
return str
'specialaccidentals -> keyoctaviation'))
if 1:
- def conv(lines):
+ def conv(str):
if re.search ('\\\\header', lines):
sys.stderr.write ('\nNot smart enough to convert to new \\header format')
return lines
conversions.append ((1,0,2), conv, '\\header { key = concat + with + operator }')
if 1:
- def conv(lines):
- x = re.sub ('\\\\melodic', '\\\\notes',str)
+ def conv(str):
+ str = re.sub ('\\\\melodic', '\\\\notes',str)
return str
conversions.append ((1,0,3), conv, '\\melodic -> \\notes')
if 1:
- def conv(lines):
- x = re.sub ('default_paper *=', '',str)
- x = re.sub ('default_midi *=', '',x)
+ def conv(str):
+ str = re.sub ('default_paper *=', '',str)
+ str = re.sub ('default_midi *=', '',x)
return str
conversions.append ((1,0,4), conv, 'default_{paper,midi}')
if 1:
- def conv(lines):
- x = re.sub ('ChoireStaff', 'ChoirStaff',str)
- x = re.sub ('\\output', 'output = ',str)
+ def conv(str):
+ str = re.sub ('ChoireStaff', 'ChoirStaff',str)
+ str = re.sub ('\\output', 'output = ',str)
return str
conversions.append ((1,0,5), conv, 'ChoireStaff -> ChoirStaff')
if 1:
- def conv(lines):
+ def conv(str):
if re.search ('[a-zA-Z]+ = *\\translator',str):
sys.stderr.write ('\nNot smart enough to change \\translator syntax')
raise FatalConversionError()
if 1:
- def conv(lines):
- x = re.sub ('\\\\lyric', '\\\\lyrics',str)
+ def conv(str):
+ str = re.sub ('\\\\lyric', '\\\\lyrics',str)
return str
conversions.append ((1,0,7), conv, '\\lyric -> \\lyrics')
if 1:
- def conv(lines):
- x = re.sub ('\\\\\\[/3+', '\\\\times 2/3 { ',str)
- x = re.sub ('\\[/3+', '\\\\times 2/3 { [',str)
- x = re.sub ('\\\\\\[([0-9/]+)', '\\\\times \\1 {',str)
- x = re.sub ('\\[([0-9/]+)', '\\\\times \\1 { [',str)
- x = re.sub ('\\\\\\]([0-9/]+)', '}', str)
- x = re.sub ('\\\\\\]', '}',str)
- x = re.sub ('\\]([0-9/]+)', '] }', str)
+ def conv(str):
+ str = re.sub ('\\\\\\[/3+', '\\\\times 2/3 { ',str)
+ str = re.sub ('\\[/3+', '\\\\times 2/3 { [',str)
+ str = re.sub ('\\\\\\[([0-9/]+)', '\\\\times \\1 {',str)
+ str = re.sub ('\\[([0-9/]+)', '\\\\times \\1 { [',str)
+ str = re.sub ('\\\\\\]([0-9/]+)', '}', str)
+ str = re.sub ('\\\\\\]', '}',str)
+ str = re.sub ('\\]([0-9/]+)', '] }', str)
return str
conversions.append ((1,0,10), conv, '[2/3 ]1/1 -> \\times 2/3 ')
if 1:
- def conv(lines):
+ def conv(str):
return lines
conversions.append ((1,0,12), conv, 'Chord syntax stuff')
if 1:
- def conv(lines):
+ def conv(str):
- x = re.sub ('<([^>~]+)~([^>]*)>','<\\1 \\2> ~', str)
+ str = re.sub ('<([^>~]+)~([^>]*)>','<\\1 \\2> ~', str)
return str
conversions.append ((1,0,13), conv, '<a ~ b> c -> <a b> ~ c')
if 1:
- def conv(lines):
- x = re.sub ('<\\[','[<', str)
- x = re.sub ('\\]>','>]', str)
+ def conv(str):
+ str = re.sub ('<\\[','[<', str)
+ str = re.sub ('\\]>','>]', str)
return str
if 1:
- def conv(lines):
- x = re.sub ('\\\\type','\\\\context', str)
- x = re.sub ('textstyle','textStyle', str)
+ def conv(str):
+ str = re.sub ('\\\\type','\\\\context', str)
+ str = re.sub ('textstyle','textStyle', str)
return str
if 1:
- def conv(lines):
+ def conv(str):
if re.search ('\\\\repeat',str):
sys.stderr.write ('\nNot smart enough to convert \\repeat')
raise FatalConversionError()
'\\repeat NUM Music Alternative -> \\repeat FOLDSTR Music Alternative')
if 1:
- def conv(lines):
- x = re.sub ('SkipBars','skipBars', str)
- x = re.sub ('fontsize','fontSize', str)
- x = re.sub ('midi_instrument','midiInstrument', x)
+ def conv(str):
+ str = re.sub ('SkipBars','skipBars', str)
+ str = re.sub ('fontsize','fontSize', str)
+ str = re.sub ('midi_instrument','midiInstrument', x)
return str
if 1:
- def conv(lines):
- x = re.sub ('tieydirection','tieVerticalDirection', str)
- x = re.sub ('slurydirection','slurVerticalDirection', str)
- x = re.sub ('ydirection','verticalDirection', x)
+ def conv(str):
+ str = re.sub ('tieydirection','tieVerticalDirection', str)
+ str = re.sub ('slurydirection','slurVerticalDirection', str)
+ str = re.sub ('ydirection','verticalDirection', x)
return str
if 1:
- def conv(lines):
- x = re.sub ('hshift','horizontalNoteShift', str)
+ def conv(str):
+ str = re.sub ('hshift','horizontalNoteShift', str)
return str
if 1:
- def conv(lines):
- x = re.sub ('\\\\grouping[^;]*;','', str)
+ def conv(str):
+ str = re.sub ('\\\\grouping[^;]*;','', str)
return str
if 1:
- def conv(lines):
- x = re.sub ('\\\\wheel','\\\\coda', str)
+ def conv(str):
+ str = re.sub ('\\\\wheel','\\\\coda', str)
return str
'\\wheel -> \\coda')
if 1:
- def conv(lines):
- x = re.sub ('keyoctaviation','keyOctaviation', str)
- x = re.sub ('slurdash','slurDash', str)
+ def conv(str):
+ str = re.sub ('keyoctaviation','keyOctaviation', str)
+ str = re.sub ('slurdash','slurDash', str)
return str
'slurdash -> slurDash, keyoctaviation -> keyOctaviation')
if 1:
- def conv(lines):
- x = re.sub ('\\\\repeat *\"?semi\"?','\\\\repeat "volta"', str)
+ def conv(str):
+ str = re.sub ('\\\\repeat *\"?semi\"?','\\\\repeat "volta"', str)
return str
if 1:
- def conv(lines):
- x = re.sub ('\"?beamAuto\"? *= *\"?0?\"?','noAutoBeaming = "1"', str)
+ def conv(str):
+ str = re.sub ('\"?beamAuto\"? *= *\"?0?\"?','noAutoBeaming = "1"', str)
return str
'beamAuto -> noAutoBeaming')
if 1:
- def conv(lines):
- x = re.sub ('automaticMelismas', 'automaticMelismata', str)
+ def conv(str):
+ str = re.sub ('automaticMelismas', 'automaticMelismata', str)
return str
'automaticMelismas -> automaticMelismata')
if 1:
- def conv(lines):
- x = re.sub ('dynamicDir', 'dynamicDirection', str)
+ def conv(str):
+ str = re.sub ('dynamicDir\\b', 'dynamicDirection', str)
return str
conversions.append ((1,2,1), conv,
'dynamicDir -> dynamicDirection')
+if 1:
+ def conv(str):
+ str = re.sub ('\\\\cadenza *0 *;', '\\\\cadenzaOff', str)
+ str = re.sub ('\\\\cadenza *1 *;', '\\\\cadenzaOn', str)
+
+ return str
+
+ conversions.append ((1,3,4), conv,
+ '\\cadenza -> \cadenza{On|Off}')
+
+if 1:
+ def conv (str):
+ str = re.sub ('beamAuto([^=]+)= *"([0-9]+)/([0-9]+)" *;',
+ 'beamAuto\\1 = #(make-moment \\2 \\3)',
+ str)
+ return str
+
+ conversions.append ((1,3,5), conv, 'beamAuto moment properties')
+
+if 1:
+ def conv (str):
+ str = re.sub ('stemStyle',
+ 'flagStyle',
+ str)
+ return str
+
+ conversions.append ((1,3,17), conv, 'stemStyle -> flagStyle')
+
+if 1:
+ def conv (str):
+ str = re.sub ('staffLineLeading',
+ 'staffSpace',
+ str)
+ return str
+
+ conversions.append ((1,3,18), conv, 'staffLineLeading -> staffSpace')
+
+if 1:
+ def conv (str):
+ str = re.sub ('textEmptyDimension *= *##t',
+ 'textNonEmpty = ##f',
+ str)
+ str = re.sub ('textEmptyDimension *= *##f',
+ 'textNonEmpty = ##t',
+ str)
+ return str
+
+ conversions.append ((1,3,35), conv, 'textEmptyDimension -> textNonEmpty')
+
############################
conv_list = get_conversions (from_version, to_version)
sys.stderr.write ('Applying conversions: ')
- str = infile.read (-1)
+ str = infile.read ()
last_conversion = ()
try:
for x in conv_list:
if last_conversion:
sys.stderr.write ('\n')
new_ver = '\\\\version \"%s\"' % tup_to_str (last_conversion)
- if re.search (mudela_version_re_str):
+ if re.search (mudela_version_re_str, str):
str = re.sub (mudela_version_re_str,new_ver , str)
else:
str = new_ver + '\n' + str
outfile.write(str)
+ return last_conversion
+
class UnknownVersion:
pass
else:
outfile = sys.stdout
-
- do_conversion (infile, from_version, outfile, to_version)
+ touched = do_conversion (infile, from_version, outfile, to_version)
if infile_name:
infile.close ()
if outfile_name:
outfile.close ()
- if __main__.edit:
+ if __main__.edit and touched:
try:
os.remove(infile_name + '~')
except:
o = opt[0]
a = opt[1]
if o== '--help' or o == '-h':
- help ()
+ usage ()
+ sys.exit (0)
if o == '--version' or o == '-v':
print_version ()
sys.exit (0)