Hi Georg,
        if you are not the person to blame please excuse and direct the flames 
to 
the responsible. ;-)

        By any account it is Angus fault that I report this error. ;-) He 
suggested 
a convertion to the latest format and a revertion to 221 to see how lyx2lyx 
behaves.

        I should say that it performs amazingly well given its test in this 
regard. :-)

        My first file that fails the test is the one attached.

        My proposed patch follows attached as well.

        Notice that I make add_to_preamble a little bit more robust. It is no 
error 
for a lyx file not to have a preamble, so if it does not have one we add 
it. If for some reason the end_preamble is missing we add it also (this 
should not ever happen but I am playing safe again.)

        Later when the dictionary is initialized I notice that two of the 
entries 
are used as indices of lists that is why I changed their value to integers.

        This is a superficial fix, I let to those who know better than me to 
decide 
what to do with the patch.

        Best regards,
-- 
José Abílio
#LyX 1.1 created this file. For more info see http://www.lyx.org/
\lyxformat 218
\textclass article
\language english
\inputencoding auto
\fontscheme default
\graphics default
\paperfontsize default
\spacing single 
\papersize Default
\paperpackage a4
\use_geometry 0
\use_amsmath 0
\paperorientation portrait
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\defskip medskip
\quotes_language english
\quotes_times 2
\papercolumns 1
\papersides 1
\paperpagestyle default

\layout Standard
\pextra_type 2 \pextra_alignment 0 \pextra_hfill 1 \pextra_widthp 50


\begin_inset  Tabular
<lyxtabular version="2" rows="2" columns="2">
<features rotate="false" islongtable="false" endhead="0" endfirsthead="0" endfoot="0" endlastfoot="0">
<column alignment="center" valignment="top" leftline="true" rightline="false" width="" special="">
<column alignment="center" valignment="top" leftline="true" rightline="true" width="" special="">
<row topline="true" bottomline="false" newpage="false">
<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
\begin_inset Text

\layout Standard

1
\end_inset 
</cell>
<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="true" rotate="false" usebox="none" width="" special="">
\begin_inset Text

\layout Standard

2
\end_inset 
</cell>
</row>
<row topline="true" bottomline="true" newpage="false">
<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
\begin_inset Text

\layout Standard

3
\end_inset 
</cell>
<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="true" rotate="false" usebox="none" width="" special="">
\begin_inset Text

\layout Standard

4
\end_inset 
</cell>
</row>
</lyxtabular>

\end_inset 


\layout Standard
\pextra_type 2 \pextra_alignment 0 \pextra_start_minipage 1 \pextra_widthp 45


\begin_inset  Tabular
<lyxtabular version="2" rows="2" columns="2">
<features rotate="false" islongtable="false" endhead="0" endfirsthead="0" endfoot="0" endlastfoot="0">
<column alignment="center" valignment="top" leftline="true" rightline="false" width="" special="">
<column alignment="center" valignment="top" leftline="true" rightline="true" width="" special="">
<row topline="true" bottomline="false" newpage="false">
<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
\begin_inset Text

\layout Standard

5
\end_inset 
</cell>
<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="true" rotate="false" usebox="none" width="" special="">
\begin_inset Text

\layout Standard

6
\end_inset 
</cell>
</row>
<row topline="true" bottomline="true" newpage="false">
<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="false" rotate="false" usebox="none" width="" special="">
\begin_inset Text

\layout Standard

7
\end_inset 
</cell>
<cell multicolumn="0" alignment="center" valignment="top" topline="true" bottomline="false" leftline="true" rightline="true" rotate="false" usebox="none" width="" special="">
\begin_inset Text

\layout Standard

8
\end_inset 
</cell>
</row>
</lyxtabular>

\end_inset 


\the_end
? l2ly_test.sh
Index: lyx_1_4.py
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/lyx2lyx/lyx_1_4.py,v
retrieving revision 1.35
diff -u -p -r1.35 lyx_1_4.py
--- lyx_1_4.py	7 Jul 2005 10:51:55 -0000	1.35
+++ lyx_1_4.py	12 Jul 2005 20:43:19 -0000
@@ -1047,12 +1047,16 @@ def insert_ert(body, i, status, text):
 def add_to_preamble(file, text):
     i = find_token(file.header, '\\begin_preamble', 0)
     if i == -1:
-        file.warning("Malformed LyX file: Missing '\\begin_preamble'.")
+        #file.warning("Malformed LyX file: Missing '\\begin_preamble'.")
+        file.header.extend(['\\begin_preamble'] + text + ['\\end_preamble'])
         return
+
     j = find_token(file.header, '\\end_preamble', i)
     if j == -1:
         file.warning("Malformed LyX file: Missing '\\end_preamble'.")
-        return
+        file.header.append('\\end_preamble')
+        j = len(file.header)
+
     if find_token(file.header, text[0], i, j) != -1:
         return
     file.header[j:j] = text
@@ -1075,8 +1079,8 @@ def convert_frameless_box(file):
 	j = j - 1
 
 	# Gather parameters
-	params = {'position':'0', 'hor_pos':'c', 'has_inner_box':'1',
-                  'inner_pos':'1', 'use_parbox':'0', 'width':'100col%',
+	params = {'position':0, 'hor_pos':'c', 'has_inner_box':'1',
+                  'inner_pos':1, 'use_parbox':'0', 'width':'100col%',
 	          'special':'none', 'height':'1in',
 	          'height_special':'totalheight', 'collapsed':'false'}
 	for key in params.keys():

Reply via email to