From 27ee11a8d77f71f329d5cb6e4e58ce12ca148500 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Thu, 11 Apr 2019 18:15:43 -0500 Subject: [PATCH] get_dot_dependency_graph(): Don't use repr() to get statement labels Sometimes, it is useful to have labels that include escape sequences significant to the dot language. The string that comes from repr() doesn't allow us to do that because it escapes all the backslashes. >>> print(str("a\lb")) a\lb >>> print(repr("a\lb")) 'a\\lb' This change removes the use of repr() and documents that the statements are turned into strings using str(). --- pymbolic/imperative/utils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pymbolic/imperative/utils.py b/pymbolic/imperative/utils.py index fa13d57..bb69269 100644 --- a/pymbolic/imperative/utils.py +++ b/pymbolic/imperative/utils.py @@ -50,6 +50,8 @@ def get_dot_dependency_graph( """Return a string in the `dot `_ language depicting dependencies among kernel statements. + :arg statements: A sequence of statements, each of which is stringified by + calling :func:`str`. :arg preamble_hook: A function that returns an iterable of lines to add at the beginning of the graph :arg additional_lines_hook: A function that returns an iterable @@ -73,10 +75,7 @@ def get_dot_dependency_graph( stmt_label = str(stmt) tooltip = stmt.id - return "label=\"%s\",shape=\"box\",tooltip=\"%s\"" % ( - repr(stmt_label)[1:-1], - repr(tooltip)[1:-1], - ) + return "label=\"%s\",shape=\"box\",tooltip=\"%s\"" % (stmt_label, tooltip) lines = list(preamble_hook()) lines.append("rankdir=BT;") -- GitLab