]> git.lyx.org Git - lyx.git/blobdiff - lib/lyx2lyx/lyx_1_1_5.py
Add support for CALS tables in DocBook.
[lyx.git] / lib / lyx2lyx / lyx_1_1_5.py
index fde89f5595c996960ced9d5467388700b29d6cd0..6f553649d5413a2df727d7b6728ec33907c9abb7 100644 (file)
 #
 # 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.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
 """ Convert files to the file format generated by lyx 1.1.5"""
 
 import re
-import string
 from parser_tools import find_token, find_token_backwards, find_re
 
 ####################################################################
@@ -27,7 +26,7 @@ from parser_tools import find_token, find_token_backwards, find_re
 
 def get_layout(line, default_layout):
     " Get the line layout, beware of the empty layout."
-    tokens = string.split(line)
+    tokens = line.split()
     if len(tokens) > 1:
         return tokens[1]
     return default_layout
@@ -41,7 +40,7 @@ def replace_protected_separator(document):
     " Replace protected separator. "
     lines = document.body
     i=0
-    while 1:
+    while True:
         i = find_token(lines, "\\protected_separator", i)
         if i == -1:
             break
@@ -66,7 +65,7 @@ def merge_formula_inset(document):
     " Merge formula insets. "
     lines = document.body
     i=0
-    while 1:
+    while True:
         i = find_token(lines, "\\begin_inset Formula", i)
         if i == -1: break
         if lines[i+1] in math_env:
@@ -80,7 +79,7 @@ def update_tabular(document):
     lines = document.body
     lyxtable_re = re.compile(r".*\\LyXTable$")
     i=0
-    while 1:
+    while True:
         i = find_re(lines, lyxtable_re, i)
         if i == -1:
             break
@@ -91,16 +90,16 @@ def update_tabular(document):
 
         lines[i]='multicol5'
         i = i + 1
-        rows = int(string.split(lines[i])[0])
-        columns = int(string.split(lines[i])[1])
+        rows = int(lines[i].split()[0])
+        columns = int(lines[i].split()[1])
 
         i = i + rows + 1
         for j in range(columns):
-            col_info = string.split(lines[i])
+            col_info = lines[i].split()
             if len(col_info) == 3:
                 lines[i] = lines[i] + '"" ""'
             else:
-                lines[i] = string.join(col_info[:3]) + ' "%s" ""' % col_info[3]
+                lines[i] = " ".join(col_info[:3]) + ' "%s" ""' % col_info[3]
             i = i + 1
 
         while lines[i]:
@@ -112,7 +111,7 @@ def update_toc(document):
     " Update table of contents. "
     lines = document.body
     i = 0
-    while 1:
+    while True:
         i = find_token(lines,
                        '\\begin_inset LatexCommand \\tableofcontents', i)
         if i == -1:
@@ -159,7 +158,7 @@ def remove_space_in_units(document):
 
     for margin in margins:
         i = 0
-        while 1:
+        while True:
             i = find_token(lines, margin, i)
             if i == -1:
                 break
@@ -175,7 +174,7 @@ def latexdel_getargs(document, i):
     lines = document.body
 
     # play safe, clean empty lines
-    while 1:
+    while True:
         if lines[i]:
             break
         del lines[i]
@@ -188,11 +187,11 @@ def latexdel_getargs(document, i):
         document.warning("Unexpected end of inset.")
     j = find_token(lines, '\\begin_inset LatexDel }{', i)
 
-    ref = string.join(lines[i:j])
+    ref = " ".join(lines[i:j])
     del lines[i:j + 1]
 
     # play safe, clean empty lines
-    while 1:
+    while True:
         if lines[i]:
             break
         del lines[i]
@@ -203,7 +202,7 @@ def latexdel_getargs(document, i):
     else:
         document.warning("Unexpected end of inset.")
     j = find_token(lines, '\\begin_inset LatexDel }', i)
-    label = string.join(lines[i:j])
+    label = " ".join(lines[i:j])
     del lines[i:j + 1]
 
     return ref, label
@@ -213,12 +212,12 @@ def update_ref(document):
     " Update reference inset. "
     lines = document.body
     i = 0
-    while 1:
+    while True:
         i = find_token(lines, '\\begin_inset LatexCommand', i)
         if i == -1:
             return
 
-        if string.split(lines[i])[-1] == "\\ref{":
+        if lines[i].split()[-1] == "\\ref{":
             i = i + 1
             ref, label = latexdel_getargs(document, i)
             lines[i - 1] = "%s[%s]{%s}" % (lines[i - 1][:-1], ref, label)
@@ -231,20 +230,19 @@ def update_latexdel(document):
     lines = document.body
     i = 0
     latexdel_re = re.compile(r".*\\begin_inset LatexDel")
-    while 1:
+    while True:
         i = find_re(lines, latexdel_re, i)
         if i == -1:
             return
-        lines[i] = string.replace(lines[i],
-                                  '\\begin_inset LatexDel',
-                                  '\\begin_inset LatexCommand')
+        lines[i] = lines[i].replace('\\begin_inset LatexDel',
+                                    '\\begin_inset LatexCommand')
 
-        j = string.find(lines[i],'\\begin_inset')
+        j = lines[i].find('\\begin_inset')
         lines.insert(i+1, lines[i][j:])
-        lines[i] = string.strip(lines[i][:j])
+        lines[i] = lines[i][:j].strip()
         i = i + 1
 
-        if string.split(lines[i])[-1] in ("\\url{", "\\htmlurl{"):
+        if lines[i].split()[-1] in ("\\url{", "\\htmlurl{"):
             i = i + 1
 
             ref, label = latexdel_getargs(document, i)