Makepacketdict
Revision as of 15:56, 10 April 2008 by Saijanai Kuhn (talk | contribs) (New page: brain-dead import. While it should work as-is for testing, the parsing requires you eleiminate all extraneous spaces in the white space in "message_template.msg" before the "{" and replace...)
brain-dead import. While it should work as-is for testing, the parsing requires you eleiminate all extraneous spaces in the white space in "message_template.msg" before the "{" and replace it with tabs
<python>
import re
def makepacketdict():
dict = {} for line in open("message_template.msg", ).xreadlines(): results = re.match("^\t([^\t{}]+.+)",line) if results: aline = results.group(1) aline = aline.split() if aline[1] == "Fixed": dict[(aline[1],aline[2])] = (aline[0],aline[3], aline[4]) #print (aline[1],aline[2]) #print (aline[1],"0x"+aline[2]), dict[(aline[1],"0x"+aline[2])] #dict[(aline[1],int("0x"+aline[2][8:],16))] = (aline[0],aline[3], aline[4]) else: dict[(aline[1],int(aline[2]))] = (aline[0],aline[3], aline[4]) return dict
</python>