code: def write_config_file(opts, config_file):
      
      parser = SafeConfigParser()
  
      if os.path.exists(config_file):
          parser.read(config_file)
  
      for sec_name in opts:
          sec_opts = opts[sec_name]
  
          if parser.has_section(sec_name):
              parser.remove_section(sec_name)
  
          parser.add_section(sec_name)
          for opt_name, opt_value in sec_opts.items():
              if opt_value is None:
                  opt_value = ''
  
              parser.set(sec_name, opt_name, '{}'.format(opt_value))
  
      with open(config_file, 'w') as fout:
          os.fchmod(fout.fileno(), 0600)
          parser.write(fout)
  
      return True
docs: Write our config file with the given options dict.
      Each key is a section name, and each value is the list of options.
  
      If the file exists, do not remove unaffected sections.  Instead,
      merge the sections in opts into the file.
  
      Return True on success
      Raise on error