mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-25 05:55:34 +00:00
Unify the call to converters into LyX.py. (lyx2lyx)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9442 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
3f0c865751
commit
eb0de102db
@ -1,3 +1,21 @@
|
|||||||
|
2005-01-04 José Matos <jamatos@lyx.org>
|
||||||
|
|
||||||
|
* lyx_0_12.py:
|
||||||
|
* lyx_1_0_0.py:
|
||||||
|
* lyx_1_0_1.py:
|
||||||
|
* lyx_1_1_4.py:
|
||||||
|
* lyx_1_1_5.py:
|
||||||
|
* lyx_1_1_6.py:
|
||||||
|
* lyx_1_1_6fix3.py:
|
||||||
|
* lyx_1_2.py:
|
||||||
|
* lyx_1_3.py:
|
||||||
|
* lyx_1_4.py: convert and revert change from functions to lists.
|
||||||
|
|
||||||
|
* LyX.py:
|
||||||
|
* lyx2lyx: version -> version_lyx2lyx
|
||||||
|
|
||||||
|
* LyX.py (convert): put all the convertion logic here.
|
||||||
|
|
||||||
2005-01-04 José Matos <jamatos@lyx.org>
|
2005-01-04 José Matos <jamatos@lyx.org>
|
||||||
|
|
||||||
* LyX.py (set_format): fix typo.
|
* LyX.py (set_format): fix typo.
|
||||||
|
@ -23,7 +23,7 @@ import sys
|
|||||||
import re
|
import re
|
||||||
import string
|
import string
|
||||||
|
|
||||||
version = "1.4.0cvs"
|
version_lyx2lyx = "1.4.0cvs"
|
||||||
default_debug_level = 2
|
default_debug_level = 2
|
||||||
|
|
||||||
# Regular expressions used
|
# Regular expressions used
|
||||||
@ -224,7 +224,7 @@ class LyX_Base:
|
|||||||
|
|
||||||
def set_version(self):
|
def set_version(self):
|
||||||
" Set the header with the version used."
|
" Set the header with the version used."
|
||||||
self.header[0] = "#LyX %s created this file. For more info see http://www.lyx.org/" % version
|
self.header[0] = "#LyX %s created this file. For more info see http://www.lyx.org/" % version_lyx2lyx
|
||||||
if self.header[1][0] == '#':
|
if self.header[1][0] == '#':
|
||||||
del self.header[1]
|
del self.header[1]
|
||||||
|
|
||||||
@ -265,8 +265,28 @@ class LyX_Base:
|
|||||||
self.warning("convertion chain: " + str(convertion_chain), 3)
|
self.warning("convertion chain: " + str(convertion_chain), 3)
|
||||||
|
|
||||||
for step in convertion_chain:
|
for step in convertion_chain:
|
||||||
convert_step = getattr(__import__("lyx_" + step), mode)
|
steps = getattr(__import__("lyx_" + step), mode)
|
||||||
convert_step(self)
|
|
||||||
|
if not steps:
|
||||||
|
self.error("The convertion to an older format (%s) is not implemented." % self.format)
|
||||||
|
|
||||||
|
if len(steps) == 1:
|
||||||
|
version, table = steps[0]
|
||||||
|
for conv in table:
|
||||||
|
conv(self)
|
||||||
|
self.format = version
|
||||||
|
continue
|
||||||
|
|
||||||
|
for version, table in steps:
|
||||||
|
if self.format >= version and mode == "convert":
|
||||||
|
continue
|
||||||
|
if self.format <= version and mode == "revert":
|
||||||
|
continue
|
||||||
|
for conv in table:
|
||||||
|
conv(self)
|
||||||
|
self.format = version
|
||||||
|
if self.end_format == self.format:
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
def chain(self):
|
def chain(self):
|
||||||
|
@ -51,7 +51,7 @@ def parse_options(argv):
|
|||||||
usage()
|
usage()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if o in ("-v", "--version"):
|
if o in ("-v", "--version"):
|
||||||
print "lyx2lyx, version %s" %(LyX.version)
|
print "lyx2lyx, version %s" %(LyX.version_lyx2lyx)
|
||||||
print "Copyright (C) 2002-2004 José Matos and Dekel Tsur"
|
print "Copyright (C) 2002-2004 José Matos and Dekel Tsur"
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if o in ("-d", "--debug"):
|
if o in ("-d", "--debug"):
|
||||||
|
@ -137,11 +137,6 @@ def update_space_units(file):
|
|||||||
lines[i] = string.replace(lines[i], old, new)
|
lines[i] = string.replace(lines[i], old, new)
|
||||||
|
|
||||||
|
|
||||||
def update_inset_accent(file):
|
|
||||||
lines = file.body
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def remove_cursor(file):
|
def remove_cursor(file):
|
||||||
lines = file.body
|
lines = file.body
|
||||||
i = 0
|
i = 0
|
||||||
@ -278,22 +273,13 @@ def update_latexaccents(file):
|
|||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
||||||
|
|
||||||
def convert(file):
|
convert = [[215, [header_update, add_end_document, remove_cursor,
|
||||||
table = [header_update, add_end_document, remove_cursor,
|
final_dot, update_inset_label, update_latexdel,
|
||||||
final_dot, update_inset_label, update_latexdel,
|
update_space_units, space_before_layout,
|
||||||
update_space_units, update_inset_accent,
|
formula_inset_space_eat, update_tabular,
|
||||||
space_before_layout, formula_inset_space_eat,
|
update_vfill, remove_empty_insets,
|
||||||
update_tabular, update_vfill, remove_empty_insets,
|
remove_formula_latex, update_latexaccents]]]
|
||||||
remove_formula_latex, update_latexaccents]
|
revert = []
|
||||||
|
|
||||||
for conv in table:
|
|
||||||
conv(file)
|
|
||||||
|
|
||||||
file.format = 215
|
|
||||||
|
|
||||||
|
|
||||||
def revert(file):
|
|
||||||
file.error("The convertion to an older format (%s) is not implemented." % file.format)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -16,17 +16,8 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
def convert(file):
|
convert = [[215, []]]
|
||||||
table = []
|
revert = []
|
||||||
|
|
||||||
for conv in table:
|
|
||||||
conv(file)
|
|
||||||
|
|
||||||
file.format = 215
|
|
||||||
|
|
||||||
|
|
||||||
def revert(file):
|
|
||||||
file.error("The convertion to an older format (%s) is not implemented." % file .format)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -16,17 +16,8 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
def convert(file):
|
convert = [[215, []]]
|
||||||
table = []
|
revert = []
|
||||||
|
|
||||||
for conv in table:
|
|
||||||
conv(file)
|
|
||||||
|
|
||||||
file.format = 215
|
|
||||||
|
|
||||||
|
|
||||||
def revert(file):
|
|
||||||
file.error("The convertion to an older format (%s) is not implemented." % file.format)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -16,17 +16,8 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
def convert(file):
|
convert = [[215, []]]
|
||||||
table = []
|
revert = []
|
||||||
|
|
||||||
for conv in table:
|
|
||||||
conv(file)
|
|
||||||
|
|
||||||
file.format = 215
|
|
||||||
|
|
||||||
|
|
||||||
def revert(file):
|
|
||||||
file.error("The convertion to an older format (%s) is not implemented." % file.format)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -155,19 +155,10 @@ def remove_space_in_units(file):
|
|||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
||||||
|
|
||||||
def convert(file):
|
convert = [[216, [first_layout, remove_vcid, remove_cursor, update_toc,
|
||||||
table = [first_layout, remove_vcid, remove_cursor, update_toc,
|
replace_protected_separator, merge_formula_inset,
|
||||||
replace_protected_separator, merge_formula_inset,
|
update_tabular, remove_space_in_units]]]
|
||||||
update_tabular, remove_space_in_units]
|
revert = []
|
||||||
|
|
||||||
for conv in table:
|
|
||||||
conv(file)
|
|
||||||
|
|
||||||
file.format = 216
|
|
||||||
|
|
||||||
|
|
||||||
def revert(file):
|
|
||||||
file.error("The convertion to an older format (%s) is not implemented." % file.format)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
pass
|
pass
|
||||||
|
@ -276,17 +276,8 @@ def update_language(file):
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def convert(file):
|
convert = [[217, [update_tabular, update_language]]]
|
||||||
table = [update_tabular, update_language]
|
revert = []
|
||||||
|
|
||||||
for conv in table:
|
|
||||||
conv(file)
|
|
||||||
|
|
||||||
file.format = 217
|
|
||||||
|
|
||||||
|
|
||||||
def revert(file):
|
|
||||||
file.error("The convertion to an older format (%s) is not implemented." % file.format)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -114,17 +114,8 @@ def table_update(lines):
|
|||||||
return lines[:2] + col_info + lines[2:]
|
return lines[:2] + col_info + lines[2:]
|
||||||
|
|
||||||
|
|
||||||
def convert(file):
|
convert = [[218, [update_tabular]]]
|
||||||
table = [update_tabular]
|
revert = []
|
||||||
|
|
||||||
for conv in table:
|
|
||||||
conv(file)
|
|
||||||
|
|
||||||
file.format = 218
|
|
||||||
|
|
||||||
|
|
||||||
def revert(file):
|
|
||||||
file.error("The convertion to an older format (%s) is not implemented." % file.format)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -730,20 +730,11 @@ def change_preamble(file):
|
|||||||
"\use_numerical_citations 0"]
|
"\use_numerical_citations 0"]
|
||||||
|
|
||||||
|
|
||||||
def convert(file):
|
convert = [[220, [change_preamble, change_listof, fix_oldfloatinset,
|
||||||
table = [change_preamble, change_listof, fix_oldfloatinset,
|
update_tabular, update_longtables, remove_pextra,
|
||||||
update_tabular, update_longtables, remove_pextra,
|
remove_oldfloat, remove_figinset, remove_oldertinset,
|
||||||
remove_oldfloat, remove_figinset, remove_oldertinset,
|
remove_oldert, combine_ert, change_infoinset]]]
|
||||||
remove_oldert, combine_ert, change_infoinset]
|
revert = []
|
||||||
|
|
||||||
for conv in table:
|
|
||||||
conv(file)
|
|
||||||
|
|
||||||
file.format = 220
|
|
||||||
|
|
||||||
|
|
||||||
def revert(file):
|
|
||||||
file.error("The convertion to an older format (%s) is not implemented." % file.format)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -92,17 +92,8 @@ def change_tabular(file):
|
|||||||
i = i+1
|
i = i+1
|
||||||
|
|
||||||
|
|
||||||
def convert(file):
|
convert = [[221, [change_insetgraphics, change_tabular]]]
|
||||||
table = [change_insetgraphics, change_tabular]
|
revert = []
|
||||||
|
|
||||||
for conv in table:
|
|
||||||
conv(file)
|
|
||||||
|
|
||||||
file.format = 221
|
|
||||||
|
|
||||||
|
|
||||||
def revert(file):
|
|
||||||
file.error("The convertion to an older format (%s) is not implemented." % file.format)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -1510,66 +1510,47 @@ def use_x_binary(file):
|
|||||||
##
|
##
|
||||||
# Convertion hub
|
# Convertion hub
|
||||||
#
|
#
|
||||||
def convert(file):
|
|
||||||
table = [[223, [insert_tracking_changes, add_end_header, remove_color_default,
|
|
||||||
convert_spaces, convert_bibtex, remove_insetparent]],
|
|
||||||
[224, [convert_external, convert_comment]],
|
|
||||||
[225, [add_end_layout, layout2begin_layout, convert_end_document,
|
|
||||||
convert_table_valignment_middle, convert_breaks]],
|
|
||||||
[226, [convert_note]],
|
|
||||||
[227, [convert_box]],
|
|
||||||
[228, [convert_collapsable, convert_ert]],
|
|
||||||
[229, [convert_minipage]],
|
|
||||||
[230, [convert_jurabib]],
|
|
||||||
[231, [convert_float]],
|
|
||||||
[232, [convert_bibtopic]],
|
|
||||||
[233, [convert_graphics, convert_names]],
|
|
||||||
[234, [convert_cite_engine]],
|
|
||||||
[235, [convert_paperpackage]],
|
|
||||||
[236, [convert_bullets, add_begin_header, add_begin_body,
|
|
||||||
normalize_papersize, strip_end_space]],
|
|
||||||
[237, [use_x_boolean]],
|
|
||||||
[238, [update_latexaccents]]]
|
|
||||||
|
|
||||||
for version, conv_steps in table:
|
convert = [[223, [insert_tracking_changes, add_end_header, remove_color_default,
|
||||||
if file.format >= version:
|
convert_spaces, convert_bibtex, remove_insetparent]],
|
||||||
continue
|
[224, [convert_external, convert_comment]],
|
||||||
for convert in conv_steps:
|
[225, [add_end_layout, layout2begin_layout, convert_end_document,
|
||||||
convert(file)
|
convert_table_valignment_middle, convert_breaks]],
|
||||||
file.format = version
|
[226, [convert_note]],
|
||||||
if file.end_format == file.format:
|
[227, [convert_box]],
|
||||||
return
|
[228, [convert_collapsable, convert_ert]],
|
||||||
|
[229, [convert_minipage]],
|
||||||
|
[230, [convert_jurabib]],
|
||||||
|
[231, [convert_float]],
|
||||||
|
[232, [convert_bibtopic]],
|
||||||
|
[233, [convert_graphics, convert_names]],
|
||||||
|
[234, [convert_cite_engine]],
|
||||||
|
[235, [convert_paperpackage]],
|
||||||
|
[236, [convert_bullets, add_begin_header, add_begin_body,
|
||||||
|
normalize_papersize, strip_end_space]],
|
||||||
|
[237, [use_x_boolean]],
|
||||||
|
[238, [update_latexaccents]]]
|
||||||
|
|
||||||
|
revert = [[237, []],
|
||||||
|
[236, [use_x_binary]],
|
||||||
|
[235, [denormalize_papersize, remove_begin_body,remove_begin_header,
|
||||||
|
revert_bullets]],
|
||||||
|
[234, [revert_paperpackage]],
|
||||||
|
[233, [revert_cite_engine]],
|
||||||
|
[232, [revert_names]],
|
||||||
|
[231, [revert_bibtopic]],
|
||||||
|
[230, [revert_float]],
|
||||||
|
[229, [revert_jurabib]],
|
||||||
|
[228, []],
|
||||||
|
[227, [revert_collapsable, revert_ert]],
|
||||||
|
[226, [revert_box, revert_external_2]],
|
||||||
|
[225, [revert_note]],
|
||||||
|
[224, [rm_end_layout, begin_layout2layout, revert_end_document,
|
||||||
|
revert_valignment_middle, convert_vspace, convert_frameless_box]],
|
||||||
|
[223, [revert_external_2, revert_comment]],
|
||||||
|
[221, [rm_end_header, revert_spaces, revert_bibtex,
|
||||||
|
rm_tracking_changes, rm_body_changes]]]
|
||||||
|
|
||||||
def revert(file):
|
|
||||||
table = [[237, []],
|
|
||||||
[236, [use_x_binary]],
|
|
||||||
[235, [denormalize_papersize, remove_begin_body,remove_begin_header,
|
|
||||||
revert_bullets]],
|
|
||||||
[234, [revert_paperpackage]],
|
|
||||||
[233, [revert_cite_engine]],
|
|
||||||
[232, [revert_names]],
|
|
||||||
[231, [revert_bibtopic]],
|
|
||||||
[230, [revert_float]],
|
|
||||||
[229, [revert_jurabib]],
|
|
||||||
[228, []],
|
|
||||||
[227, [revert_collapsable, revert_ert]],
|
|
||||||
[226, [revert_box, revert_external_2]],
|
|
||||||
[225, [revert_note]],
|
|
||||||
[224, [rm_end_layout, begin_layout2layout, revert_end_document,
|
|
||||||
revert_valignment_middle, convert_vspace, convert_frameless_box]],
|
|
||||||
[223, [revert_external_2, revert_comment]],
|
|
||||||
[221, [rm_end_header, revert_spaces, revert_bibtex,
|
|
||||||
rm_tracking_changes, rm_body_changes]]]
|
|
||||||
|
|
||||||
for version, conv_steps in table:
|
|
||||||
if file.format <= version:
|
|
||||||
continue
|
|
||||||
for convert in conv_steps:
|
|
||||||
convert(file)
|
|
||||||
file.format = version
|
|
||||||
if file.end_format == file.format:
|
|
||||||
return
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user