diff options
Diffstat (limited to 'texall')
| -rwxr-xr-x | texall | 62 |
1 files changed, 36 insertions, 26 deletions
@@ -8,6 +8,8 @@ import pty import re import select import subprocess +import fnmatch +import dircache parser = OptionParser(usage="%prog [options] DIR/FILE", version="%prog $Id: $", @@ -37,7 +39,7 @@ parser.add_option("-i", "--interaction", dest="interactionmode", choices=("batchmode", "nonstopmode", "scrollmode", "errorstopmode"), help="control the behaviour of latex (on of batchmode (default), nonstopmode (default for -o), scrollmode, errorstopmode)") parser.add_option("-I", "--ignore", - action="store", dest="ignorepattern", default=".*vorlage.*|\.\#.*", + action="store", dest="ignorepattern", default=".*vorlage.*|\.\#.*|\..*\.rmligs\.tex", help="regular expression of filenames to ignore") parser.add_option("-P", "--required-pattern", action="store", dest="requiredpattern", default='^\\\\documentclass|%%% TeX-master: t', @@ -74,10 +76,7 @@ def error(file, desc, warning=False): print msg errors.append(msg) -if os.path.exists("/dev/null"): - null = file("/dev/null", "wb") -else: - null = file("nul:", "wb") +null = file(os.path.devnull, "wb") # platform checking: iswindows = (sys.platform == "win32") @@ -264,7 +263,7 @@ def bibfiles(dirname, texname): if bib[-4:] != ".bib": bib += ".bib" if bib[-8:] != "-blx.bib": - yield os.path.normpath(os.path.join(dirname,os.path.expanduser(bib))) + yield bib def outdatedtexfiles(args): for dirname, texname in alltexfiles(args): @@ -321,6 +320,10 @@ def detectrmligs(dirname, texname): return True return False +def bblfiles(dirname, jobname): + files = dircache.listdir(dirname) + return fnmatch.filter(files, "%s*.bbl"%jobname) + MAXRUNS=5 def processtexfiles(args): for dirname, texname, reason in outdatedtexfiles(args): @@ -338,37 +341,46 @@ def processtexfiles(args): realname = texname if detectrmligs(dirname, texname): realname = preparermligs(texname, dirname, tmplist) - - runtex(tex, texname, realname, dirname) - if not options.singlerun: - #strip .tex extension - jobname=texname[:-4] + #strip .tex extension + jobname=texname[:-4] - # run bibtex if any bibfile changed: - for bib in bibfiles(dirname, texname): - bbl = os.path.normpath(os.path.join(dirname, jobname+".bbl")) - if options.force or not os.path.isfile(bbl) or os.path.getmtime(bbl) < os.path.getmtime(bib): + # remove all outdated .bbl files (will be recreated by requests) + bbls = bblfiles(dirname, jobname) + bblname = jobname+".bbl" + for bib in bibfiles(dirname, texname): + bibpath = os.path.join(dirname, os.path.expanduser(bib)) + bibtime = os.path.getmtime(bibpath) + nextbbls = bbls[:] + for bbl in bbls: + bblpath = os.path.normpath(os.path.join(dirname, bbl)) + bbltime = os.path.getmtime(bblpath) + if options.force or bbltime < bibtime: reason = "" if options.verbosity: - if not os.path.isfile(bbl): - reason = " (because .bbl does not exist yet)" - elif os.path.getmtime(bbl) < os.path.getmtime(bib): - reason = " (because %s is newer than .bbl)"%bib + if bbltime < bibtime: + reason = " (because %s is newer than %s)"%(bib,bbl) else: reason = " (because of --force)" - run(["bibtex8", "--wolfgang", jobname], dirname, reason=reason) - runtex(tex, texname, realname, dirname, reason=" (because of updated .bbl)") - break + rmtempfile(bbl, dirname, force=True, reason=reason) + nextbbls.remove(bbl) + bbls = nextbbls + runtex(tex, texname, realname, dirname) + + if not options.singlerun: # check for undefined references and run requests numrun=0 reqs=options.act while reqs: reqs = requests(os.path.join(dirname, jobname+".log")) + if not reqs: break pri = reqs.values() pri.sort(reverse=True) + lastp = pri[0] + 1 for p in pri: + if p == lastp: continue + lastp = p for req in reqs.keys(): rp = reqs[req] if rp == p: @@ -377,8 +389,6 @@ def processtexfiles(args): reason = " (because of request in .aux file, priority %d)"%rp if req == "latex": runtex(tex, texname, realname, dirname, reason=reason) - elif req == "bibtex": - run(["bibtex8", "--wolfgang", jobname], dirname, reason=reason) elif isinstance(req, tuple): run(req, dirname, reason) else: @@ -478,12 +488,12 @@ def haderrors(dirname, jobname): f.close() return False -def rmtempfile(filename, dirname): +def rmtempfile(filename, dirname, force=False, reason=""): if options.deletetempfiles: if not isinstance(filename, list): filename = [filename] if options.verbosity > 1: - print " removing %s"%(", ".join(filename)) + print " removing %s%s"%(", ".join(filename), reason) if options.act: for f in filename: fullname = os.path.join(dirname, f) |
