From 1d1289f50318e73826c20d9615d725fcda920060 Mon Sep 17 00:00:00 2001 From: Dekel Tsur Date: Wed, 28 Aug 2002 09:03:45 +0000 Subject: [PATCH] Handle the case where insetgraphics has no size_kind token git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5129 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/lyxconvert_220.py | 44 ++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/lib/lyx2lyx/lyxconvert_220.py b/lib/lyx2lyx/lyxconvert_220.py index fbb6b3f515..b0976b026e 100644 --- a/lib/lyx2lyx/lyxconvert_220.py +++ b/lib/lyx2lyx/lyxconvert_220.py @@ -44,32 +44,34 @@ def change_insetgraphics(lines): k = find_token2(lines, "size_type", i, j) if k == -1: k = find_token2(lines, "size_kind", i, j) - size_type = string.split(lines[k])[1] - del lines[k] - j = j-1 - if size_type in ["0", "original"]: - j = del_token(lines, "width", i, j) - j = del_token(lines, "height", i, j) - j = del_token(lines, "scale", i, j) - elif size_type in ["2", "scale"]: - j = del_token(lines, "width", i, j) - j = del_token(lines, "height", i, j) - if get_value(lines, "scale", i, j) == "100": + if k != -1: + size_type = string.split(lines[k])[1] + del lines[k] + j = j-1 + if size_type in ["0", "original"]: + j = del_token(lines, "width", i, j) + j = del_token(lines, "height", i, j) + j = del_token(lines, "scale", i, j) + elif size_type in ["2", "scale"]: + j = del_token(lines, "width", i, j) + j = del_token(lines, "height", i, j) + if get_value(lines, "scale", i, j) == "100": + j = del_token(lines, "scale", i, j) + else: j = del_token(lines, "scale", i, j) - else: - j = del_token(lines, "scale", i, j) k = find_token2(lines, "lyxsize_type", i, j) if k == -1: k = find_token2(lines, "lyxsize_kind", i, j) - lyxsize_type = string.split(lines[k])[1] - del lines[k] - j = j-1 - j = del_token(lines, "lyxwidth", i, j) - j = del_token(lines, "lyxheight", i, j) - if lyxsize_type not in ["2", "scale"] or \ - get_value(lines, "lyxscale", i, j) == "100": - j = del_token(lines, "lyxscale", i, j) + if k != -1: + lyxsize_type = string.split(lines[k])[1] + del lines[k] + j = j-1 + j = del_token(lines, "lyxwidth", i, j) + j = del_token(lines, "lyxheight", i, j) + if lyxsize_type not in ["2", "scale"] or \ + get_value(lines, "lyxscale", i, j) == "100": + j = del_token(lines, "lyxscale", i, j) i = i+1