'''This module generates a mapping of the message type integers to respective Request and Response message classes. ''' import paatti_pb2 # Fill in the available RPC commands from enum description. # Mapping is done by the name of the messages. # e.g. messagetypes[1].request == LoginRequest messagetypes = {} class MessageType: def __init__(self, name): self.name = name self.request = getattr(paatti_pb2, name + "Request") self.response = getattr(paatti_pb2, name + "Response") for command in paatti_pb2._RPCCOMMAND.values: if command.number == paatti_pb2.Error: continue # Don't include the error response in the list messagetypes[command.number] = MessageType(command.name)