Author: rgheck
Date: Fri Nov 5 16:11:37 2010
New Revision: 36113
URL: http://www.lyx.org/trac/changeset/36113
Log:
New routine: get_quoted_value.
Modified:
lyx-devel/trunk/lib/lyx2lyx/parser_tools.py
Modified: lyx-devel/trunk/lib/lyx2lyx/parser_tools.py
==============================================================================
--- lyx-devel/trunk/lib/lyx2lyx/parser_tools.py Fri Nov 5 16:07:32 2010
(r36112)
+++ lyx-devel/trunk/lib/lyx2lyx/parser_tools.py Fri Nov 5 16:11:37 2010
(r36113)
@@ -160,6 +160,23 @@
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