mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Simplify the get_value routines a bit.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36103 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
96106e6dda
commit
cd99f162b3
@ -147,7 +147,8 @@ def get_value(lines, token, start, end = 0, default = ""):
|
||||
|
||||
Find the next line that looks like:
|
||||
token followed by other stuff
|
||||
Returns "followed by other stuff".
|
||||
Returns "followed by other stuff" with leading and trailing
|
||||
whitespace removed.
|
||||
"""
|
||||
|
||||
i = find_token_exact(lines, token, start, end)
|
||||
@ -155,7 +156,7 @@ def get_value(lines, token, start, end = 0, default = ""):
|
||||
return default
|
||||
l = lines[i].split(None, 1)
|
||||
if len(l) > 1:
|
||||
return l[1]
|
||||
return l[1].strip()
|
||||
return default
|
||||
|
||||
|
||||
@ -166,18 +167,12 @@ def get_value_string(lines, token, start, end = 0, trim = False, default = ""):
|
||||
token is the first element. When trim is used, the first and last character
|
||||
of the string is trimmed."""
|
||||
|
||||
i = find_token_exact(lines, token, start, end)
|
||||
if i == -1:
|
||||
return default
|
||||
if len(lines[i].split()) > 1:
|
||||
for k in range (0, len(lines[i])):
|
||||
if lines[i][k] == ' ':
|
||||
if trim == False:
|
||||
return lines[i][k+1:len(lines[i])]
|
||||
else:
|
||||
return lines[i][k+2:len(lines[i])-1]
|
||||
else:
|
||||
return default
|
||||
val = get_value(lines, token, start, end, "")
|
||||
if not val:
|
||||
return default
|
||||
if trim:
|
||||
return val[1:-1]
|
||||
return val
|
||||
|
||||
|
||||
def del_token(lines, token, start, end):
|
||||
|
Loading…
Reference in New Issue
Block a user