Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2ee37ff

Browse files
committed
- use string methods
- make TEXINPUTS work the way it's supposed to in TeX-ish tools
1 parent e395e22 commit 2ee37ff

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

Doc/tools/mkhowto

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import glob
4343
import os
4444
import re
4545
import shutil
46-
import string
4746
import sys
4847

4948

@@ -243,13 +242,18 @@ class Options:
243242
if not self.formats:
244243
self.formats = self.DEFAULT_FORMATS
245244
# determine the base set of texinputs directories:
246-
texinputs = string.split(os.environ.get("TEXINPUTS", ""), os.pathsep)
245+
texinputs = os.environ.get("TEXINPUTS", "").split(os.pathsep)
247246
if not texinputs:
248247
texinputs = ['']
249-
self.base_texinputs = [
250-
os.path.join(TOPDIR, "paper-" + self.paper),
251-
os.path.join(TOPDIR, "texinputs"),
252-
] + texinputs
248+
mydirs = [os.path.join(TOPDIR, "paper-" + self.paper),
249+
os.path.join(TOPDIR, "texinputs"),
250+
]
251+
if '' in texinputs:
252+
i = texinputs.index('')
253+
texinputs[i:i] = mydirs
254+
else:
255+
texinputs += mydirs
256+
self.base_texinputs = texinputs
253257
if self.builddir:
254258
self.builddir = os.path.abspath(self.builddir)
255259

@@ -320,8 +324,8 @@ class Job:
320324
self.cleanup()
321325

322326
def setup_texinputs(self):
323-
texinputs = [self.filedir] + list(self.options.base_texinputs)
324-
os.environ["TEXINPUTS"] = string.join(texinputs, os.pathsep)
327+
texinputs = [self.filedir] + self.options.base_texinputs
328+
os.environ["TEXINPUTS"] = os.pathsep.join(texinputs)
325329
self.message("TEXINPUTS=" + os.environ["TEXINPUTS"])
326330

327331
def build_aux(self, binary=None):
@@ -391,7 +395,7 @@ class Job:
391395
if max_split_depth is None:
392396
max_split_depth = self.options.max_split_depth
393397
texfile = None
394-
for p in string.split(os.environ["TEXINPUTS"], os.pathsep):
398+
for p in os.environ["TEXINPUTS"].split(os.pathsep):
395399
fn = os.path.join(p, self.doc + ".tex")
396400
if os.path.isfile(fn):
397401
texfile = fn
@@ -413,7 +417,7 @@ class Job:
413417
"-dir", builddir,
414418
texfile
415419
]
416-
self.run(string.join(args)) # XXX need quoting!
420+
self.run(" ".join(args)) # XXX need quoting!
417421
# ... postprocess
418422
shutil.copyfile(self.options.style_file,
419423
os.path.join(builddir, self.doc + ".css"))
@@ -636,12 +640,12 @@ _to_perl["$"] = "\\$"
636640
_to_perl['"'] = '\\"'
637641

638642
def string_to_perl(s):
639-
return string.join(map(_to_perl.get, s), '')
643+
return ''.join(map(_to_perl.get, s))
640644

641645

642646
def check_for_bibtex(filename):
643647
fp = open(filename)
644-
pos = string.find(fp.read(), r"\bibdata{")
648+
pos = fp.read().find(r"\bibdata{")
645649
fp.close()
646650
return pos >= 0
647651

0 commit comments

Comments
 (0)