Commit cf5c578f authored by Fred Drake's avatar Fred Drake

- use string methods

- make TEXINPUTS work the way it's supposed to in TeX-ish tools
parent 5bdf55c1
...@@ -43,7 +43,6 @@ import glob ...@@ -43,7 +43,6 @@ import glob
import os import os
import re import re
import shutil import shutil
import string
import sys import sys
...@@ -243,13 +242,18 @@ class Options: ...@@ -243,13 +242,18 @@ class Options:
if not self.formats: if not self.formats:
self.formats = self.DEFAULT_FORMATS self.formats = self.DEFAULT_FORMATS
# determine the base set of texinputs directories: # determine the base set of texinputs directories:
texinputs = string.split(os.environ.get("TEXINPUTS", ""), os.pathsep) texinputs = os.environ.get("TEXINPUTS", "").split(os.pathsep)
if not texinputs: if not texinputs:
texinputs = [''] texinputs = ['']
self.base_texinputs = [ mydirs = [os.path.join(TOPDIR, "paper-" + self.paper),
os.path.join(TOPDIR, "paper-" + self.paper),
os.path.join(TOPDIR, "texinputs"), os.path.join(TOPDIR, "texinputs"),
] + texinputs ]
if '' in texinputs:
i = texinputs.index('')
texinputs[i:i] = mydirs
else:
texinputs += mydirs
self.base_texinputs = texinputs
if self.builddir: if self.builddir:
self.builddir = os.path.abspath(self.builddir) self.builddir = os.path.abspath(self.builddir)
...@@ -320,8 +324,8 @@ class Job: ...@@ -320,8 +324,8 @@ class Job:
self.cleanup() self.cleanup()
def setup_texinputs(self): def setup_texinputs(self):
texinputs = [self.filedir] + list(self.options.base_texinputs) texinputs = [self.filedir] + self.options.base_texinputs
os.environ["TEXINPUTS"] = string.join(texinputs, os.pathsep) os.environ["TEXINPUTS"] = os.pathsep.join(texinputs)
self.message("TEXINPUTS=" + os.environ["TEXINPUTS"]) self.message("TEXINPUTS=" + os.environ["TEXINPUTS"])
def build_aux(self, binary=None): def build_aux(self, binary=None):
...@@ -391,7 +395,7 @@ class Job: ...@@ -391,7 +395,7 @@ class Job:
if max_split_depth is None: if max_split_depth is None:
max_split_depth = self.options.max_split_depth max_split_depth = self.options.max_split_depth
texfile = None texfile = None
for p in string.split(os.environ["TEXINPUTS"], os.pathsep): for p in os.environ["TEXINPUTS"].split(os.pathsep):
fn = os.path.join(p, self.doc + ".tex") fn = os.path.join(p, self.doc + ".tex")
if os.path.isfile(fn): if os.path.isfile(fn):
texfile = fn texfile = fn
...@@ -413,7 +417,7 @@ class Job: ...@@ -413,7 +417,7 @@ class Job:
"-dir", builddir, "-dir", builddir,
texfile texfile
] ]
self.run(string.join(args)) # XXX need quoting! self.run(" ".join(args)) # XXX need quoting!
# ... postprocess # ... postprocess
shutil.copyfile(self.options.style_file, shutil.copyfile(self.options.style_file,
os.path.join(builddir, self.doc + ".css")) os.path.join(builddir, self.doc + ".css"))
...@@ -636,12 +640,12 @@ _to_perl["$"] = "\\$" ...@@ -636,12 +640,12 @@ _to_perl["$"] = "\\$"
_to_perl['"'] = '\\"' _to_perl['"'] = '\\"'
def string_to_perl(s): def string_to_perl(s):
return string.join(map(_to_perl.get, s), '') return ''.join(map(_to_perl.get, s))
def check_for_bibtex(filename): def check_for_bibtex(filename):
fp = open(filename) fp = open(filename)
pos = string.find(fp.read(), r"\bibdata{") pos = fp.read().find(r"\bibdata{")
fp.close() fp.close()
return pos >= 0 return pos >= 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment