# Path: netjsonconfig/backends/openwrt/schema.py



from ..schema import default_radio_driver
from .base import OpenWrtConverter


class Radios(OpenWrtConverter):
    netjson_key = 'radios'
    intermediate_key = 'wireless'
    _uci_types = ['wifi-device']

    def to_intermediate_loop(self, block, result, index=None):
        radio = self.__intermediate_radio(block)
        result.setdefault('wireless', [])
        result['wireless'].append(radio)
        return result

    def __intermediate_radio(self, radio):
        radio.update({'.type': 'wifi-device', '.name': radio.pop('name')})
        # rename tx_power to txpower
        if 'tx_power' in radio:
            radio['txpower'] = radio.pop('tx_power')
        # rename driver to type

# Path: netjsonconfig/backends/openwrt/schema.py



# Path: netjsonconfig/backends/openwrt/converters/radios.py
from ..schema import default_radio_driver
from .base import OpenWrtConverter



class Radios(OpenWrtConverter):
    netjson_key = 'radios'
    intermediate_key = 'wireless'
    _uci_types = ['wifi-device']

    def to_intermediate_loop(self, block, result, index=None):
        radio = self.__intermediate_radio(block)
        result.setdefault('wireless', [])
        result['wireless'].append(radio)
        return result

    def __intermediate_radio(self, radio):
        radio.update({'.type': 'wifi-device', '.name': radio.pop('name')})
        # rename tx_power to txpower
        if 'tx_power' in radio:
            radio['txpower'] = radio.pop('tx_power')
        # rename driver to type

        radio['type'] = radio.pop('driver', default_radio_driver)