Makepacketdict

From Second Life Wiki
Jump to: navigation, search

brain-dead import. While it should work as-is for testing, the parsing requires you eliminate all extraneous spaces in the white space in "message_template.msg" before the "{" and replace it with tabs

import re
 
def makepacketdict():
    dict = {}
    for line in open("message_template.msg"):
        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(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