]> git.lyx.org Git - lyx.git/blobdiff - lib/scripts/prefs2prefs_prefs.py
Small clarification about 'LyX Archives'
[lyx.git] / lib / scripts / prefs2prefs_prefs.py
index 936b95711f5807c8444a62503bc59ce1311d93fe..2a77d793769d3ca4ce7f78132efe4f0c33e2261a 100644 (file)
 # where the Bool says if  we've modified anything and the NewLine is 
 # the new line, if so, which will be used to replace the old line.
 
+import re
+
 
 ###########################################################
 #
 # Conversion chain
 
+def simple_renaming(line, old, new):
+       if line.find(old) == -1:
+               return no_match
+       line = line.replace(old, new)
+       return (True, line)
+
 no_match = (False, [])
 
+########################
+### Format 1 conversions
+
 def remove_obsolete(line):
        tags = ("\\use_tempdir", "\\spell_command", "\\personal_dictionary",
                                "\\plaintext_roff_command", "\\use_alt_language", 
@@ -38,7 +49,7 @@ def remove_obsolete(line):
 def language_use_babel(line):
        if not line.startswith("\language_use_babel"):
                return no_match
-       re_lub = re.compile(r'^\\language_use_babel\s+(true|false)')
+       re_lub = re.compile(r'^\\language_use_babel\s+"?(true|false)')
        m = re_lub.match(line)
        val = m.group(1)
        newval = '0'
@@ -47,9 +58,34 @@ def language_use_babel(line):
        newline = "\\language_package_selection " + newval
        return (True, newline)
 
+def language_package(line):
+       return simple_renaming(line, "\\language_package", "\\language_custom_package")
+
+lfre = re.compile(r'^\\converter\s+"?(\w+)"?\s+"?(\w+)"?\s+"([^"]*?)"\s+"latex"')
+def latex_flavor(line):
+       if not line.startswith("\\converter"):
+               return no_match
+       m = lfre.match(line)
+       if not m:
+               return no_match
+       conv = m.group(1)
+       fmat = m.group(2)
+       args = m.group(3)
+       flavor = "pdflatex"     
+       if conv in ("platex", "xetex", "luatex"):
+               flavor = conv
+       return (True, 
+               "\\converter \"%s\" \"%s\" \"%s\" \"latex=%s\"" % (conv, fmat, args, flavor))
+
+
+########################
+
+
 conversions = [
        [ # this will be a long list of conversions for format 0
+               latex_flavor,
                remove_obsolete,
-               language_use_babel
+               language_use_babel,
+               language_package
        ] # end conversions for format 0
 ]