]> git.lyx.org Git - features.git/commitdiff
* prefs2prefs.py : Use a list of [format, conversions] pair.
authorJulien Rioux <jrioux@lyx.org>
Mon, 12 Sep 2011 20:43:06 +0000 (20:43 +0000)
committerJulien Rioux <jrioux@lyx.org>
Mon, 12 Sep 2011 20:43:06 +0000 (20:43 +0000)
    Use a list of [int, list of functions] pair, representing
      - int: the format number, and
      - list of functions: what needs to be done to the file to
                           update it to the given format number.

    This matches what is done in lyx2lyx and helps keeping track of
    format numbers and their corresponding conversion routines.

    Also, add another sanity check.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39668 a592a061-630c-0410-9148-cb99ea01b6c8

lib/scripts/prefs2prefs.py
lib/scripts/prefs2prefs_lfuns.py
lib/scripts/prefs2prefs_prefs.py

index b29bb74528b773196bf51d14e8f7e66dc4e3a1be..3026d061637e0acb4f45fa9b804e59f452d5568b 100644 (file)
@@ -167,17 +167,24 @@ def main(argv):
        format = get_format(lines)
 
        while format < current_format:
-               for c in conversions[format]:
+               target_format, convert = conversions[format]
+               old_format = format
+
+               # 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)
+
+               for c in convert:
                        for i in range(len(lines)):
                                (update, newline) = c(lines[i])
                                if update:
                                        lines[i] = newline
 
                update_format(lines)
+               format = get_format(lines)
 
                # sanity check
-               old_format = format
-               format = get_format(lines)
                if int(old_format) + 1 != int(format):
                        sys.stderr.write("Failed to convert to new format!\n")
                        sys.exit(1)
index 8c334a8c92a57505883e0fc32a42ff6bc4d127a6..1295a7dc308576d99249a38d9072181d6a8a23bc 100644 (file)
@@ -154,7 +154,7 @@ def Bar2bar(line):
 # Conversion chain
 
 conversions = [
-       [ # this will be a long list of conversions for format 0
+       [  1, [ # this will be a long list of conversions to format 1
                next_inset_toggle,
                next_inset_modify,
                optional_insert,
@@ -165,6 +165,6 @@ conversions = [
                paragraph_spacing,
                tabular_feature,
                Bar2bar
-       ] # end conversions for format 0
+       ]],
 ]
 
index 7a2cdd69bcf0156511148e5e7008e69db21bec9f..ae5b5ca0fe405e5a5473501184f3772b8567048f 100644 (file)
@@ -101,11 +101,11 @@ def export_menu(line):
 
 
 conversions = [
-       [ # this will be a long list of conversions for format 0
+       [  1, [ # this will be a long list of conversions to format 1
                export_menu,
                latex_flavor,
                remove_obsolete,
                language_use_babel,
                language_package
-       ] # end conversions for format 0
+       ]],
 ]