On Thursday 09 March 2006 21:15, Georg Baum wrote:
>A fix is in bugzilla.
> lyx2lyx fails to convert 1.3 files with a list of figures at the very end
> 2245
>ditto. Both work for me and could go if somebody confirms that.
Georg
I will comment the patch, I hope you don't mind. [Emotion censored]
> Index: lib/lyx2lyx/ChangeLog
> ===================================================================
> --- lib/lyx2lyx/ChangeLog (Revision 13262)
> +++ lib/lyx2lyx/ChangeLog (Arbeitskopie)
> @@ -1,3 +1,10 @@
> +2006-02-20 Georg Baum <[EMAIL PROTECTED]>
> +
> + * parser_tools.py (find_tokens2): new, extract tokens with exact match
> + * lyx_1_4.py (revert_box, convert_collapsable, revert_bibtopic,
> + convert_float): use find_token(s)2 instead of find_token(s). This
> + does not match "FloatList" when "Float" is searched (bug 2245)
> +
> 2006-02-05 Georg Baum <[EMAIL PROTECTED]>
>
> * LyX.py: new member is_default_layout()
> Index: lib/lyx2lyx/parser_tools.py
> ===================================================================
> --- lib/lyx2lyx/parser_tools.py (Revision 13262)
> +++ lib/lyx2lyx/parser_tools.py (Arbeitskopie)
> @@ -58,6 +58,18 @@ def find_tokens(lines, tokens, start, en
> return -1
>
>
> +def find_tokens2(lines, tokens, start, end = 0):
Please give it a meaningful like find_tokens_exact if that is what you mean.
I know that other functions in this file suffer from that but that is not an
excuse for new funtions.
> + if end == 0:
> + end = len(lines)
> + for i in xrange(start, end):
We can use range, xrange is deprecated now. I know that other functions use
it and it is not a stopper here.
> + line = lines[i]
No need to define line here since it is not modified bellow.
> + for token in tokens:
> + x = string.split(line)
> + if len(x) > 0 and x[0] == token:
> + return i
> + return -1
> +
> +
I understand what you are doing but this will never work for tokens with a
space like what you use bellow. This will always return -1 for tokens with a
space.
You want something like:
...
for token in tokens:
x = string.split(lines[i])
y = string.split(token)
if len(x) < len(y):
continue
if x[:len(y)] == y:
return i
Does it makes sense?
Actually I think that the first if is not necessary since slicing is always a
valid operation.
In [6]: a = [1]
In [7]: a[:20]
Out[7]: [1]
OK, only the second if is necessary. [Emotion censored]
> def find_re(lines, rexp, start, end = 0):
> if end == 0:
> end = len(lines)
--
José Abílio