Template dictionary python: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
name this file makepacketdict.py in order to use it | |||
<python> | <python> | ||
# uses the client's message_template.msg file to create a dictionary of name and other relevant packet info... | # uses the client's message_template.msg file to create a dictionary of name and other relevant packet info... | ||
Revision as of 14:58, 10 April 2008
name this file makepacketdict.py in order to use it
<python>
- uses the client's message_template.msg file to create a dictionary of name and other relevant packet info...
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],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>