def get_hostname(host):
    """
    This function get the hostname of the given host.

    :param host: The NmapHost object
    :type host: libnmap.objects.host.NmapHost

    :return: hostname
    :rtype: str
    """
    hostname = ''
    for name in host.hostnames:
        if name == 'localhost' and hostname != '':
            continue
        hostname = name
    return hostname
