X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=lib%2Flyx2lyx%2Fparser_tools.py;h=e32ac5dc4fca7d879a933e8f9c0d7550aa800716;hb=b33b352171813f99a8fbf8e8b6f6c445025d94f8;hp=d657ffbcfab14bcc2ca31fc99f065af0c51b6d26;hpb=22c7c7b144be890c53ac4663ccfee8564489ddad;p=lyx.git diff --git a/lib/lyx2lyx/parser_tools.py b/lib/lyx2lyx/parser_tools.py index d657ffbcfa..e32ac5dc4f 100644 --- a/lib/lyx2lyx/parser_tools.py +++ b/lib/lyx2lyx/parser_tools.py @@ -1,6 +1,6 @@ # This file is part of lyx2lyx # -*- coding: utf-8 -*- -# Copyright (C) 2002-2010 Dekel Tsur , +# Copyright (C) 2002-2011 Dekel Tsur , # José Matos , Richard Heck # # This program is free software; you can redistribute it and/or @@ -15,7 +15,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ''' @@ -307,7 +307,7 @@ def get_quoted_value(lines, token, start, end = 0, default = ""): def get_option_value(line, option): - rx = option + '\s*=\s*"([^"+])"' + rx = option + '\s*=\s*"([^"]+)"' rx = re.compile(rx) m = rx.search(line) if not m: @@ -315,6 +315,15 @@ def get_option_value(line, option): return m.group(1) +def set_option_value(line, option, value): + rx = '(' + option + '\s*=\s*")[^"]+"' + rx = re.compile(rx) + m = rx.search(line) + if not m: + return line + return re.sub(rx, '\g<1>' + value + '"', line) + + def del_token(lines, token, start, end = 0): """ del_token(lines, token, start, end) -> int