]> git.lyx.org Git - lyx.git/blob - lib/scripts/fig2pstex.py
typos
[lyx.git] / lib / scripts / fig2pstex.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # file fig2pstex.py
5 # This file is part of LyX, the document processor.
6 # Licence details can be found in the file COPYING.
7 #
8 # \author Angus Leeming
9 # \author Bo Peng
10 #
11 # Full author contact details are available in file CREDITS
12
13
14 # This script converts an XFIG image to something that latex can process
15 # into high quality PostScript.
16
17 # Usage:
18 #   python fig2pstex.py ${base}.fig ${base}.pstex
19 # This command generates
20 #   ${base}.eps    the converted eps file
21 #   ${base}.pstex  a tex file that can be included in your latex document
22 #       using '\input{${output}}'.
23 #
24 # Note:
25 #   Do not use this command as
26 #     python fig2pstex.py file.fig file.eps
27 #   the real eps file will be overwritten by a tex file named file.eps.
28 #
29
30 import os, sys
31
32 # We expect two args, the names of the input and output files.
33 if len(sys.argv) != 3:
34     sys.exit(1)
35
36 input, output = sys.argv[1:]
37
38 # Fail silently if the file doesn't exist
39 if not os.path.isfile(input):
40     sys.exit(0)
41
42 # Strip the extension from ${output}
43 outbase = os.path.splitext(output)[0]
44
45 # Generate the EPS file
46 # Generate the PSTEX_T file
47 if os.system('fig2dev -Lpstex %s %s.eps' % (input, outbase)) != 0 or \
48   os.system('fig2dev -Lpstex_t -p%s %s %s' % (outbase, input, output)) != 0:
49   print 'fig2dev fails'
50   sys.exit(1)