help_summary = (
_ ('''Update LilyPond input to newer version. By default, update from the
version taken from the \\version command, to the current LilyPond version.''')
++ "\n"
++ _ ("If FILE is `-', read from standard input.")
++ "\n\n"
+ _ ("Examples:")
+ '''
$ convert-ly -e old.ly
ly.progress (_ ("Applying conversion: "), newline = False)
- last_conversion = ()
+ last_conversion = None
errors = 0
try:
- if not conv_list:
- last_conversion = to_version
for x in conv_list:
if x != conv_list[-1]:
ly.progress (tup_to_str (x[0]), newline = False)
(last, result, errors) = do_conversion (input, from_version, to_version)
+ if global_options.force_current_version and \
+ (last is None or last == to_version):
+ last = str_to_tuple (program_version)
if last:
- if global_options.force_current_version and last == to_version:
- last = str_to_tuple (program_version)
-
if global_options.diff_version_update:
if result == input:
# check the y in x.y.z (minor version number)
elif not global_options.skip_version_add:
result = newversion + '\n' + result
- ly.progress ('\n')
-
- if global_options.edit:
- try:
- os.remove(infile_name + '~')
- except:
- pass
- os.rename (infile_name, infile_name + '~')
- outfile = open (infile_name, 'w')
- else:
- outfile = sys.stdout
-
+ ly.progress ('\n')
- outfile.write (result)
+ if global_options.edit:
+ try:
+ os.remove (infile_name + '~')
+ except:
+ pass
+ os.rename (infile_name, infile_name + '~')
+ outfile = open (infile_name, 'w')
+ else:
+ outfile = sys.stdout
+ outfile.write (result)
+
sys.stderr.flush ()
return errors
errors = 0
for f in files:
- if f == '-':
- continue
f = f.decode (sys.stdin.encoding or "utf-8")
- if not os.path.isfile (f):
+ if f == '-':
+ f = ''
+ elif not os.path.isfile (f):
ly.error (_ (u"%s: Unable to open file") % f)
errors += 1
continue