blob: b4605274eeaa854419cb1c634b3c26d7f38522f4 [file] [log] [blame]
Patrick Meredithb89dd232005-10-13 16:26:50 +00001#! /usr/bin/python
2
3#changelog:
4#10/13/2005: exntended to remove variables of the form %tmp(.#)* rather than just
5#%tmp.#, i.e. it now will remove %tmp.12.3.15 etc, additionally fixed a spelling error in
6#the comments
7#10/12/2005: now it only removes nodes and edges for which the label is %tmp.# rather
8#than removing all lines for which the lable CONTAINS %tmp.#
9import re
10import sys
11if( len(sys.argv) < 3 ):
12 print 'usage is: ./DSAclean <dot_file_to_be_cleaned> <out_put_file>'
13 sys.exit(1)
14#get a file object
15input = open(sys.argv[1], 'r')
16output = open(sys.argv[2], 'w')
17#we'll get this one line at a time...while we could just put the whole thing in a string
18#it would kill old computers
19buffer = input.readline()
20while buffer != '':
21 if re.compile("label(\s*)=(\s*)\"\s%tmp(.\d*)*(\s*)\"").search(buffer):
22 #skip next line, write neither this line nor the next
23 buffer = input.readline()
24 else:
25 #this isn't a tmp Node, we can write it
26 output.write(buffer)
27 #prepare for the next iteration
28 buffer = input.readline()
29input.close()
30output.close()