Skip to content

Escape { to support dictionary in params #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions visualiser/visualiser.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ def wrapper(*args, **kwargs):
# Current function signature looks as follows:
# foo(1, 31, 0) or foo(a=1, b=31, c=0)
function_signature = f"{function_name}({signature_args_string})"
function_label = f"{function_name}({label_args_string})"
# Pydot needs us to escape certain special chars, namely { } and < >
function_label = re.escape(function_label)
function_label = function_label.replace("<","\<").replace(">","\>")
""""""

"""Details about caller function"""
Expand Down Expand Up @@ -247,11 +249,12 @@ def wrapper(*args, **kwargs):
if self.show_return_value:
# If shape is set to record
# Then separate function label and return value by a row
escaped_return_value = re.escape(str(result)).replace("<", "\<").replace(">", "\>")
if "record" in self.node_properties_kwargs.values():
function_label = "{" + \
function_label + f"|{result} }}"
function_label + f"|{escaped_return_value} }}"
else:
function_label += f"\n => {result}"
function_label += f"\n => {escaped_return_value}"

child_node = pydot.Node(name=function_signature,
label=function_label,
Expand Down