code: def write_autoconf(self, filename,
                         header="/* Generated by Kconfiglib (https://github.com/ulfalizer/Kconfiglib) */\n"):
          r
          with self._open(filename, "w") as f:
              f.write(header)
  
              for sym in self.unique_defined_syms:
                  # Note: _write_to_conf is determined when the value is
                  # calculated. This is a hidden function call due to
                  # property magic.
                  val = sym.str_value
                  if sym._write_to_conf:
                      if sym.orig_type in _BOOL_TRISTATE:
                          if val != "n":
                              f.write("#define {}{}{} 1\n"
                                      .format(self.config_prefix, sym.name,
                                              "_MODULE" if val == "m" else ""))
  
                      elif sym.orig_type is STRING:
                          f.write('#define {}{} "{}"\n'
                                  .format(self.config_prefix, sym.name,
                                          escape(val)))
  
                      else:  # sym.orig_type in _INT_HEX:
                          if sym.orig_type is HEX and \
                             not val.startswith(("0x", "0X")):
                              val = "0x" + val
  
                          f.write("#define {}{} {}\n"
                                  .format(self.config_prefix, sym.name, val))
docs: r"""
          Writes out symbol values as a C header file, matching the format used
          by include/generated/autoconf.h in the kernel.
  
          The ordering of the #defines matches the one generated by
          write_config(). The order in the C implementation depends on the hash
          table implementation as of writing, and so won't match.
  
          filename:
            Self-explanatory.
  
          header (default: "/* Generated by Kconfiglib (https://github.com/ulfalizer/Kconfiglib) */\n"):
            Text that will be inserted verbatim at the beginning of the file. You
            would usually want it enclosed in '/* */' to make it a C comment,
            and include a final terminating newline.