/usr/bin/plastex is in python-plastex 0.9.2-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | #!/usr/bin/python
import os, sys, codecs, string, glob
import plasTeX
from plasTeX.TeX import TeX
from plasTeX.Config import config
from plasTeX.ConfigManager import *
from plasTeX.Logging import getLogger
log = getLogger()
__version__ = '0.9.1'
def main(argv):
""" Main program routine """
print >>sys.stderr, 'plasTeX version %s' % __version__
# Parse the command line options
try:
opts, args = config.getopt(argv[1:])
except Exception, msg:
log.error(msg)
print >>sys.stderr, config.usage()
sys.exit(1)
if not args:
print >>sys.stderr, config.usage()
sys.exit(1)
file = args.pop(0)
# Create document instance that output will be put into
document = plasTeX.TeXDocument(config=config)
# Instantiate the TeX processor and parse the document
tex = TeX(document, file=file)
# Populate variables for use later
if config['document']['title']:
document.userdata['title'] = config['document']['title']
jobname = document.userdata['jobname'] = tex.jobname
cwd = document.userdata['working-dir'] = os.getcwd()
# Load aux files for cross-document references
pauxname = '%s.paux' % jobname
rname = config['general']['renderer']
for dirname in [cwd] + config['general']['paux-dirs']:
for fname in glob.glob(os.path.join(dirname, '*.paux')):
if os.path.basename(fname) == pauxname:
continue
document.context.restore(fname, rname)
# Parse the document
tex.parse()
# Set up TEXINPUTS to include the current directory for the renderer
os.environ['TEXINPUTS'] = '%s:%s' % (os.getcwd(),
os.environ.get('TEXINPUTS',''))
# Change to specified directory to output to
outdir = config['files']['directory']
if outdir:
outdir = string.Template(outdir).substitute({'jobname':jobname})
if not os.path.isdir(outdir):
os.makedirs(outdir)
log.info('Directing output files to directory: %s.' % outdir)
os.chdir(outdir)
# Load renderer
try:
exec('from plasTeX.Renderers.%s import Renderer' % rname)
except ImportError, msg:
log.error('Could not import renderer "%s". Make sure that it is installed correctly, and can be imported by Python.' % rname)
sys.exit(1)
# Write expanded source file
#sourcefile = '%s.source' % jobname
#open(sourcefile,'w').write(document.source.encode('utf-8'))
# Write XML dump
#outfile = '%s.xml' % jobname
#open(outfile,'w').write(document.toXML().encode('utf-8'))
# Apply renderer
Renderer().render(document)
print
def info(type, value, tb):
if hasattr(sys, 'ps1') or not sys.stderr.isatty():
# we are in interactive mode or we don't have a tty-like
# device, so we call the default hook
sys.__excepthook__(type, value, tb)
else:
import traceback, pdb
# we are NOT in interactive mode, print the exception...
traceback.print_exception(type, value, tb)
print
# ...then start the debugger in post-mortem mode.
pdb.pm()
#sys.excepthook = info
#sys.setrecursionlimit(10000)
#main(sys.argv)
try:
main(sys.argv)
except KeyboardInterrupt:
pass
|