def _write_file_ifaces(iface, data, **settings):
    '''
    Writes a file to disk
    '''
    try:
        eth_template = JINJA.get_template('debian_eth.jinja')
        source_template = JINJA.get_template('debian_source.jinja')
    except jinja2.exceptions.TemplateNotFound:
        log.error('Could not load template debian_eth.jinja')
        return ''

    # Read /etc/network/interfaces into a dict
    adapters = _parse_interfaces()
    # Apply supplied settings over on-disk settings
    adapters[iface] = data

    ifcfg = ''
    for adapter in adapters:
        if 'type' in adapters[adapter] and adapters[adapter]['type'] == 'slave':
            # Override values so the interfaces file is correct
            adapters[adapter]['data']['inet']['addrfam'] = 'inet'
            adapters[adapter]['data']['inet']['proto'] = 'manual'
            adapters[adapter]['data']['inet']['master'] = adapters[adapter]['master']

        if 'type' in adapters[adapter] and adapters[adapter]['type'] == 'source':
            tmp = source_template.render({'name': adapter, 'data': adapters[adapter]})
        else:
            tmp = eth_template.render({'name': adapter, 'data': adapters[adapter]})
        ifcfg = ifcfg + tmp
        if adapter == iface:
            saved_ifcfg = tmp

    _SEPERATE_FILE = False
    if 'filename' in settings:
        if not settings['filename'].startswith('/'):
            filename = '{0}/{1}'.format(_DEB_NETWORK_DIR, settings['filename'])
        else:
            filename = settings['filename']
        _SEPERATE_FILE = True
    else:
        if 'filename' in adapters[adapter]['data']:
            filename = adapters[adapter]['data']
        else:
            filename = _DEB_NETWORK_FILE

    if not os.path.exists(os.path.dirname(filename)):
        msg = '{0} cannot be written.'
        msg = msg.format(os.path.dirname(filename))
        log.error(msg)
        raise AttributeError(msg)
    with salt.utils.flopen(filename, 'w') as fout:
        if _SEPERATE_FILE:
            fout.write(saved_ifcfg)
        else:
            fout.write(ifcfg)

    # Return as a array so the difflib works
    return saved_ifcfg.split('\n')
dataset/ETHPy150Open saltstack/salt/salt/modules/debian_ip.py/_write_file_ifaces/original