From cd99f162b3923e2808cd0c8e4514e27965986682 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Fri, 5 Nov 2010 14:26:14 +0000 Subject: [PATCH] Simplify the get_value routines a bit. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36103 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/parser_tools.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/lyx2lyx/parser_tools.py b/lib/lyx2lyx/parser_tools.py index 7f783b9d21..5e6f0da90e 100644 --- a/lib/lyx2lyx/parser_tools.py +++ b/lib/lyx2lyx/parser_tools.py @@ -147,7 +147,8 @@ def get_value(lines, token, start, end = 0, default = ""): Find the next line that looks like: token followed by other stuff - Returns "followed by other stuff". + Returns "followed by other stuff" with leading and trailing + whitespace removed. """ i = find_token_exact(lines, token, start, end) @@ -155,7 +156,7 @@ def get_value(lines, token, start, end = 0, default = ""): return default l = lines[i].split(None, 1) if len(l) > 1: - return l[1] + return l[1].strip() return default @@ -166,18 +167,12 @@ def get_value_string(lines, token, start, end = 0, trim = False, default = ""): token is the first element. When trim is used, the first and last character of the string is trimmed.""" - i = find_token_exact(lines, token, start, end) - if i == -1: - return default - if len(lines[i].split()) > 1: - for k in range (0, len(lines[i])): - if lines[i][k] == ' ': - if trim == False: - return lines[i][k+1:len(lines[i])] - else: - return lines[i][k+2:len(lines[i])-1] - else: - return default + val = get_value(lines, token, start, end, "") + if not val: + return default + if trim: + return val[1:-1] + return val def del_token(lines, token, start, end): -- 2.39.2