X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=lib%2Flyx2lyx%2Flyx_1_1_6_0.py;h=dd6112423f7bf19afcb792867d6e0c1bf3411231;hb=9da74fe2078e24e1e7891784ecbfe33ff77e7f85;hp=8d9773235f6f02325c46816775103a25c96d7c43;hpb=ddc31f7aeefb87901e11506f5448d68d5f462c3a;p=lyx.git diff --git a/lib/lyx2lyx/lyx_1_1_6_0.py b/lib/lyx2lyx/lyx_1_1_6_0.py index 8d9773235f..dd6112423f 100644 --- a/lib/lyx2lyx/lyx_1_1_6_0.py +++ b/lib/lyx2lyx/lyx_1_1_6_0.py @@ -1,6 +1,6 @@ # This file is part of lyx2lyx -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2002-2004 José Matos +# -*- coding: utf-8 -*- +# Copyright (C) 2002-2004 José Matos # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -14,16 +14,17 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +""" Convert files to the file format generated by lyx 1.1.6, until fix2""" import re -import string from parser_tools import find_re, find_tokens, find_token, check_token - lyxtable_re = re.compile(r".*\\LyXTable$") -def update_tabular(file): - lines = file.body +def update_tabular(document): + " Update tabular to version 1 (xml like syntax). " + lines = document.body i=0 while 1: i = find_re(lines, lyxtable_re, i) @@ -41,7 +42,7 @@ def update_tabular(file): i = i + 1 lines[i] = "\\begin_inset Tabular" i = i + 1 - head = string.split(lines[i]) + head = lines[i].split() rows = int(head[0]) columns = int(head[1]) @@ -54,8 +55,8 @@ def update_tabular(file): row_info = [] cont_row = [] for j in range(rows): - row_info.append(string.split(lines[i])) - if string.split(lines[i])[2] == '1': + row_info.append(lines[i].split()) + if lines[i].split()[2] == '1': cont_row.append(j) del lines[i] @@ -100,13 +101,13 @@ def update_tabular(file): continue if l == ncells -1: - # the end variable refers to cell end, not to file end. + # the end variable refers to cell end, not to document end. end = find_tokens(lines, ['\\layout','\\the_end','\\end_deeper','\\end_float'], i) else: end = find_token(lines, '\\newline', i) if end == -1: - file.error("Malformed LyX file.") + document.error("Malformed LyX file.") end = end - i while end > 0: @@ -114,7 +115,7 @@ def update_tabular(file): del lines[i] end = end -1 - if string.find(lines[i],'\\newline') != -1: + if lines[i].find('\\newline') != -1: del lines[i] l = l + 1 @@ -146,7 +147,7 @@ def update_tabular(file): tmp.append('' % (cell_info[m][0],cell_info[m][1],cell_info[m][2],cell_info[m][3],leftline,rightline,cell_info[m][5],cell_info[m][6],cell_info[m][7],cell_info[m][8])) tmp.append('\\begin_inset Text') tmp.append('') - tmp.append('\\layout %s' % file.default_layout) + tmp.append('\\layout %s' % document.default_layout) tmp.append('') if cell_info[m][0] != '2': @@ -179,8 +180,8 @@ def update_tabular(file): prop_exp = re.compile(r"\\(\S*)\s*(\S*)") - def set_paragraph_properties(lines, prop_dict): + " Set paragraph properties." # we need to preserve the order of options properties = ["family","series","shape","size", "emph","bar","noun","latex","color"] @@ -263,19 +264,22 @@ def set_paragraph_properties(lines, prop_dict): return result[:] -def update_language(file): - header = file.header +def update_language(document): + """ Update document language, if language is default convert it to + english.""" + header = document.header i = find_token(header, "\\language", 0) if i == -1: # no language, should emit a warning header.append('\\language english') return # This is the lyx behaviour: defaults to english - if string.split(header[i])[1] == 'default': + if header[i].split()[1] == 'default': header[i] = '\\language english' return +supported_versions = ["1.1.6","1.1.6fix1","1.1.6fix2","1.1"] convert = [[217, [update_tabular, update_language]]] revert = []