]> git.lyx.org Git - features.git/commitdiff
Rename files:
authorJosé Matox <jamatos@lyx.org>
Tue, 1 Aug 2006 08:38:24 +0000 (08:38 +0000)
committerJosé Matox <jamatos@lyx.org>
Tue, 1 Aug 2006 08:38:24 +0000 (08:38 +0000)
lyx_1_1_6.py -> lyx_1_1_6_0.py
lyx_1_1_6fix3.py -> lyx_1_1_6_3.py

Change LyX.py accordingly.

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

lib/lyx2lyx/LyX.py
lib/lyx2lyx/lyx_1_1_6.py [deleted file]
lib/lyx2lyx/lyx_1_1_6_0.py [new file with mode: 0644]
lib/lyx2lyx/lyx_1_1_6_3.py [new file with mode: 0644]
lib/lyx2lyx/lyx_1_1_6fix3.py [deleted file]

index 6d9605f06a1e0e7a8ba1c53ea1f7e018ad1db065..817717dc58d10560454410639253c475c27b8682 100644 (file)
@@ -48,17 +48,17 @@ original_version = re.compile(r"\#LyX (\S*)")
 ##
 # file format information:
 #  file, supported formats, stable release versions
-format_relation = [("0_10",  [210], ["0.10.7","0.10"]),
-                   ("0_12",  [215], ["0.12","0.12.1","0.12"]),
-                   ("1_0_0", [215], ["1.0.0","1.0"]),
-                   ("1_0_1", [215], ["1.0.1","1.0.2","1.0.3","1.0.4", "1.1.2","1.1"]),
-                   ("1_1_4", [215], ["1.1.4","1.1"]),
-                   ("1_1_5", [216], ["1.1.5","1.1.5fix1","1.1.5fix2","1.1"]),
-                   ("1_1_6", [217], ["1.1.6","1.1.6fix1","1.1.6fix2","1.1"]),
-                   ("1_1_6fix3", [218], ["1.1.6fix3","1.1.6fix4","1.1"]),
-                   ("1_2", [220], ["1.2.0","1.2.1","1.2.3","1.2.4","1.2"]),
-                   ("1_3", [221], ["1.3.0","1.3.1","1.3.2","1.3.3","1.3.4","1.3.5","1.3.6","1.3.7","1.3"]),
-                   ("1_4", range(222,246), ["1.4.0", "1.4.1", "1.4.2svn"]),
+format_relation = [("0_10",    [210], ["0.10.7","0.10"]),
+                   ("0_12",    [215], ["0.12","0.12.1","0.12"]),
+                   ("1_0_0",   [215], ["1.0.0","1.0"]),
+                   ("1_0_1",   [215], ["1.0.1","1.0.2","1.0.3","1.0.4", "1.1.2","1.1"]),
+                   ("1_1_4",   [215], ["1.1.4","1.1"]),
+                   ("1_1_5",   [216], ["1.1.5","1.1.5fix1","1.1.5fix2","1.1"]),
+                   ("1_1_6_0", [217], ["1.1.6","1.1.6fix1","1.1.6fix2","1.1"]),
+                   ("1_1_6_3", [218], ["1.1.6fix3","1.1.6fix4","1.1"]),
+                   ("1_2",     [220], ["1.2.0","1.2.1","1.2.3","1.2.4","1.2"]),
+                   ("1_3",     [221], ["1.3.0","1.3.1","1.3.2","1.3.3","1.3.4","1.3.5","1.3.6","1.3.7","1.3"]),
+                   ("1_4", range(222,246), ["1.4.0", "1.4.1", "1.4.2","1.4.3svn"]),
                    ("1_5", range(246,249), ["1.5.0svn","1.5"])]
 
 
diff --git a/lib/lyx2lyx/lyx_1_1_6.py b/lib/lyx2lyx/lyx_1_1_6.py
deleted file mode 100644 (file)
index 8d97732..0000000
+++ /dev/null
@@ -1,284 +0,0 @@
-# This file is part of lyx2lyx
-# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2002-2004 José Matos <jamatos@lyx.org>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-import re
-import string
-from parser_tools import find_re, find_tokens, find_token, check_token
-
-
-lyxtable_re = re.compile(r".*\\LyXTable$")
-def update_tabular(file):
-    lines = file.body
-    i=0
-    while 1:
-        i = find_re(lines, lyxtable_re, i)
-        if i == -1:
-            break
-        prop_dict = {"family" : "default", "series" : "default",
-                      "shape" : "default", "size" : "default",
-                      "emph" : "default", "bar" : "default",
-                      "noun" : "default", "latex" : "default", "color" : "default"}
-
-        # remove \LyXTable
-        lines[i] = lines[i][:-9]
-        i = i + 1
-        lines.insert(i,'')
-        i = i + 1
-        lines[i] = "\\begin_inset  Tabular"
-        i = i + 1
-        head = string.split(lines[i])
-        rows = int(head[0])
-        columns = int(head[1])
-
-        tabular_line = i
-        i = i +1
-        lines.insert(i, '<Features rotate="%s" islongtable="%s" endhead="%s" endfirsthead="%s" endfoot="%s" endlastfoot="%s">' % (head[2],head[3],head[4],head[5],head[6],head[7]))
-
-        i = i +1
-
-        row_info = []
-        cont_row = []
-        for j in range(rows):
-            row_info.append(string.split(lines[i]))
-            if string.split(lines[i])[2] == '1':
-                cont_row.append(j)
-            del lines[i]
-
-        column_info = []
-        col_info_re = re.compile(r'(\d) (\d) (\d) (".*") (".*")')
-        for j in range(columns):
-            column_info.append(col_info_re.match(lines[i]).groups())
-            del lines[i]
-
-        cell_info = []
-        cell_col = []
-        ncells = 0
-        cell_re = re.compile(r'(\d) (\d) (\d) (\d) (\d) (\d) (\d) (".*") (".*")')
-        for j in range(rows):
-            for k in range(columns):
-                #add column location to read properties
-                cell_info.append(cell_re.match(lines[i]).groups())
-                cell_col.append(k)
-                if lines[i][0] != "2":
-                    ncells = ncells + 1
-                del lines[i]
-
-        lines[tabular_line] = '<LyXTabular version="1" rows="%s" columns="%s">' % (rows-len(cont_row),columns)
-        del lines[i]
-        if not lines[i]:
-            del lines[i]
-
-        # Read cells
-        l = 0
-        cell_content = []
-        for j in range(rows):
-            cell_content.append([])
-
-        for j in range(rows):
-            for k in range(columns):
-                cell_content[j].append([])
-
-        for j in range(rows):
-            for k in range(columns):
-                m = j*columns + k
-                if cell_info[m][0] == '2':
-                    continue
-
-                if l == ncells -1:
-                    # the end variable refers to cell end, not to file end.
-                    end = find_tokens(lines, ['\\layout','\\the_end','\\end_deeper','\\end_float'], i)
-                else:
-                    end = find_token(lines, '\\newline', i)
-
-                if end == -1:
-                    file.error("Malformed LyX file.")
-
-                end = end - i
-                while end > 0:
-                    cell_content[j][k].append(lines[i])
-                    del lines[i]
-                    end = end -1
-
-                if string.find(lines[i],'\\newline') != -1:
-                    del lines[i]
-                l = l + 1
-
-        tmp = []
-        tmp.append("")
-
-        for j in range(rows):
-            if j in cont_row:
-                continue
-            tmp.append('<Row topline="%s" bottomline="%s" newpage="%s">' % (row_info[j][0],row_info[j][1],row_info[j][3]))
-
-            for k in range(columns):
-                if j:
-                    tmp.append('<Column>')
-                else:
-                    tmp.append('<Column alignment="%s" valignment="0" leftline="%s" rightline="%s" width=%s special=%s>' % (column_info[k][0],column_info[k][1], column_info[k][2], column_info[k][3], column_info[k][4]))
-                m = j*columns + k
-
-                leftline = int(column_info[k][1])
-                if cell_info[m][0] == '1':
-                    n = m + 1
-                    while n < rows * columns - 1 and cell_info[n][0] == '2':
-                        n = n + 1
-                    rightline = int(column_info[cell_col[n-1]][2])
-                else:
-                    # not a multicolumn main cell
-                    rightline = int(column_info[k][2])
-
-                tmp.append('<Cell multicolumn="%s" alignment="%s" valignment="0" topline="%s" bottomline="%s" leftline="%d" rightline="%d" rotate="%s" usebox="%s" width=%s special=%s>' % (cell_info[m][0],cell_info[m][1],cell_info[m][2],cell_info[m][3],leftline,rightline,cell_info[m][5],cell_info[m][6],cell_info[m][7],cell_info[m][8]))
-                tmp.append('\\begin_inset Text')
-                tmp.append('')
-                tmp.append('\\layout %s' % file.default_layout)
-                tmp.append('')
-
-                if cell_info[m][0] != '2':
-                    paragraph = []
-                    if cell_info[m][4] == '1':
-                        l = j
-                        paragraph = paragraph + cell_content[j][k]
-                        while cell_info[m][4] == '1':
-                            m = m + columns
-                            l = l + 1
-                            if l >= rows: break
-                            paragraph = paragraph + cell_content[l][k]
-                    else:
-                        paragraph = cell_content[j][k]
-                    tmp = tmp + set_paragraph_properties(paragraph, prop_dict)
-
-                tmp.append('\\end_inset ')
-                tmp.append('</Cell>')
-                tmp.append('</Column>')
-            tmp.append('</Row>')
-
-        tmp.append('</LyXTabular>')
-        tmp.append('')
-        tmp.append('\\end_inset ')
-        tmp.append('')
-        tmp.append('')
-        lines[i:i] = tmp
-
-        i = i + len(tmp)
-
-
-prop_exp = re.compile(r"\\(\S*)\s*(\S*)")
-
-def set_paragraph_properties(lines, prop_dict):
-    # we need to preserve the order of options
-    properties = ["family","series","shape","size",
-                  "emph","bar","noun","latex","color"]
-    prop_value = {"family" : "default", "series" : "medium",
-                   "shape" : "up", "size" : "normal",
-                   "emph" : "off", "bar" : "no",
-                   "noun" : "off", "latex" : "no_latex", "color" : "none"}
-
-    start = 0
-    end = 0
-    i = 0
-    n = len(lines)
-
-    #skip empty lines
-    while i<n and lines[i] == "":
-        i = i + 1
-    start = i
-
-    #catch open char properties
-    while i<n and lines[i][:1] == "\\":
-        result = prop_exp.match(lines[i])
-        # sys.stderr.write(lines[i]+"\n")
-        prop = result.group(1)
-        if prop not in properties:
-            break
-        else:
-            prop_dict[prop] = result.group(2)
-        i = i + 1
-    end = i
-
-    aux = []
-    insert = 0
-    for prop in properties:
-        if prop_dict[prop] != 'default':
-            insert = 1
-            if prop == "color":
-                aux.append("\\%s %s" % (prop, prop_dict[prop]))
-            elif prop != "family" or prop_dict[prop] != "roman":
-                    aux.append("\\%s %s " % (prop, prop_dict[prop]))
-
-    # remove final char properties
-    n = len(lines)
-    changed_prop = []
-
-    while n:
-        n = n - 1
-        if not lines[n]:
-            del lines[n]
-            continue
-
-        if lines[n][:1] == '\\':
-            result = prop_exp.match(lines[n])
-            prop = result.group(1)
-            if prop in properties:
-                changed_prop.append(prop)
-                prop_dict[prop] = result.group(2)
-                del lines[n]
-                continue
-
-            if check_token(lines[n],'\\end_inset'):
-                # ensure proper newlines after inset end
-                lines.append('')
-                lines.append('')
-        break
-
-    for line in lines[end:]:
-        if line[:1] == '\\':
-            result = prop_exp.match(line)
-            prop = result.group(1)
-            if prop in properties and prop not in changed_prop:
-                prop_dict[prop] = result.group(2)
-
-    if not lines[start:] and not lines[end:]:
-        return []
-
-    result = lines[:start] + aux[:] + lines[end:]
-    if insert and result[0] != '':
-        return [''] + result[:]
-
-    return result[:]
-
-
-def update_language(file):
-    header = file.header
-    i = find_token(header, "\\language", 0)
-    if i == -1:
-        # no language, should emit a warning
-        header.append('\\language english')
-        return
-    # This is the lyx behaviour: defaults to english
-    if string.split(header[i])[1] == 'default':
-        header[i] = '\\language english'
-    return
-
-
-convert = [[217, [update_tabular, update_language]]]
-revert  = []
-
-
-if __name__ == "__main__":
-    pass
diff --git a/lib/lyx2lyx/lyx_1_1_6_0.py b/lib/lyx2lyx/lyx_1_1_6_0.py
new file mode 100644 (file)
index 0000000..8d97732
--- /dev/null
@@ -0,0 +1,284 @@
+# This file is part of lyx2lyx
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2002-2004 José Matos <jamatos@lyx.org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+import re
+import string
+from parser_tools import find_re, find_tokens, find_token, check_token
+
+
+lyxtable_re = re.compile(r".*\\LyXTable$")
+def update_tabular(file):
+    lines = file.body
+    i=0
+    while 1:
+        i = find_re(lines, lyxtable_re, i)
+        if i == -1:
+            break
+        prop_dict = {"family" : "default", "series" : "default",
+                      "shape" : "default", "size" : "default",
+                      "emph" : "default", "bar" : "default",
+                      "noun" : "default", "latex" : "default", "color" : "default"}
+
+        # remove \LyXTable
+        lines[i] = lines[i][:-9]
+        i = i + 1
+        lines.insert(i,'')
+        i = i + 1
+        lines[i] = "\\begin_inset  Tabular"
+        i = i + 1
+        head = string.split(lines[i])
+        rows = int(head[0])
+        columns = int(head[1])
+
+        tabular_line = i
+        i = i +1
+        lines.insert(i, '<Features rotate="%s" islongtable="%s" endhead="%s" endfirsthead="%s" endfoot="%s" endlastfoot="%s">' % (head[2],head[3],head[4],head[5],head[6],head[7]))
+
+        i = i +1
+
+        row_info = []
+        cont_row = []
+        for j in range(rows):
+            row_info.append(string.split(lines[i]))
+            if string.split(lines[i])[2] == '1':
+                cont_row.append(j)
+            del lines[i]
+
+        column_info = []
+        col_info_re = re.compile(r'(\d) (\d) (\d) (".*") (".*")')
+        for j in range(columns):
+            column_info.append(col_info_re.match(lines[i]).groups())
+            del lines[i]
+
+        cell_info = []
+        cell_col = []
+        ncells = 0
+        cell_re = re.compile(r'(\d) (\d) (\d) (\d) (\d) (\d) (\d) (".*") (".*")')
+        for j in range(rows):
+            for k in range(columns):
+                #add column location to read properties
+                cell_info.append(cell_re.match(lines[i]).groups())
+                cell_col.append(k)
+                if lines[i][0] != "2":
+                    ncells = ncells + 1
+                del lines[i]
+
+        lines[tabular_line] = '<LyXTabular version="1" rows="%s" columns="%s">' % (rows-len(cont_row),columns)
+        del lines[i]
+        if not lines[i]:
+            del lines[i]
+
+        # Read cells
+        l = 0
+        cell_content = []
+        for j in range(rows):
+            cell_content.append([])
+
+        for j in range(rows):
+            for k in range(columns):
+                cell_content[j].append([])
+
+        for j in range(rows):
+            for k in range(columns):
+                m = j*columns + k
+                if cell_info[m][0] == '2':
+                    continue
+
+                if l == ncells -1:
+                    # the end variable refers to cell end, not to file end.
+                    end = find_tokens(lines, ['\\layout','\\the_end','\\end_deeper','\\end_float'], i)
+                else:
+                    end = find_token(lines, '\\newline', i)
+
+                if end == -1:
+                    file.error("Malformed LyX file.")
+
+                end = end - i
+                while end > 0:
+                    cell_content[j][k].append(lines[i])
+                    del lines[i]
+                    end = end -1
+
+                if string.find(lines[i],'\\newline') != -1:
+                    del lines[i]
+                l = l + 1
+
+        tmp = []
+        tmp.append("")
+
+        for j in range(rows):
+            if j in cont_row:
+                continue
+            tmp.append('<Row topline="%s" bottomline="%s" newpage="%s">' % (row_info[j][0],row_info[j][1],row_info[j][3]))
+
+            for k in range(columns):
+                if j:
+                    tmp.append('<Column>')
+                else:
+                    tmp.append('<Column alignment="%s" valignment="0" leftline="%s" rightline="%s" width=%s special=%s>' % (column_info[k][0],column_info[k][1], column_info[k][2], column_info[k][3], column_info[k][4]))
+                m = j*columns + k
+
+                leftline = int(column_info[k][1])
+                if cell_info[m][0] == '1':
+                    n = m + 1
+                    while n < rows * columns - 1 and cell_info[n][0] == '2':
+                        n = n + 1
+                    rightline = int(column_info[cell_col[n-1]][2])
+                else:
+                    # not a multicolumn main cell
+                    rightline = int(column_info[k][2])
+
+                tmp.append('<Cell multicolumn="%s" alignment="%s" valignment="0" topline="%s" bottomline="%s" leftline="%d" rightline="%d" rotate="%s" usebox="%s" width=%s special=%s>' % (cell_info[m][0],cell_info[m][1],cell_info[m][2],cell_info[m][3],leftline,rightline,cell_info[m][5],cell_info[m][6],cell_info[m][7],cell_info[m][8]))
+                tmp.append('\\begin_inset Text')
+                tmp.append('')
+                tmp.append('\\layout %s' % file.default_layout)
+                tmp.append('')
+
+                if cell_info[m][0] != '2':
+                    paragraph = []
+                    if cell_info[m][4] == '1':
+                        l = j
+                        paragraph = paragraph + cell_content[j][k]
+                        while cell_info[m][4] == '1':
+                            m = m + columns
+                            l = l + 1
+                            if l >= rows: break
+                            paragraph = paragraph + cell_content[l][k]
+                    else:
+                        paragraph = cell_content[j][k]
+                    tmp = tmp + set_paragraph_properties(paragraph, prop_dict)
+
+                tmp.append('\\end_inset ')
+                tmp.append('</Cell>')
+                tmp.append('</Column>')
+            tmp.append('</Row>')
+
+        tmp.append('</LyXTabular>')
+        tmp.append('')
+        tmp.append('\\end_inset ')
+        tmp.append('')
+        tmp.append('')
+        lines[i:i] = tmp
+
+        i = i + len(tmp)
+
+
+prop_exp = re.compile(r"\\(\S*)\s*(\S*)")
+
+def set_paragraph_properties(lines, prop_dict):
+    # we need to preserve the order of options
+    properties = ["family","series","shape","size",
+                  "emph","bar","noun","latex","color"]
+    prop_value = {"family" : "default", "series" : "medium",
+                   "shape" : "up", "size" : "normal",
+                   "emph" : "off", "bar" : "no",
+                   "noun" : "off", "latex" : "no_latex", "color" : "none"}
+
+    start = 0
+    end = 0
+    i = 0
+    n = len(lines)
+
+    #skip empty lines
+    while i<n and lines[i] == "":
+        i = i + 1
+    start = i
+
+    #catch open char properties
+    while i<n and lines[i][:1] == "\\":
+        result = prop_exp.match(lines[i])
+        # sys.stderr.write(lines[i]+"\n")
+        prop = result.group(1)
+        if prop not in properties:
+            break
+        else:
+            prop_dict[prop] = result.group(2)
+        i = i + 1
+    end = i
+
+    aux = []
+    insert = 0
+    for prop in properties:
+        if prop_dict[prop] != 'default':
+            insert = 1
+            if prop == "color":
+                aux.append("\\%s %s" % (prop, prop_dict[prop]))
+            elif prop != "family" or prop_dict[prop] != "roman":
+                    aux.append("\\%s %s " % (prop, prop_dict[prop]))
+
+    # remove final char properties
+    n = len(lines)
+    changed_prop = []
+
+    while n:
+        n = n - 1
+        if not lines[n]:
+            del lines[n]
+            continue
+
+        if lines[n][:1] == '\\':
+            result = prop_exp.match(lines[n])
+            prop = result.group(1)
+            if prop in properties:
+                changed_prop.append(prop)
+                prop_dict[prop] = result.group(2)
+                del lines[n]
+                continue
+
+            if check_token(lines[n],'\\end_inset'):
+                # ensure proper newlines after inset end
+                lines.append('')
+                lines.append('')
+        break
+
+    for line in lines[end:]:
+        if line[:1] == '\\':
+            result = prop_exp.match(line)
+            prop = result.group(1)
+            if prop in properties and prop not in changed_prop:
+                prop_dict[prop] = result.group(2)
+
+    if not lines[start:] and not lines[end:]:
+        return []
+
+    result = lines[:start] + aux[:] + lines[end:]
+    if insert and result[0] != '':
+        return [''] + result[:]
+
+    return result[:]
+
+
+def update_language(file):
+    header = file.header
+    i = find_token(header, "\\language", 0)
+    if i == -1:
+        # no language, should emit a warning
+        header.append('\\language english')
+        return
+    # This is the lyx behaviour: defaults to english
+    if string.split(header[i])[1] == 'default':
+        header[i] = '\\language english'
+    return
+
+
+convert = [[217, [update_tabular, update_language]]]
+revert  = []
+
+
+if __name__ == "__main__":
+    pass
diff --git a/lib/lyx2lyx/lyx_1_1_6_3.py b/lib/lyx2lyx/lyx_1_1_6_3.py
new file mode 100644 (file)
index 0000000..f7656d7
--- /dev/null
@@ -0,0 +1,124 @@
+# This file is part of lyx2lyx
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2002-2004 José Matos <jamatos@lyx.org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+import re
+import string
+from parser_tools import find_token, find_re
+
+def bool_table(item):
+    if item == "0":
+        return "false"
+    # should emit a warning if item != "1"
+    return "true"
+
+
+align_vertical = {"0": "top", "1": "bottom", "2": "center"}
+align_table = {"0": "top", "2": "left", "4": "right", "8": "center"}
+use_table = {"0": "none", "1": "parbox"}
+table_meta_re = re.compile(r'<LyXTabular version="?1"? rows="?(\d*)"? columns="?(\d*)"?>')
+
+def update_tabular(file):
+    regexp = re.compile(r'^\\begin_inset\s+Tabular')
+    lines = file.body
+    i=0
+    while 1:
+        i = find_re(lines, regexp, i)
+        if i == -1:
+            break
+
+        i = i +1
+
+        # scan table header meta-info
+        res = table_meta_re.match( lines[i] )
+        if res:
+            val = res.groups()
+            lines[i] = '<lyxtabular version="2" rows="%s" columns="%s">' % val
+
+        j = find_token(lines, '</LyXTabular>', i) + 1
+        if j == 0:
+            file.warning( "Error: Bad lyx format i=%d j=%d" % (i,j))
+            break
+
+        new_table = table_update(lines[i:j])
+        lines[i:j] = new_table
+        i = i + len(new_table)
+
+
+col_re = re.compile(r'<column alignment="?(\d)"? valignment="?(\d)"? leftline="?(\d)"? rightline="?(\d)"? width="(.*)" special="(.*)">')
+cell_re = re.compile(r'<cell multicolumn="?(\d)"? alignment="?(\d)"? valignment="?(\d)"? topline="?(\d)"? bottomline="?(\d)"? leftline="?(\d)"? rightline="?(\d)"? rotate="?(\d)"? usebox="?(\d)"? width="(.*)" special="(.*)">')
+features_re = re.compile(r'<features rotate="?(\d)"? islongtable="?(\d)"? endhead="?(-?\d)"? endfirsthead="?(-?\d)"? endfoot="?(-?\d)"? endlastfoot="?(-?\d)"?>')
+row_re = re.compile(r'<row topline="?(\d)"? bottomline="?(\d)"? newpage="?(\d)"?>')
+
+def table_update(lines):
+    lines[1] = string.replace(lines[1], '<Features', '<features')
+    res = features_re.match( lines[1] )
+    if res:
+        val = res.groups()
+        lines[1] = '<features rotate="%s" islongtable="%s" endhead="%s" endfirsthead="%s" endfoot="%s" endlastfoot="%s">' % (bool_table(val[0]), bool_table(val[1]), val[2], val[3], val[4], val[5])
+
+    if lines[2]=="":
+        del lines[2]
+    i = 2
+    col_info = []
+    while i < len(lines):
+        lines[i] = string.replace(lines[i], '<Cell', '<cell')
+        lines[i] = string.replace(lines[i], '</Cell', '</cell')
+        lines[i] = string.replace(lines[i], '<Row', '<row')
+        lines[i] = string.replace(lines[i], '</Row', '</row')
+        lines[i] = string.replace(lines[i], '<Column', '<column')
+        lines[i] = string.replace(lines[i], '</Column', '</column')
+        lines[i] = string.replace(lines[i], '</LyXTabular', '</lyxtabular')
+        k = string.find (lines[i], '<column ')
+        if k != -1:
+            col_info.append(lines[i])
+            del lines[i]
+            continue
+
+        if lines[i] == '</column>' or lines[i] == '<column>':
+            del lines[i]
+            continue
+
+        res = cell_re.match(lines[i])
+        if res:
+            val = res.groups()
+            lines[i] = '<cell multicolumn="%s" alignment="%s" valignment="%s" topline="%s" bottomline="%s" leftline="%s" rightline="%s" rotate="%s" usebox="%s" width="%s" special="%s">' % ( val[0], align_table[val[1]], align_vertical[val[2]], bool_table(val[3]), bool_table(val[4]), bool_table(val[5]), bool_table(val[6]), bool_table(val[7]), use_table[val[8]], val[9], val[10])
+
+        res = row_re.match(lines[i])
+        if res:
+            val = res.groups()
+            lines[i] = '<row topline="%s" bottomline="%s" newpage="%s">' % (bool_table(val[0]), bool_table(val[1]), bool_table(val[2]))
+
+        i = i + 1
+
+    j = len(col_info)
+    for i in range(j):
+        res = col_re.match(col_info[i])
+        if res:
+            val = res.groups()
+            col_info[i] = '<column alignment="%s" valignment="%s" leftline="%s" rightline="%s" width="%s" special="%s">' \
+                          % ( align_table[val[0]], align_vertical[val[1]], bool_table(val[2]), bool_table(val[3]), val[4],val[5])
+
+    return lines[:2] + col_info + lines[2:]
+
+
+convert = [[218, [update_tabular]]]
+revert  = []
+
+
+if __name__ == "__main__":
+    pass
diff --git a/lib/lyx2lyx/lyx_1_1_6fix3.py b/lib/lyx2lyx/lyx_1_1_6fix3.py
deleted file mode 100644 (file)
index f7656d7..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-# This file is part of lyx2lyx
-# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2002-2004 José Matos <jamatos@lyx.org>
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
-import re
-import string
-from parser_tools import find_token, find_re
-
-def bool_table(item):
-    if item == "0":
-        return "false"
-    # should emit a warning if item != "1"
-    return "true"
-
-
-align_vertical = {"0": "top", "1": "bottom", "2": "center"}
-align_table = {"0": "top", "2": "left", "4": "right", "8": "center"}
-use_table = {"0": "none", "1": "parbox"}
-table_meta_re = re.compile(r'<LyXTabular version="?1"? rows="?(\d*)"? columns="?(\d*)"?>')
-
-def update_tabular(file):
-    regexp = re.compile(r'^\\begin_inset\s+Tabular')
-    lines = file.body
-    i=0
-    while 1:
-        i = find_re(lines, regexp, i)
-        if i == -1:
-            break
-
-        i = i +1
-
-        # scan table header meta-info
-        res = table_meta_re.match( lines[i] )
-        if res:
-            val = res.groups()
-            lines[i] = '<lyxtabular version="2" rows="%s" columns="%s">' % val
-
-        j = find_token(lines, '</LyXTabular>', i) + 1
-        if j == 0:
-            file.warning( "Error: Bad lyx format i=%d j=%d" % (i,j))
-            break
-
-        new_table = table_update(lines[i:j])
-        lines[i:j] = new_table
-        i = i + len(new_table)
-
-
-col_re = re.compile(r'<column alignment="?(\d)"? valignment="?(\d)"? leftline="?(\d)"? rightline="?(\d)"? width="(.*)" special="(.*)">')
-cell_re = re.compile(r'<cell multicolumn="?(\d)"? alignment="?(\d)"? valignment="?(\d)"? topline="?(\d)"? bottomline="?(\d)"? leftline="?(\d)"? rightline="?(\d)"? rotate="?(\d)"? usebox="?(\d)"? width="(.*)" special="(.*)">')
-features_re = re.compile(r'<features rotate="?(\d)"? islongtable="?(\d)"? endhead="?(-?\d)"? endfirsthead="?(-?\d)"? endfoot="?(-?\d)"? endlastfoot="?(-?\d)"?>')
-row_re = re.compile(r'<row topline="?(\d)"? bottomline="?(\d)"? newpage="?(\d)"?>')
-
-def table_update(lines):
-    lines[1] = string.replace(lines[1], '<Features', '<features')
-    res = features_re.match( lines[1] )
-    if res:
-        val = res.groups()
-        lines[1] = '<features rotate="%s" islongtable="%s" endhead="%s" endfirsthead="%s" endfoot="%s" endlastfoot="%s">' % (bool_table(val[0]), bool_table(val[1]), val[2], val[3], val[4], val[5])
-
-    if lines[2]=="":
-        del lines[2]
-    i = 2
-    col_info = []
-    while i < len(lines):
-        lines[i] = string.replace(lines[i], '<Cell', '<cell')
-        lines[i] = string.replace(lines[i], '</Cell', '</cell')
-        lines[i] = string.replace(lines[i], '<Row', '<row')
-        lines[i] = string.replace(lines[i], '</Row', '</row')
-        lines[i] = string.replace(lines[i], '<Column', '<column')
-        lines[i] = string.replace(lines[i], '</Column', '</column')
-        lines[i] = string.replace(lines[i], '</LyXTabular', '</lyxtabular')
-        k = string.find (lines[i], '<column ')
-        if k != -1:
-            col_info.append(lines[i])
-            del lines[i]
-            continue
-
-        if lines[i] == '</column>' or lines[i] == '<column>':
-            del lines[i]
-            continue
-
-        res = cell_re.match(lines[i])
-        if res:
-            val = res.groups()
-            lines[i] = '<cell multicolumn="%s" alignment="%s" valignment="%s" topline="%s" bottomline="%s" leftline="%s" rightline="%s" rotate="%s" usebox="%s" width="%s" special="%s">' % ( val[0], align_table[val[1]], align_vertical[val[2]], bool_table(val[3]), bool_table(val[4]), bool_table(val[5]), bool_table(val[6]), bool_table(val[7]), use_table[val[8]], val[9], val[10])
-
-        res = row_re.match(lines[i])
-        if res:
-            val = res.groups()
-            lines[i] = '<row topline="%s" bottomline="%s" newpage="%s">' % (bool_table(val[0]), bool_table(val[1]), bool_table(val[2]))
-
-        i = i + 1
-
-    j = len(col_info)
-    for i in range(j):
-        res = col_re.match(col_info[i])
-        if res:
-            val = res.groups()
-            col_info[i] = '<column alignment="%s" valignment="%s" leftline="%s" rightline="%s" width="%s" special="%s">' \
-                          % ( align_table[val[0]], align_vertical[val[1]], bool_table(val[2]), bool_table(val[3]), val[4],val[5])
-
-    return lines[:2] + col_info + lines[2:]
-
-
-convert = [[218, [update_tabular]]]
-revert  = []
-
-
-if __name__ == "__main__":
-    pass