lines[format_line] = "Format " + str(format + 1)
+def abort(msg):
+ sys.stderr.write("\n%s\n" % (msg))
+ sys.exit(10)
+
#
###########################################################
(options, args) = getopt(sys.argv[1:], "lp")
except:
usage()
- print "\nUnrecognized option"
- sys.exit(1)
+ abort("Unrecognized option")
opened_files = False
# Open files
opened_files = True
else:
usage()
- print "\nEither zero or two arguments must be given."
- sys.exit(1)
+ abort("Either zero or two arguments must be given.")
conversions = False
if not conversions:
usage()
- print "\nNeither -l nor -p given."
- sys.exit(1)
+ abort("Neither -l nor -p given.")
elif len(options) > 1:
usage()
- print "\nOnly one of -l or -p should be given."
- sys.exit(1)
+ abort("Only one of -l or -p should be given.")
current_format = len(conversions)
lines = read(source)
# make sure the conversion list is sequential
if int(old_format) + 1 != target_format:
- sys.stderr.write("Something is wrong with the conversion chain.\n")
- sys.exit(1)
+ abort("Something is wrong with the conversion chain.")
for c in convert:
for i in range(len(lines)):
# sanity check
if int(old_format) + 1 != int(format):
- sys.stderr.write("Failed to convert to new format!\n")
- sys.exit(1)
+ abort("Failed to convert to new format!")
write(output, lines)
# These accept a line as argument and should return a list:
# (bool, newline)
# where the bool indicates whether we changed anything. If not,
-# one normally returns: (False, []).
+# one normally returns: (False, "").
-no_match = (False, [])
+no_match = (False, "")
def simple_renaming(line, old, new):
if line.find(old) == -1:
return (True, line)
+def simple_remove(line, old):
+ if line.find(old) == -1:
+ return no_match
+ return (True, "")
+
+
def next_inset_modify(line):
return simple_renaming(line, "next-inset-modify", "inset-modify")
def label_copy_as_reference(line):
return simple_renaming(line, "copy-label-as-reference", "label-copy-as-reference")
-#
+
+def remove_print_support(line):
+ return simple_remove(line, "dialog-show print")
+
#
###########################################################
view_split,
label_copy_as_reference
]],
+ [ 3, [ # list of conversions to format 3, LyX 2.2
+ remove_print_support
+ ]]
]
-