code: def write_file(filename, text):
      
      logging.debug(_('Writing file: %s'), filename)
      try:
          with open(filename, 'w') as writable:
              writable.write(text)
      except (PermissionError, NotADirectoryError):
          logging.error(_('Error writing file: %s'), filename)
          return False
      return True
docs: Write text to a file.