2 # -*- coding: utf-8 -*-
3 # Copyright (C) 2002-2004 José Matos <jamatos@lyx.org>
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 print """Usage: lyx2lyx [options] [file]
25 Convert old lyx file <file> to newer format, files can be compressed with gzip.
26 If there no file is specified then the standard input is assumed, in this case
27 gziped files are not handled.
29 -h, --help this information
30 -v, --version output version information and exit
31 -l, --list list all available formats
32 -d, --debug level level=0..2 (O_ no debug information, 2_verbose)
34 -e, --err error_file name of the error file or else goes to stderr
35 -f, --from version initial version (optional)
36 -t, --to version final version (optional)
37 -o, --output name name of the output file or else goes to stdout
38 -n, --try-hard try hard (ignore any convertion errors)
39 -c, --cjk [encoding] files in format 248 and lower are read and
40 written in the format of CJK-LyX.
41 If encoding is not given or 'auto' the encoding
42 is determined from the locale.
43 -q, --quiet same as --debug=0"""
46 def parse_options(argv):
47 _options = ["help", "version", "list", "debug=", "err=", "from=", "to=", "output=", "try-hard", "cjk", "quiet"]
49 opts, args = getopt.getopt(argv[1:], "c:d:e:f:hlno:qt:v", _options)
54 end_format, input, output, error, debug, try_hard = 0, "", "", "", LyX.default_debug_level, 0
57 if o in ("-h", "--help"):
60 if o in ("-v", "--version"):
61 print "lyx2lyx, version %s" %(LyX.version_lyx2lyx)
62 print "Copyright (C) 2002-2004 José Matos and Dekel Tsur"
64 if o in ("-d", "--debug"):
66 if o in ("-q", "--quiet"):
68 if o in ("-l", "--list"):
69 print LyX.formats_list()
71 if o in ("-o", "--output"):
73 if o in ("-t", "--to"):
75 if o in ("-e","--err"):
77 if o in ("-n", "--try-hard"):
79 if o in ("-c", "--cjk"):
87 return end_format, input, output, error, debug, try_hard, cjk_encoding
91 end_format, input, output, error, debug, try_hard, cjk_encoding = parse_options(argv)
92 file = LyX.File(end_format, input, output, error, debug, try_hard, cjk_encoding)
100 if __name__ == "__main__":
101 sys.exit(main(sys.argv))