def compress(hostnames):
    """
    Compress a list of host into a more compact range representation
    """
    domain_dict = {}
    result = []
    for host in hostnames:
        if '.' in host:
            domain = '.'.join(host.split('.')[1:])
        else:
            domain = ''
        try:
            domain_dict[domain].append(host)
        except __HOLE__:
            domain_dict[domain] = [host]
    domains = list(domain_dict.keys())
    domains.sort()
    for domain in domains:
        hosts = compress_domain(domain_dict[domain])
        result += hosts
    return result
dataset/ETHPy150Open dwighthubbard/hostlists/hostlists/hostlists.py/compress