]> git.lyx.org Git - lyx.git/blob - lib/lyx2lyx/lyx2lyx
Don't use widest label for numerical citations.
[lyx.git] / lib / lyx2lyx / lyx2lyx
1 #! /usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # Copyright (C) 2002-2011 The LyX Team
4 # Copyright (C) 2002-2007 José Matos <jamatos@lyx.org>
5 # Copyright (C) 2002-2004 Dekel Tsur <dekel@lyx.org>
6 #
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation; either version 2
10 # of the License, or (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20
21 " Program used to convert between different versions of the lyx file format."
22 import optparse
23 import sys
24 import LyX
25
26 def main():
27     args = {}
28     args["usage"] = "usage: %prog [options] [file]"
29
30     args["version"] = """lyx2lyx, version %s
31 Copyright (C) 2011 The LyX Team, José Matos and Dekel Tsur""" % LyX.version__
32
33     args["description"] = """Convert old lyx file <file> to newer format,
34     files can be compressed with gzip.  If there no file is specified then
35     the standard input is assumed, in this case gziped files are not
36     handled."""
37
38     parser = optparse.OptionParser(**args)
39
40     parser.set_defaults(debug=LyX.default_debug__, cjk_encoding = '')
41     parser.add_option("-d", "--debug", type="int",
42                       help="level=0..2 (O_ quiet, 10_verbose) default: 2")
43     parser.add_option("-q", "--quiet",
44                       action="store_const", const=0, dest="debug")
45     parser.add_option("-v", "--verbose",
46                       action="store_const", const=1, dest="debug")
47     parser.add_option("--noisy",
48                       action="store_const", const=10, dest="debug")
49     parser.add_option("-c", "--encoding", dest="cjk_encoding",
50                       help="files in format 413 and lower are read and"
51                            " written in the format of CJK-LyX."
52                            "If encoding is not given or 'auto' the encoding"
53                            "is determined from the locale.")
54     parser.add_option("-e", "--err", dest="error",
55                       help= "file name of the error file else goes to stderr")
56     parser.add_option("-o", "--output",
57                       help= "name of the output file else goes to stdout")
58     parser.add_option("-t", "--to", dest= "end_format",
59                       help= "destination file format, default (latest)")
60     parser.add_option("-V", "--final_version", dest= "final_version",
61                       help= "destination version, default (latest)")
62     parser.add_option("-l", "--list", action="store_true",
63                       help = "list all available formats and supported versions")
64     parser.add_option("-n", "--try-hard", action="store_true",
65                       help = "try hard (ignore any convertion errors)")
66
67     (options, args) = parser.parse_args()
68     if args:
69         options.input = args[0]
70     else:
71         options.input = None
72
73     if options.list:
74         sys.stderr.write(LyX.format_info())
75         sys.exit()
76     else:
77         del options.list
78
79     doc = LyX.File(**options.__dict__)
80     doc.convert()
81     doc.write()
82
83     sys.exit(doc.status)
84
85 if __name__ == "__main__":
86     main()