2020-07-15 09:31:13 +02:00
|
|
|
#!/usr/bin/env python
|
2005-10-13 16:26:50 +00:00
|
|
|
|
|
|
|
# changelog:
|
2005-10-13 17:31:30 +00:00
|
|
|
# 10/13/2005b: replaced the # in tmp(.#*)* with alphanumeric and _, this will then remove
|
|
|
|
# nodes such as %tmp.1.i and %tmp._i.3
|
2005-10-13 16:26:50 +00:00
|
|
|
# 10/13/2005: exntended to remove variables of the form %tmp(.#)* rather than just
|
|
|
|
#%tmp.#, i.e. it now will remove %tmp.12.3.15 etc, additionally fixed a spelling error in
|
|
|
|
# the comments
|
|
|
|
# 10/12/2005: now it only removes nodes and edges for which the label is %tmp.# rather
|
|
|
|
# than removing all lines for which the lable CONTAINS %tmp.#
|
2019-01-03 14:11:33 +00:00
|
|
|
|
|
|
|
from __future__ import print_function
|
|
|
|
|
2005-10-13 16:26:50 +00:00
|
|
|
import re
|
|
|
|
import sys
|
2023-05-15 11:02:42 +02:00
|
|
|
|
2005-10-13 16:26:50 +00:00
|
|
|
if len(sys.argv) < 3:
|
2019-01-03 14:11:33 +00:00
|
|
|
print("usage is: ./DSAclean <dot_file_to_be_cleaned> <out_put_file>")
|
2005-10-13 16:26:50 +00:00
|
|
|
sys.exit(1)
|
|
|
|
# get a file object
|
|
|
|
input = open(sys.argv[1], "r")
|
|
|
|
output = open(sys.argv[2], "w")
|
|
|
|
# we'll get this one line at a time...while we could just put the whole thing in a string
|
|
|
|
# it would kill old computers
|
|
|
|
buffer = input.readline()
|
|
|
|
while buffer != "":
|
2005-10-13 17:31:30 +00:00
|
|
|
if re.compile('label(\s*)=(\s*)"\s%tmp(.\w*)*(\s*)"').search(buffer):
|
2005-10-13 16:26:50 +00:00
|
|
|
# skip next line, write neither this line nor the next
|
|
|
|
buffer = input.readline()
|
|
|
|
else:
|
|
|
|
# this isn't a tmp Node, we can write it
|
|
|
|
output.write(buffer)
|
|
|
|
# prepare for the next iteration
|
|
|
|
buffer = input.readline()
|
|
|
|
input.close()
|
|
|
|
output.close()
|