Georg Brandl avatar Georg Brandl committed 7073334

Fix for graphviz map files from Sebastian Wiesner.

Comments (0)

Files changed (1)

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>)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.