def rewrite_legacy(config):
    """Rewrite legacy configuration to new format."""
    bridges = config.get('bridges', [config])
    new_bridges = []
    for bridge_conf in bridges:
        groups = []
        if 'groups' in bridge_conf:
            groups = bridge_conf['groups']
        else:
            _LOGGER.warning("Legacy configuration format detected")
            for i in range(1, 5):
                name_key = 'group_%d_name' % i
                if name_key in bridge_conf:
                    groups.append({
                        'number': i,
                        'type':  bridge_conf.get('group_%d_type' % i,
                                                 DEFAULT_LED_TYPE),
                        'name': bridge_conf.get(name_key)
                    })
        new_bridges.append({
            'host': bridge_conf.get('host'),
            'groups': groups
        })
    return {'bridges': new_bridges}
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/components/light/limitlessled.py/rewrite_legacy/original