Skip to content

Commit

Permalink
Adaptation clanDot python3 (#611)
Browse files Browse the repository at this point in the history
* cleanDotPython3Adaptation

* Documentation Adaptation for cleanDot

---------

Co-authored-by: Marco Calipari <marco.calipari.ext@siemens.com>
  • Loading branch information
marcoCalipari and Marco Calipari committed Dec 8, 2023
1 parent e6a90bf commit 2a52f12
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
4 changes: 3 additions & 1 deletion misc/cleandot/README.md
Expand Up @@ -17,7 +17,7 @@ Dependencies
In Ubuntu, the following should be sufficient to get things up and
running:

sudo apt-get install python-pyparsing python-pydot
sudo apt-get install python3-pyparsing python3-pydot

Usage
-----
Expand All @@ -37,3 +37,5 @@ paths, the following wrapper script can be used:

tamarin-prover-cleandot PROTOCOL_DIRECTORY



32 changes: 17 additions & 15 deletions misc/cleandot/tamarincleandotlib.py
Expand Up @@ -619,7 +619,7 @@ def parseLabel( strng ):
s = " as: %s\n" % (tokens)
appendLog(s)

except ParseException, err:
except ParseException as err:
s = str(err.line) + "\n"
s += " "*(err.column-1) + "^" + "\n"
s += str(err) + "\n"
Expand Down Expand Up @@ -717,9 +717,11 @@ def recordToList(s,start=0):
(fl2,i) = recordToList(s,i+1)
fl.append(["<recordflip>"] + fl2)
if i >= len(s):
raise ValueError, "Cannot parse record node (missing closing parenthesis? ) [%s]" % s
raise ValueError("Cannot parse record node (missing closing parenthesis? ) [%s]" % s)

if s[i] != "}":
raise ValueError, "Cannot parse record node (missing closing parenthesis? ) [%s]" % s
raise ValueError("Cannot parse record node (missing closing parenthesis? ) [%s]" % s)

i += 1
start = i
elif s[i] == "|":
Expand Down Expand Up @@ -972,7 +974,7 @@ def clear_node(G,N):
"""
Remove node N and its connected edges from the graph
"""
print "Clearing node ", N.get_name()
print ("Clearing node ", N.get_name())
for OE in incomingEdges(G,N):
del_edge(G,OE.get_source(),OE.get_destination())
for OE in outgoingEdges(G,N):
Expand Down Expand Up @@ -1039,7 +1041,7 @@ def leavePortAddress(t,coord=None):
return ""
i = t.find(">")
if i < 0:
raise ValueError, "Could not find port name end marker in [%s]" % (t)
raise (ValueError, "Could not find port name end marker in [%s]" % (t))
return t[:i+1]


Expand Down Expand Up @@ -1130,7 +1132,7 @@ def recordToSimpleHTML(N):

newlabel = "<<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\"><TR><TD>x</TD></TR><TR><TD>y</TD></TR></TABLE>>"
N.set_label(newlabel)
print "Set [", newlabel, "] for node ",N.get_name()
print ("Set [", newlabel, "] for node ",N.get_name())
N.set_shape("plaintext")


Expand Down Expand Up @@ -1768,7 +1770,7 @@ def joinSimilar(G,subsumetest=True):
appendLog("Parsing some labels\n")
label = joinLabels(labels)
if len(label) > 0:
print "Setting label for ", N1.get_name()
print ("Setting label for ", N1.get_name())
N1.set_label(label)
N1.set_shape("box")

Expand All @@ -1788,7 +1790,7 @@ def joinSimilar(G,subsumetest=True):
if containsOutgoingEdges(G,N1,N2):
# N1 can be subsumed by N2
label = joinLabels([N2.get_label(),N1.get_label()])
print "Setting label for ", N2.get_name()
print ("Setting label for ", N2.get_name())
N2.set_label(label)
N2.set("shape",'box')
if N1 not in toremove:
Expand Down Expand Up @@ -1884,8 +1886,8 @@ def colorRules(G):
if color != None:
nodecolor = "#" + multiplex(color,2)
N.set_fillcolor(nodecolor)
print "Attempted to set some color!"
print nodecolor
print ("Attempted to set some color!")
print (nodecolor)
return G


Expand Down Expand Up @@ -2017,10 +2019,10 @@ def main():
if DEBUGMODE:
import traceback

print "Unexpected error:", sys.exc_info()[0]
print ("Unexpected error:", sys.exc_info()[0])
report = traceback.format_exc()
appendLog(report)
print report
print (report)

# Something went wrong, fall back to default rendering method.
execDot(sys.argv[1:])
Expand Down Expand Up @@ -2101,9 +2103,9 @@ def experiment(L):

mfactor += step

print "Best we can do:"
print "mfactor", bestf
print "delta", bestd
print ("Best we can do:")
print (mfactor, bestf)
print("delta", bestd)

if __name__ == '__main__':
# L = [ ("A","B"), \
Expand Down

0 comments on commit 2a52f12

Please sign in to comment.