Files
Hippolyzer/pyogp/lib/base/message/msgdict.py
tao.takashi 6a6dd5fdb1 The big message system renaming:
- renamed all files starting with message_ to a name without message_
- exception: msgdict as dict is a reserved word
- moved all tests into the message/ directory
- changed all tests to use the new names
- changed all modules to use the new names
- shortened imports to not use the full path (pyogp.lib.base. but only the short path)
- removed makepacketdict.py as it's not needed anymore
- moved the data/ directory into message/ as it's local to the msg system

and some small cleanups on the way.

please run the tests!

I haven't adjusted pyogp.interop yet, Enus wanted to look after it.
2008-09-03 22:55:07 +00:00

42 lines
1.2 KiB
Python

from indra.base import llsd
class MessageDictionary(object):
def __init__(self, message_details):
if message_details == None:
raise Exception('Details file null')
#all the details of the file
self.message_details = {}
#only concerning messages
self.message_dict = {}
self.buildDictionary(message_details)
def buildDictionary(self, message_details):
self.message_details = llsd.parse(message_details)
message_dict = self.message_details['messages']
for message in message_dict:
self.message_dict[message] = message_dict[message]
def get_message(self, message_name):
if message_name in self.message_dict:
return self.message_dict[message_name]
return None
def get_message_flavor(self, message_name):
message = self.get_message(message_name)
if message == None:
return None
return message['flavor']
def get_trusted_sender(self, message_name):
message = self.get_message(message_name)
if message == None:
return None
return message['trusted-sender']
def __getitem__(self, i):
return self.get_message(i)