def _make_message_type(name, attributes, has_data=True):
  """Make a message type for the AdbTransport subclasses."""

  def AssertCommandIs(self, command):  # pylint: disable=invalid-name
    """Assert that a message's command matches the given command."""
    if self.command != command:
      raise usb_exceptions.AdbProtocolError(
          'Expected %s command, received %s', command, self)

  return type(name, (collections.namedtuple(name, attributes),),
              {
                  'AssertCommandIs': AssertCommandIs,
                  'has_data': has_data,
                  # Struct format on the wire has an unsigned int for each attr.
                  'struct_format': '<%sI' % len(attributes.split()),
              })
dataset/ETHPy150Open google/openhtf/openhtf/plugs/usb/filesync_service.py/_make_message_type/original