summaryrefslogtreecommitdiff
path: root/graph.py
diff options
context:
space:
mode:
authorSylvain <syt@logilab.fr>2007-03-06 15:01:20 +0100
committerSylvain <syt@logilab.fr>2007-03-06 15:01:20 +0100
commit9b6590fc20ac401f10fafcbfd93188bd7a9f76c6 (patch)
tree198a477fd48cfe0bec8e028d5e88d5a53caf04be /graph.py
parent9d434c15d951d0acb34b43e1c54bc5072f23672c (diff)
downloadlogilab-common-9b6590fc20ac401f10fafcbfd93188bd7a9f76c6.tar.gz
replace - by _ in dot node id
Diffstat (limited to 'graph.py')
-rw-r--r--graph.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/graph.py b/graph.py
index 7def29f..81a16ba 100644
--- a/graph.py
+++ b/graph.py
@@ -3,7 +3,7 @@
(dot generation adapted from pypy/translator/tool/make_dot.py)
:organization: Logilab
-:copyright: 2003-2005 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+:copyright: 2003-2007 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
@@ -89,13 +89,15 @@ class DotBackend:
"""
attrs = ['%s="%s"' % (prop, value) for prop, value in props.items()]
self.emit('edge [%s];' % ", ".join(attrs))
- self.emit('%s -> %s' % (name1.replace(' ', '_'), name2.replace(' ', '_')))
+ self.emit('%s -> %s' % (normalize_node_id(name1), normalize_node_id(name2)))
def emit_node(self, name, **props):
"""authorized props: shape, label, color, fillcolor, style"""
attrs = ['%s="%s"' % (prop, value) for prop, value in props.items()]
- self.emit('%s [%s];' % (name.replace(' ', '_'), ", ".join(attrs)))
+ self.emit('%s [%s];' % (normalize_node_id(name), ", ".join(attrs)))
+def normalize_node_id(nid):
+ return nid.replace(' ', '_').replace('-', '_')
class GraphGenerator:
def __init__(self, backend):