Commits

Georg Brandl committed 7073334

Fix for graphviz map files from Sebastian Wiesner.

  • Participants
  • Parent commits e94e28c

Comments (0)

Files changed (1)

File sphinx/ext/graphviz.py

         outfn = path.join(self.builder.outdir, fname)
 
     if path.isfile(outfn):
-        return relfn
+        return relfn, outfn
 
     if hasattr(self.builder, '_graphviz_warned_dot') or \
        hasattr(self.builder, '_graphviz_warned_ps2pdf'):
     if p.returncode != 0:
         raise GraphvizError('dot exited with error:\n[stderr]\n%s\n'
                             '[stdout]\n%s' % (stderr, stdout))
-    return relfn
+    return relfn, outfn
 
 
 def render_dot_html(self, node, code, options, prefix='graphviz', imgcls=None):
     try:
-        fname = render_dot(self, code, options, 'png', prefix)
+        fname, outfn = render_dot(self, code, options, 'png', prefix)
     except GraphvizError, exc:
         self.builder.warn('dot code %r: ' % code + str(exc))
         raise nodes.SkipNode
     if fname is None:
         self.body.append(self.encode(code))
     else:
-        mapfile = open(path.join(self.builder.outdir, fname) + '.map', 'rb')
-        imgmap = mapfile.readlines()
-        mapfile.close()
+        mapfile = open(outfn + '.map', 'rb')
+        try:
+            imgmap = mapfile.readlines()
+        finally:
+            mapfile.close()
         imgcss = imgcls and 'class="%s"' % imgcls or ''
         if len(imgmap) == 2:
             # nothing in image map (the lines are <map> and </map>)