docs: def _write_file(folder, filename, data):
      '''
      Writes a file to disk
      '''
      path = os.path.join(folder, filename)
      if not os.path.exists(folder):
          msg = '{0} cannot be written. {1} does not exist'.format(filename, folder)
          log.error(msg)
          raise AttributeError(six.text_type(msg))
      with salt.utils.files.fopen(path, 'w') as fp_:
          fp_.write(salt.utils.stringutils.to_str(data))
  
      return 0