mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 05:40:59 +00:00
Move del_token into the files where it is used. We could use such a
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
This commit is contained in:
parent
fbd0436847
commit
98c80361f4
@ -21,7 +21,7 @@
|
||||
|
||||
import re
|
||||
from parser_tools import find_token, find_end_of, get_value,\
|
||||
find_token_exact, del_token
|
||||
find_token_exact
|
||||
|
||||
####################################################################
|
||||
# Private helper functions
|
||||
@ -30,6 +30,22 @@ def find_end_of_inset(lines, i):
|
||||
"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
|
||||
####################################################################
|
||||
|
||||
|
@ -24,7 +24,7 @@ import re
|
||||
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
|
||||
@ -84,6 +84,21 @@ def find_end_of_inset(lines, i):
|
||||
"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
|
||||
####################################################################
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user