From 0e9a0224c1eaf5187c724f00e9094ed4fc38bfed Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Fri, 5 Nov 2010 15:11:37 +0000 Subject: [PATCH] New routine: get_quoted_value. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36113 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/parser_tools.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/lyx2lyx/parser_tools.py b/lib/lyx2lyx/parser_tools.py index 18a797e2ed..19e5054294 100644 --- a/lib/lyx2lyx/parser_tools.py +++ b/lib/lyx2lyx/parser_tools.py @@ -160,6 +160,23 @@ def get_value(lines, token, start, end = 0, default = ""): return default +def get_quoted_value(lines, token, start, end = 0, default = ""): + """ get_quoted_value(lines, token, start[[, end], default]) -> string + + Find the next line that looks like: + token "followed by other stuff" + Returns "followed by other stuff" with leading and trailing + whitespace and quotes removed. If there are no quotes, that is OK too. + So use get_value to preserve possible quotes, this one to remove them, + if they are there. + Note that we will NOT strip quotes from default! + """ + val = get_value(lines, token, start, end, "") + if not val: + return default + return val.strip('"') + + def del_token(lines, token, start, end): """ del_token(lines, token, start, end) -> int -- 2.39.2