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