X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=lib%2Flyx2lyx%2Flyx_1_3.py;h=91dae09ec0d1c81ef7e61df06c735bc7885874d8;hb=23366b930e3ffd8b27c56042e2cd6459f3871366;hp=acb8d9f62f0894a82a3cb0d79436df5549725af2;hpb=34001ec175b10b2b75ca91ccf0a28ffc4419f55e;p=lyx.git diff --git a/lib/lyx2lyx/lyx_1_3.py b/lib/lyx2lyx/lyx_1_3.py index acb8d9f62f..91dae09ec0 100644 --- a/lib/lyx2lyx/lyx_1_3.py +++ b/lib/lyx2lyx/lyx_1_3.py @@ -1,7 +1,7 @@ # This file is part of lyx2lyx -# -*- coding: iso-8859-1 -*- +# -*- coding: utf-8 -*- # Copyright (C) 2002 Dekel Tsur -# Copyright (C) 2004 José Matos +# Copyright (C) 2004 José Matos # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -17,13 +17,26 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -import string +""" Convert files to the file format generated by lyx 1.3""" + import re -from parser_tools import find_token, find_end_of_inset, get_value,\ +from parser_tools import find_token, find_end_of, get_value,\ find_token_exact, del_token -def change_insetgraphics(file): - lines = file.body +#################################################################### +# Private helper functions + +def find_end_of_inset(lines, i): + "Finds the matching \end_inset" + return find_end_of(lines, i, "\\begin_inset", "\\end_inset") + +# End of helper functions +#################################################################### + + +def change_insetgraphics(document): + " Change inset Graphics." + lines = document.body i = 0 while 1: i = find_token(lines, "\\begin_inset Graphics", i) @@ -49,7 +62,7 @@ def change_insetgraphics(file): if k == -1: k = find_token_exact(lines, "size_kind", i, j) if k != -1: - size_type = string.split(lines[k])[1] + size_type = lines[k].split()[1] del lines[k] j = j-1 if size_type in ["0", "original"]: @@ -68,7 +81,7 @@ def change_insetgraphics(file): if k == -1: k = find_token_exact(lines, "lyxsize_kind", i, j) if k != -1: - lyxsize_type = string.split(lines[k])[1] + lyxsize_type = lines[k].split()[1] del lines[k] j = j-1 j = del_token(lines, "lyxwidth", i, j) @@ -80,8 +93,9 @@ def change_insetgraphics(file): i = i+1 -def change_tabular(file): - lines = file.body +def change_tabular(document): + " Change tabular." + lines = document.body i = 0 while 1: i = find_token(lines, "