-#! /usr/bin/env python
# -*- coding: utf-8 -*-
# file prefs2prefs-lfuns.py
# 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 tabular_feature(line):
return simple_renaming(line, "tabular-feature", "inset-modify tabular")
+
re_Bar2bar = re.compile(r'^(\\(?:bind|unbind))\s+"([^"]*)Bar"(\s+"[^"]+")')
def Bar2bar(line):
m = re_Bar2bar.search(line)
newline = btype + " \"" + mod + "bar\"" + rest
return (True, newline)
-#
+
+def paragraph_break(line):
+ return simple_renaming(line, "break-paragraph", "paragraph-break")
+
+
+def tab_group_close(line):
+ return simple_renaming(line, "close-tab-group", "tab-group-close")
+
+
+def view_split(line):
+ return simple_renaming(line, "split-view", "view-split")
+
+
+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")
+
#
###########################################################
# Conversion chain
conversions = [
- [ 1, [ # this will be a long list of conversions to format 1
+ [ 1, [ # this will be a long list of conversions to format 1, LyX 2.0
next_inset_toggle,
next_inset_modify,
optional_insert,
tabular_feature,
Bar2bar
]],
+ [ 2, [ # list of conversions to format 2, LyX 2.1
+ paragraph_break,
+ tab_group_close,
+ view_split,
+ label_copy_as_reference
+ ]],
+ [ 3, [ # list of conversions to format 3, LyX 2.2
+ remove_print_support
+ ]]
]
-