This patch adds partial lyx2lyx support for the recent file format changes.
It is only the mechanical part, that means backconversion is not yet
implemented for the case that the new features are really used. I'll leave
the interesting stuff for the python gurus ;-)
Can somebody please apply?
Georg
Index: lib/lyx2lyx/ChangeLog
===================================================================
RCS file: /cvs/lyx/lyx-devel/lib/lyx2lyx/ChangeLog,v
retrieving revision 1.25
diff -u -r1.25 ChangeLog
--- lib/lyx2lyx/ChangeLog 2004/03/29 13:17:21 1.25
+++ lib/lyx2lyx/ChangeLog 2004/03/31 14:59:54
@@ -1,3 +1,12 @@
+2004-03-31 Georg Baum <[EMAIL PROTECTED]>
+
+ * lyxconvert_229.py (convert_jurabib): new, add use_jurabib flag
+ * lyxrevert_230.py (convert_jurabib): new, remove use_jurabib flag
+ * lyxconvert_230.py (convert_float): new, add sideways flag
+ * lyxrevert_231.py (convert_float): new, remove sideways flag
+ * lyxconvert_231.py (convert_bibtopic): new, add use_bibtopic flag
+ * lyxrevert_232.py (convert_bibtopic): new, remove use_bibtopic flag
+
2004-03-29 Jürgen Spitzmüller <[EMAIL PROTECTED]>
* lyx2lyx: up the format to 232.
Index: lib/lyx2lyx/lyxconvert_229.py
===================================================================
RCS file: /cvs/lyx/lyx-devel/lib/lyx2lyx/lyxconvert_229.py,v
retrieving revision 1.1
diff -u -r1.1 lyxconvert_229.py
--- lib/lyx2lyx/lyxconvert_229.py 2004/03/05 14:49:08 1.1
+++ lib/lyx2lyx/lyxconvert_229.py 2004/03/31 14:59:56
@@ -22,8 +22,15 @@
from parser_tools import find_token
-def convert(header, body):
- pass
+def convert_jurabib(header):
+ i = find_token(header, '\\use_numerical_citations', 0)
+ if i == -1:
+ sys.stderr.write("Malformed lyx file: Missing '\\use_numerical_citations'\n")
+ return
+ header.insert(i + 1, '\\use_jurabib 0')
+
+def convert(header, body):
+ convert_jurabib(header)
if __name__ == "__main__":
pass
Index: lib/lyx2lyx/lyxconvert_230.py
===================================================================
RCS file: /cvs/lyx/lyx-devel/lib/lyx2lyx/lyxconvert_230.py,v
retrieving revision 1.1
diff -u -r1.1 lyxconvert_230.py
--- lib/lyx2lyx/lyxconvert_230.py 2004/03/29 11:38:36 1.1
+++ lib/lyx2lyx/lyxconvert_230.py 2004/03/31 14:59:56
@@ -21,9 +21,17 @@
import sys
from parser_tools import find_token
+def convert_float(lines):
+ i = 0
+ while 1:
+ i = find_token(lines, '\\begin_inset Float', i)
+ if i == -1:
+ return
+ i = i + 1
+ lines.insert(i, 'sideways false')
def convert(header, body):
- pass
+ convert_float(body)
if __name__ == "__main__":
pass
Index: lib/lyx2lyx/lyxconvert_231.py
===================================================================
RCS file: /cvs/lyx/lyx-devel/lib/lyx2lyx/lyxconvert_231.py,v
retrieving revision 1.1
diff -u -r1.1 lyxconvert_231.py
--- lib/lyx2lyx/lyxconvert_231.py 2004/03/29 13:17:21 1.1
+++ lib/lyx2lyx/lyxconvert_231.py 2004/03/31 14:59:56
@@ -22,8 +22,15 @@
from parser_tools import find_token
-def convert(header, body):
- pass
+def convert_bibtopic(header):
+ i = find_token(header, '\\use_jurabib', 0)
+ if i == -1:
+ sys.stderr.write("Malformed lyx file: Missing '\\use_jurabib'\n")
+ return
+ header.insert(i + 1, '\\use_bibtopic 0')
+
+def convert(header, body):
+ convert_bibtopic(header)
if __name__ == "__main__":
pass
Index: lib/lyx2lyx/lyxrevert_230.py
===================================================================
RCS file: /cvs/lyx/lyx-devel/lib/lyx2lyx/lyxrevert_230.py,v
retrieving revision 1.1
diff -u -r1.1 lyxrevert_230.py
--- lib/lyx2lyx/lyxrevert_230.py 2004/03/05 14:49:08 1.1
+++ lib/lyx2lyx/lyxrevert_230.py 2004/03/31 14:59:56
@@ -19,11 +19,22 @@
import sys
-from parser_tools import find_token
+from parser_tools import find_token, get_value
-def convert(header, body):
- pass
+def convert_jurabib(header):
+ i = find_token(header, '\\use_jurabib', 0)
+ if i == -1:
+ sys.stderr.write("Malformed lyx file: Missing '\\use_jurabib'\n")
+ return
+ if get_value(header, '\\use_jurabib', 0) != "0":
+ sys.stderr.write("Conversion of '\\use_jurabib = 1' not yet implemented.\n")
+ # Don't remove '\\use_jurabib' so that people will get warnings by lyx
+ return
+ del header[i]
+
+def convert(header, body):
+ convert_jurabib(header)
if __name__ == "__main__":
pass
Index: lib/lyx2lyx/lyxrevert_231.py
===================================================================
RCS file: /cvs/lyx/lyx-devel/lib/lyx2lyx/lyxrevert_231.py,v
retrieving revision 1.1
diff -u -r1.1 lyxrevert_231.py
--- lib/lyx2lyx/lyxrevert_231.py 2004/03/29 11:38:36 1.1
+++ lib/lyx2lyx/lyxrevert_231.py 2004/03/31 14:59:56
@@ -19,11 +19,30 @@
import sys
-from parser_tools import find_token
+from parser_tools import find_token, del_token, get_value, find_end_of_inset
-def convert(header, body):
- pass
+def convert_float(lines):
+ i = 0
+ while 1:
+ i = find_token(lines, '\\begin_inset Float', i)
+ if i == -1:
+ return
+ j = find_end_of_inset(lines, i)
+ if j == -1:
+ sys.stderr.write("Malformed lyx file: Missing '\\end_inset'\n")
+ i = i + 1
+ continue
+ if get_value(lines, 'sideways', i, j) != "false":
+ sys.stderr.write("Conversion of 'sideways true' not yet implemented.\n")
+ # Don't remove 'sideways' so that people will get warnings by lyx
+ i = i + 1
+ continue
+ del_token(lines, 'sideways', i, j)
+ i = i + 1
+
+def convert(header, body):
+ convert_float(body)
if __name__ == "__main__":
pass
Index: lib/lyx2lyx/lyxrevert_232.py
===================================================================
RCS file: /cvs/lyx/lyx-devel/lib/lyx2lyx/lyxrevert_232.py,v
retrieving revision 1.1
diff -u -r1.1 lyxrevert_232.py
--- lib/lyx2lyx/lyxrevert_232.py 2004/03/29 13:17:21 1.1
+++ lib/lyx2lyx/lyxrevert_232.py 2004/03/31 14:59:56
@@ -19,11 +19,21 @@
import sys
-from parser_tools import find_token
+from parser_tools import find_token, get_value
-def convert(header, body):
- pass
+def convert_bibtopic(header):
+ i = find_token(header, '\\use_bibtopic', 0)
+ if i == -1:
+ sys.stderr.write("Malformed lyx file: Missing '\\use_bibtopic'\n")
+ return
+ if get_value(header, '\\use_bibtopic', 0) != "0":
+ sys.stderr.write("Conversion of '\\use_bibtopic = 1' not yet implemented.\n")
+ # Don't remove '\\use_jurabib' so that people will get warnings by lyx
+ del header[i]
+
+def convert(header, body):
+ convert_bibtopic(header)
if __name__ == "__main__":
pass