import collections


def GetInfoByModule(module, struct_name):
  """Returns a namedtuple of useful type info."""
  Info = collections.namedtuple(  # pylint: disable=invalid-name
      'Info', ['module', 'struct_name', 'ctype', 'pack_size', 'unpack_size',
               'pack_func', 'unpack_func', 'header_file'])
  ctype = getattr(module, struct_name)
  return Info(module=module,
              struct_name=struct_name,
              ctype=ctype,
              pack_size='PACK_{}_SIZE'.format(struct_name.upper()),
              unpack_size='sizeof({})'.format(struct_name),
              pack_func='Pack{}'.format(struct_name),
              unpack_func='Unpack{}'.format(struct_name),
              header_file=module.H2PY_HEADER_FILE)