From 23499e63baf8cc52cd021e840db6beae16f23366 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Fri, 5 Nov 2010 15:07:32 +0000 Subject: [PATCH] Move get_value_string to lyx_1_6, since it is only used there. A more suitable replacement is forthcoming. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36112 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/lyx_1_6.py | 18 +++++++++++++++++- lib/lyx2lyx/lyx_2_0.py | 2 +- lib/lyx2lyx/parser_tools.py | 15 --------------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/lib/lyx2lyx/lyx_1_6.py b/lib/lyx2lyx/lyx_1_6.py index 4058f46fb6..e1ed5e670f 100644 --- a/lib/lyx2lyx/lyx_1_6.py +++ b/lib/lyx2lyx/lyx_1_6.py @@ -22,11 +22,27 @@ import re import unicodedata import sys, os -from parser_tools import find_token, find_end_of, find_tokens, get_value, get_value_string +from parser_tools import find_token, find_end_of, find_tokens, get_value #################################################################### # Private helper functions + +def get_value_string(lines, token, start, end = 0, trim = False, default = ""): + """ get_value_string(lines, token, start[[, end], trim, default]) -> string + + Return tokens after token as string, in lines, where + token is the first element. When trim is used, the first and last character + of the string is trimmed.""" + + val = get_value(lines, token, start, end, "") + if not val: + return default + if trim: + return val[1:-1] + return val + + def find_end_of_inset(lines, i): " Find end of inset, where lines[i] is included." return find_end_of(lines, i, "\\begin_inset", "\\end_inset") diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index 61a5809119..cd7b87e2e6 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -25,7 +25,7 @@ import sys, os from parser_tools import find_token, find_end_of, find_tokens, \ find_end_of_inset, find_end_of_layout, find_token_backwards, \ - get_containing_inset, get_value, get_value_string + get_containing_inset, get_value from lyx2lyx_tools import add_to_preamble, insert_to_preamble, \ put_cmd_in_ert, lyx2latex, latex_length, revert_flex_inset, \ diff --git a/lib/lyx2lyx/parser_tools.py b/lib/lyx2lyx/parser_tools.py index 5e6f0da90e..18a797e2ed 100644 --- a/lib/lyx2lyx/parser_tools.py +++ b/lib/lyx2lyx/parser_tools.py @@ -160,21 +160,6 @@ def get_value(lines, token, start, end = 0, default = ""): return default -def get_value_string(lines, token, start, end = 0, trim = False, default = ""): - """ get_value_string(lines, token, start[[, end], trim, default]) -> string - - Return tokens after token as string, in lines, where - token is the first element. When trim is used, the first and last character - of the string is trimmed.""" - - 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): """ del_token(lines, token, start, end) -> int