diff options
author | Sylvain <syt@logilab.fr> | 2007-03-06 15:01:20 +0100 |
---|---|---|
committer | Sylvain <syt@logilab.fr> | 2007-03-06 15:01:20 +0100 |
commit | 9b6590fc20ac401f10fafcbfd93188bd7a9f76c6 (patch) | |
tree | 198a477fd48cfe0bec8e028d5e88d5a53caf04be /graph.py | |
parent | 9d434c15d951d0acb34b43e1c54bc5072f23672c (diff) | |
download | logilab-common-9b6590fc20ac401f10fafcbfd93188bd7a9f76c6.tar.gz |
replace - by _ in dot node id
Diffstat (limited to 'graph.py')
-rw-r--r-- | graph.py | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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): |