2 # -*- coding: utf-8 -*-
3 # Copyright (C) 2002-2007 José Matos <jamatos@lyx.org>
4 # Copyright (C) 2002-2004 Dekel Tsur <dekel@lyx.org>
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 " Program used to convert between different versions of the lyx file format."
25 if __name__ == "__main__":
27 args["usage"] = "usage: %prog [options] [file]"
29 args["version"] = """lyx2lyx, version %s
30 Copyright (C) 2007 José Matos and Dekel Tsur""" % LyX.version__
32 args["description"] = """Convert old lyx file <file> to newer format,
33 files can be compressed with gzip. If there no file is specified then
34 the standard input is assumed, in this case gziped files are not
37 parser = optparse.OptionParser(**args)
39 parser.set_defaults(debug=LyX.default_debug__, cjk_encoding = '')
40 parser.add_option("-d", "--debug", type="int",
41 help="level=0..2 (O_ quiet, 2_verbose) default: 1")
42 parser.add_option("-q", "--quiet",
43 action="store_const", const=0, dest="debug")
44 parser.add_option("-v", "--verbose",
45 action="store_const", const=1, dest="debug")
46 parser.add_option("--noisy",
47 action="store_const", const=2, dest="debug")
48 parser.add_option("-c", "--encoding", dest="cjk_encoding",
49 help="files in format 248 and lower are read and"
50 " written in the format of CJK-LyX."
51 "If encoding is not given or 'auto' the encoding"
52 "is determined from the locale.")
53 parser.add_option("-e", "--err", dest="error",
54 help= "file name of the error file else goes to stderr")
55 parser.add_option("-o", "--output",
56 help= "name of the output file else goes to stdout")
57 parser.add_option("-t", "--to", dest= "end_format",
58 help= "destination file format, default (latest)")
59 parser.add_option("-l", "--list", action="store_true",
60 help = "list all available formats")
61 parser.add_option("-n", "--try-hard", action="store_true",
62 help = "try hard (ignore any convertion errors)")
64 (options, args) = parser.parse_args()
66 options.input = args[0]
71 print LyX.formats_list()
76 doc = LyX.File(**options.__dict__)