Difference between revisions of "Makepacketdict"

From Second Life Wiki
Jump to navigation Jump to search
m
 
Line 1: Line 1:
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
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


<python>
<syntaxhighlight lang="python">
import re
import re


Line 21: Line 21:
     return dict
     return dict


</python>
</syntaxhighlight>
[[Category: AW Groupies]]
[[Category: AW Groupies]]

Latest revision as of 07:45, 27 June 2017

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