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

Skip to content

Commit 24be976

Browse files
committed
fixed a bug in texmanager.py: .aux files not being deleted
svn path=/trunk/matplotlib/; revision=1432
1 parent c179759 commit 24be976

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
New entries should be added at the top
22

3+
2005-06-07 Fixed a bug in texmanager.py: .aux files not being removed - DSD
4+
35
2005-06-06 Added autoscale_on prop to axes
46

57
2005-06-06 Added Nick's picker "among" patch - JDH

lib/matplotlib/texmanager.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
3232
"""
3333

34-
import os, sys, md5, shutil
34+
import glob, os, sys, md5, shutil
3535
from matplotlib import get_home, get_data_path, rcParams, verbose
3636
from matplotlib._image import readpng
3737
from matplotlib.numerix import ravel, where, array, \
@@ -57,15 +57,10 @@ def __init__(self):
5757
self.pscnt = 0
5858
self.dvipngVersion = None
5959

60-
def make_dvi(self, tex, force=0):
61-
if debug: force = True
60+
def get_prefix(self, tex):
61+
return md5.md5(tex).hexdigest()
6262

63-
prefix = self.get_prefix(tex)
64-
fname = os.path.join(self.texcache, prefix+ '.tex')
65-
dvitmp = prefix + '.dvi'
66-
dvifile = os.path.join(self.texcache, dvitmp)
67-
68-
logfile = prefix + '.log'
63+
def get_tex_command(self, tex, fname):
6964
fh = file(fname, 'w')
7065
if rcParams['text.tex.engine'] == 'latex':
7166
s = r"""\documentclass{article}
@@ -80,8 +75,6 @@ def make_dvi(self, tex, force=0):
8075
fh.write(s)
8176
fh.close()
8277
command = "latex -interaction=nonstopmode '%s'"%fname
83-
try: os.remove(prefix + '.aux')
84-
except OSError: pass
8578
else:
8679
s = r"""\def\frac#1#2{ {#1 \over #2} }
8780
\nopagenumbers
@@ -93,21 +86,26 @@ def make_dvi(self, tex, force=0):
9386
fh.write(s)
9487
fh.close()
9588
command = 'tex %s'%fname
89+
return command
90+
91+
def make_dvi(self, tex, force=0):
92+
if debug: force = True
93+
94+
prefix = self.get_prefix(tex)
95+
fname = os.path.join(self.texcache, prefix+ '.tex')
96+
dvitmp = prefix + '.dvi'
97+
dvifile = os.path.join(self.texcache, dvitmp)
9698

9799
if force or not os.path.exists(dvifile):
98-
#sin, sout = os.popen2(command)
99-
#sout.close()
100+
command = self.get_tex_command(tex, fname)
100101
stdin, stdout, stderr = os.popen3(command)
101102
verbose.report(''.join(stdout.readlines()), 'debug-annoying')
102103
err = ''.join(stderr.readlines())
103104
if err: verbose.report(err, 'helpful')
104105
shutil.move(dvitmp, dvifile)
105-
os.remove(logfile)
106+
cleanup = glob.glob(prefix+'.*')
107+
for fname in cleanup: os.remove(fname)
106108
return dvifile
107-
108-
109-
def get_prefix(self, tex):
110-
return md5.md5(tex).hexdigest()
111109

112110
def make_png(self, tex, dpi, force=0):
113111
if debug: force = True

0 commit comments

Comments
 (0)