summaryrefslogtreecommitdiff
path: root/graph.py
diff options
context:
space:
mode:
authorkatia <devnull@localhost>2010-04-13 12:34:15 +0200
committerkatia <devnull@localhost>2010-04-13 12:34:15 +0200
commit0ec84e4250688cec149e9f157cb921812792d42d (patch)
tree6c9577a25b7b5690c3fd950303a3cbf0ebd75c53 /graph.py
parenta36230688db59afa11612f46809c4041e10701d5 (diff)
downloadlogilab-common-0ec84e4250688cec149e9f157cb921812792d42d.tar.gz
generate methods now takes an optional mapfile argument to generate html image maps
Diffstat (limited to 'graph.py')
-rw-r--r--graph.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/graph.py b/graph.py
index 92b2b56..638e96a 100644
--- a/graph.py
+++ b/graph.py
@@ -62,7 +62,7 @@ class DotBackend:
source = property(get_source)
- def generate(self, outputfile=None, dotfile=None):
+ def generate(self, outputfile=None, dotfile=None, mapfile=None):
"""Generates a graph file.
:param outputfile: filename and path [defaults to graphname.png]
@@ -98,7 +98,11 @@ class DotBackend:
pdot.write(self.source)
pdot.close()
if target != 'dot':
- subprocess.call('%s -T%s %s -o%s' % (self.renderer, target,
+ if mapfile:
+ subprocess.call('%s -Tcmapx -o%s -T%s %s -o%s' % (self.renderer, mapfile,
+ target, dot_sourcepath, outputfile), shell=True)
+ else:
+ subprocess.call('%s -T%s %s -o%s' % (self.renderer, target,
dot_sourcepath, outputfile), shell=True)
os.unlink(dot_sourcepath)
return outputfile
@@ -131,7 +135,7 @@ class GraphGenerator:
# the backend is responsible to output the graph in a particular format
self.backend = backend
- def generate(self, visitor, propshdlr, outputfile=None):
+ def generate(self, visitor, propshdlr, outputfile=None, mapfile=None):
# the visitor
# the property handler is used to get node and edge properties
# according to the graph and to the backend
@@ -142,7 +146,7 @@ class GraphGenerator:
for subjnode, objnode, edge in visitor.edges():
props = propshdlr.edge_properties(edge, subjnode, objnode)
self.backend.emit_edge(subjnode, objnode, **props)
- return self.backend.generate(outputfile)
+ return self.backend.generate(outputfile=outputfile, mapfile=mapfile)