Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raganmd/7f7f59bf3999a59914baac72491deab4 to your computer and use it in GitHub Desktop.
Save raganmd/7f7f59bf3999a59914baac72491deab4 to your computer and use it in GitHub Desktop.
'''
The MessageParser and General classes are intended to be the
classes that persist from project to project. The parser is the meta
function that handles message receiving and sending.
'''
class MessageParser:
def __init__(self, my_op):
self.Me = my_op
print("Parser init")
return
def Process_message(self, message):
incoming_messagekind = message.get('messagekind')
# test to see if a matching method exists
if hasattr(self.Me, incoming_messagekind):
function = getattr(self.Me, incoming_messagekind)
# call the method if it exists
function(message)
else:
# return an invalid message if no matching method exists
print("Invalid Call")
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment