All pastes #485351 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-05-13 00:00 UTC
rendered paste body
    constellation = {}
    types = {}

    for hostname in hosts_file:
        hostname = hostname.strip()
        host_site = hostname.split('-', 1)

        if len(host_site) != 2:
            continue

        host, site = host_site
        type_num_pattern = re.compile(r"([A-Za-z_]+)([0-9]+)")
        type_num = type_num_pattern.match(host)
        type, num = type_num.groups()

        #print site, type, num

        if not type in types:
            types[type] = []
        types[type].append(num)
        if not site in constellation:
            constellation[site] = []
        constellation[site].append(types)

    print constellation
    print types