thing, but not one that returns what this does.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36122
a592a061-630c-0410-9148-
cb99ea01b6c8
import re
from parser_tools import find_token, find_end_of, get_value,\
import re
from parser_tools import find_token, find_end_of, get_value,\
- find_token_exact, del_token
####################################################################
# Private helper functions
####################################################################
# Private helper functions
"Finds the matching \end_inset"
return find_end_of(lines, i, "\\begin_inset", "\\end_inset")
"Finds the matching \end_inset"
return find_end_of(lines, i, "\\begin_inset", "\\end_inset")
+
+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."""
+
+ k = find_token_exact(lines, token, start, end)
+ if k == -1:
+ return end
+ else:
+ del lines[k]
+ return end - 1
+
# End of helper functions
####################################################################
# End of helper functions
####################################################################
from os import access, F_OK
import os.path
from parser_tools import check_token, find_token, \
from os import access, F_OK
import os.path
from parser_tools import check_token, find_token, \
- get_value, del_token, is_nonempty_line, \
+ get_value, is_nonempty_line, \
find_tokens, find_end_of, find_beginning_of, find_token_exact, find_tokens_exact, \
find_re, find_tokens_backwards
from sys import stdin
find_tokens, find_end_of, find_beginning_of, find_token_exact, find_tokens_exact, \
find_re, find_tokens_backwards
from sys import stdin
"Finds the matching \end_inset"
return find_end_of(lines, i, "\\begin_inset", "\\end_inset")
"Finds the matching \end_inset"
return find_end_of(lines, i, "\\begin_inset", "\\end_inset")
+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."""
+
+ k = find_token_exact(lines, token, start, end)
+ if k == -1:
+ return end
+ else:
+ del lines[k]
+ return end - 1
+
# End of helper functions
####################################################################
# End of helper functions
####################################################################