# This file is part of lyx2lyx
# -*- coding: utf-8 -*-
-# Copyright (C) 2002-2011 The LyX Team
+# Copyright (C) 2002-2015 The LyX Team
# Copyright (C) 2002-2004 Dekel Tsur <dekel@lyx.org>
# Copyright (C) 2002-2006 José Matos <jamatos@lyx.org>
#
("1_1_6_3", [218], ["1.1", "1.1.6.3","1.1.6.4"]),
("1_2", [220], minor_versions("1.2" , 4)),
("1_3", [221], minor_versions("1.3" , 7)),
+ # Note that range(i,j) is up to j *excluded*.
("1_4", list(range(222,246)), minor_versions("1.4" , 5)),
("1_5", list(range(246,277)), minor_versions("1.5" , 7)),
("1_6", list(range(277,346)), minor_versions("1.6" , 10)),
- ("2_0", list(range(346,414)), minor_versions("2.0", 8)),
- ("2_1", list(range(414,475)), minor_versions("2.1", 0)),
- ("2_2", list(range(475,483)), minor_versions("2.2", 0))
+ ("2_0", list(range(346,414)), minor_versions("2.0" , 8)),
+ ("2_1", list(range(414,475)), minor_versions("2.1" , 0)),
+ ("2_2", list(range(475,507)), minor_versions("2.2" , 0))
]
####################################################################
def __init__(self, end_format = 0, input = "", output = "", error = "",
debug = default_debug__, try_hard = 0, cjk_encoding = '',
- final_version = "", language = "english", encoding = "auto"):
+ final_version = "", systemlyxdir = '', language = "english",
+ encoding = "auto"):
"""Arguments:
end_format: final format that the file should be converted. (integer)
self.status = 0
self.encoding = encoding
self.language = language
+ self.systemlyxdir = systemlyxdir
def warning(self, message, debug_level= default_debug__):
def set_version(self):
" Set the header with the version used."
- self.header[0] = " ".join(["#LyX %s created this file." % version__,
- "For more info see http://www.lyx.org/"])
+
+ initial_comment = " ".join(["#LyX %s created this file." % version__,
+ "For more info see http://www.lyx.org/"])
+
+ # Simple heuristic to determine the comment that always starts
+ # a lyx file
+ if self.header[0].startswith("#"):
+ self.header[0] = initial_comment
+ else:
+ self.header.insert(0, initial_comment)
+
+ # Old lyx files had a two lines comment header:
+ # 1) the first line had the user who had created it
+ # 2) the second line had the lyx version used
+ # later we decided that 1) was a privacy risk for no gain
+ # here we remove the second line effectively erasing 1)
if self.header[1][0] == '#':
del self.header[1]
def convert(self):
"Convert from current (self.format) to self.end_format."
+ if self.format == self.end_format:
+ self.warning("No conversion needed: Target format %s "
+ "same as current format!" % self.format, default_debug__)
+ return
+
mode, conversion_chain = self.chain()
self.warning("conversion chain: " + str(conversion_chain), 3)
def __init__(self, end_format = 0, input = "", output = "", error = "",
debug = default_debug__, try_hard = 0, cjk_encoding = '',
- final_version = ''):
+ final_version = '', systemlyxdir = ''):
LyX_base.__init__(self, end_format, input, output, error,
- debug, try_hard, cjk_encoding, final_version)
+ debug, try_hard, cjk_encoding, final_version,
+ systemlyxdir)
self.read()