# lilypond_version_re_str = '\\\\version *\"(.*)\"'
lilypond_version_re_str = '\\\\(mudela-)?version *\"(.*)\"'
lilypond_version_re = re.compile (lilypond_version_re_str)
+add_version = 1
+
def program_id ():
return '%s (GNU LilyPond) %s' %(program_name, version);
-a, --assume-old apply all conversions to unversioned files
-h, --help print this help
-e, --edit in place edit
- -f, --from=VERSION start from version
+ -f, --from=VERSION start from version. Overrides \version found in file.
-s, --show-rules print all rules.
-t, --to=VERSION target version
+ -n, --no-version don't add new version stamp.
--version print program version
Report bugs to bugs-gnu-music@gnu.org
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)
+ str = re.sub ('\n([^ \t\n]+)[ \t]*= *', regularize_assignment, str)
return str
conversions.append (((1,3,117), conv, 'identifier names: $!foo_bar_123 -> xfooBarABC'))
conversions.append (((1,3,145), conv,
'ContextNameXxxxVerticalExtent -> XxxxVerticalExtent'))
+if 1:
+ def conv (str):
+ str = re.sub ('\\\\key[ \t]*;', '\\key \\default;', str)
+ str = re.sub ('\\\\mark[ \t]*;', '\\mark \\default;', str)
+
+ # Make sure groups of more than one ; have space before
+ # them, so that non of them gets removed by next rule
+ str = re.sub ("([^ \n\t;]);(;+)", "\\1 ;\\2", str)
+
+ # Only remove ; that are not after spaces, # or ;
+ # Otherwise we interfere with Scheme comments,
+ # which is badbadbad.
+ str = re.sub ("([^ \t;#]);", "\\1", str)
+
+ return str
+ conversions.append (((1,3,146), conv, 'semicolons removed'))
+
+if 1:
+ def conv (str):
+ str = re.sub ('default-neutral-direction', 'neutral-direction',str)
+ return str
+ conversions.append (((1,3,147), conv, 'default-neutral-direction -> neutral-direction'))
+
################################
# END OF CONVERSIONS
################################
if last_conversion:
sys.stderr.write ('\n')
new_ver = '\\version \"%s\"' % tup_to_str (last_conversion)
- # JUNKME?
- # ugh: this all really doesn't help
- # esp. as current conversion rules are soo incomplete
+
if re.search (lilypond_version_re_str, str):
str = re.sub (lilypond_version_re_str,'\\'+new_ver , str)
- #else:
- # str = new_ver + '\n' + str
+ elif add_version:
+ str = new_ver + '\n' + str
outfile.write(str)
outfile_name = ''
(options, files) = getopt.getopt (
- sys.argv[1:], 'ao:f:t:seh', ['assume-old', 'version', 'output', 'show-rules', 'help', 'edit', 'from=', 'to='])
+ sys.argv[1:], 'ao:f:t:senh', ['no-version', 'assume-old', 'version', 'output', 'show-rules', 'help', 'edit', 'from=', 'to='])
for opt in options:
o = opt[0]
outfile_name = a
elif o == '--assume-old' or o == '-a':
assume_old = 1
+ elif o == '--no-version' or o == '-n':
+ add_version = 0
else:
print o
raise getopt.error
for f in files:
if f == '-':
f = ''
+ if not os.path.isfile (f):
+ continue
try:
do_one_file (f)
except UnknownVersion: