def _recv_message(self, expected_type=None):
    """Reads a message from Google TV.

    Args:
      expected_type: If provided, verifies that the inner message is of the
          expected type.

    Returns:
      The inner message received from Google TV.

    Raises:
      AssertionError: If a bad status was received from Google TV.
      MessageTypeError: If an expected_type was provided and the received type
          does not match the expected.
    """
    types = polo_pb2.OuterMessage
    message_types = {
        types.MESSAGE_TYPE_CONFIGURATION: polo_pb2.Configuration,
        types.MESSAGE_TYPE_CONFIGURATION_ACK: polo_pb2.ConfigurationAck,
        types.MESSAGE_TYPE_OPTIONS: polo_pb2.Options,
        types.MESSAGE_TYPE_PAIRING_REQUEST: polo_pb2.PairingRequest,
        types.MESSAGE_TYPE_PAIRING_REQUEST_ACK: polo_pb2.PairingRequestAck,
        types.MESSAGE_TYPE_SECRET: polo_pb2.Secret,
        types.MESSAGE_TYPE_SECRET_ACK: polo_pb2.SecretAck,
    }

    data = self.recv()
    req = polo_pb2.OuterMessage.FromString(data)
    # TODO: Check req.status and figure out how to deal with not OK.
    assert req.status == polo_pb2.OuterMessage.STATUS_OK

    # If an expected_type is provided, then verify the received type.
    if expected_type and expected_type != req.type:
      expected = message_types[expected_type].__name__
      actual = message_types[req.type].__name__
      raise MessageTypeError('Expected %s but received %s' / (expected, actual))

    message_type = message_types[req.type]
    message = message_type.FromString(req.payload)
    return message
dataset/ETHPy150Open stevenle/googletv-anymote/googletv/__init__.py/PairingProtocol._recv_message/operator `%` -> `/`