def to_port_ranges(ports):
    port_range_list = group_sequences(ports, are_in_sequence=lambda a, b: port_index(a) + 1 == port_index(b))

    out = []
    for port_range in port_range_list:
        if len(port_range) == 1:
            out.append("ethe %s" % split_port_name(port_range[0].name)[1])
        else:
            out.append("ethe %s to %s" %
                       (split_port_name(port_range[0].name)[1], split_port_name(port_range[-1].name)[1]))

    out_str = " ".join(out)
    return out_str
dataset/ETHPy150Open internap/fake-switches/fake_switches/brocade/command_processor/enabled.py/to_port_ranges/original