+2002-08-03 Dekel Tsur <dekelts@tau.ac.il>
+
+ * lyx2lyx/lyxconvert_218.py (remove_oldert): Few fixes.
+
+ * lyx2lyx/lyx2lyx: Change the comment at the top of the lyx file
+
2002-08-02 Dekel Tsur <dekelts@tau.ac.il>
* lyx2lyx/lyxconvert_218.py: Convert ERT and figinsets.
import getopt, sys, string, re
from error import error, warning
-from parser_tools import set_format
+from parser_tools import set_comment, set_format
version = "0.0.2"
format = re.compile(r"(\d)[\.,]?(\d\d)")
fileformat = re.compile(r"\\lyxformat\s*(\S*)")
lst_ft = ["210", "215", "216", "217", "218", "220"]
-format_name = {"210" : "2.10", "215":"2.15", "216": "2.16",
- "217" : "2.17", "218":"218" , "220":"220"}
+
def usage():
print """Usage: lyx2lyx [options] file1
Convert old lyx file <file1> to newer format.
end = lst_ft.index(opt.end)
for fmt in lst_ft[start:end]:
- __import__("lyxconvert_" + fmt).convert(header,body)
+ __import__("lyxconvert_" + fmt).convert(header,body)
- set_format(header,format_name[opt.end])
+ set_comment(header, opt.end)
+ set_format(header, opt.end)
write_file(opt.output, header, body)
if __name__ == "__main__":
i = find_tokens(lines, ["\\latex latex", "\\layout LaTeX"], i)
if i == -1:
break
- j = find_tokens(lines, ["\\latex default", "\\layout", "\\end_float"],
+ j = find_tokens(lines, ["\\latex default", "\\layout", "\\end_float", "\\the_end"],
i+1)
- if j == -1:
- j = len(lines)-1
if check_token(lines[j], "\\layout"):
while j-1 >= 0 and check_token(lines[j-1], "\\begin_deeper"):
j = j-1
break
if count >= 2:
- lines[i+1:k] = text
+ j = find_token(lines, "\\layout", i+1)
+ lines[j:k] = text
i = i+1
return i
return -1
+
+def set_comment(lines, number):
+ x = int(number)
+ if x < 216:
+ # It is not worth the trouble to handle this case
+ return
+ elif x < 220:
+ version = "1.1"
+ else:
+ version = "1.2"
+
+ lines[0] = "#LyX %s created this file. For more info see http://www.lyx.org/" % version
+ if lines[1][0] == '#':
+ del lines[1]
+
def set_format(lines, number):
+ if int(number) <= 217:
+ number = float(number)/100
i = find_token(lines, "\\lyxformat", 0)
lines[i] = "\\lyxformat %s" % number