On Wednesday 04 June 2003 13:45, Angus Leeming wrote:
>
> Not quite. If the second ExternalInset is of Template "Date" (no filename)
> then the result is
> \begin_inset External
> template Date
> filename taulogo.png
>
> where taulogo.png is filename from the first ExternalInset.
>
> Is there a filename.erase() or something?
Now if the filename is empty that field doesn't appear, ok?
def convert_external(lines):
external_rexp = re.compile(r'\\begin_inset External (.*),"(.*)",')
i = 0
while 1:
i = find_token(lines, "\\begin_inset External", i)
if i == -1:
break
look = external_rexp.search(lines[i])
top = "\\begin_inset External"
args = ['','']
if look:
args[0] = look.group(1)
args[1] = look.group(2)
#FIXME: if the previous search fails then warn
template = "\ttemplate " + args[0]
if args[1]:
filename = "\tfilename " + args[1]
lines[i:i+1] = [top, template, filename]
else:
lines[i:i+1] = [top, template]
i = i + 1
--
José Abílio