Author: rgheck
Date: Fri Nov 5 17:22:26 2010
New Revision: 36123
URL: http://www.lyx.org/trac/changeset/36123
Log:
This is the del_token that would be helpful.
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 17:20:32 2010
(r36122)
+++ lyx-devel/trunk/lib/lyx2lyx/parser_tools.py Fri Nov 5 17:22:26 2010
(r36123)
@@ -65,6 +65,9 @@
value, if they are present. So use this one for cases
where the value is normally quoted.
+del_token(lines, token, start, end):
+ Like find_token, but deletes the line if it finds one.
+ Returns True if a line got deleted, otherwise False.
'''
# Utilities for one line
@@ -231,17 +234,15 @@
def del_token(lines, token, start, end):
""" del_token(lines, token, start, end) -> int
- Find the lower line in lines where token is the first element and
- delete that line.
-
- Returns the number of lines remaining."""
+ Find the first line in lines where token is the first element
+ and delete that line. Returns True if we deleted a line, False
+ if we did not."""
k = find_token_exact(lines, token, start, end)
if k == -1:
- return end
- else:
- del lines[k]
- return end - 1
+ return False
+ del lines[k]
+ return True
def find_beginning_of(lines, i, start_token, end_token):