original_docstring: 
          Write the current ConfigObj as a file
          
          tekNico: FIXME: use StringIO instead of real files
          
          >>> filename = a.filename
          >>> a.filename = 'test.ini'
          >>> a.write()
          >>> a.filename = filename
          >>> a == ConfigObj('test.ini', raise_errors=True)
          1
          >>> import os
          >>> os.remove('test.ini')
          
docstring: Write the current ConfigObj as a file
  tekNico: FIXME: use StringIO instead of real files
  
  
docstring_tokens: Write the current ConfigObj as a file tekNico : FIXME : use StringIO instead of real files
code: def write(self, outfile=None, section=None):
          """
          Write the current ConfigObj as a file
          
          tekNico: FIXME: use StringIO instead of real files
          
          >>> filename = a.filename
          >>> a.filename = 'test.ini'
          >>> a.write()
          >>> a.filename = filename
          >>> a == ConfigObj('test.ini', raise_errors=True)
          1
          >>> import os
          >>> os.remove('test.ini')
          """
          if self.indent_type is None:
              self.indent_type = DEFAULT_INDENT_TYPE
          out = []
          cs = self._a_to_u('#')
          csp = self._a_to_u('# ')
          if section is None:
              int_val = self.interpolation
              self.interpolation = False
              section = self
              for line in self.initial_comment:
                  line = self._decode_element(line)
                  stripped_line = line.strip()
                  if stripped_line:
                      if not stripped_line.startswith(cs):
                          line = csp + line
                      out.append(line)
  
          indent_string = self.indent_type * section.depth
          for entry in section.scalars + section.sections:
              if entry in section.defaults:
                  continue
              else:
                  for comment_line in section.comments[entry]:
                      comment_line = self._decode_element(comment_line.lstrip())
                      if comment_line:
                          if not comment_line.startswith(cs):
                              comment_line = csp + comment_line
                          out.append(indent_string + comment_line)
  
                  this_entry = section[entry]
                  comment = self._handle_comment(section.inline_comments[entry])
              if isinstance(this_entry, Section):
                  out.append(self._write_marker(indent_string, this_entry.depth, entry, comment))
                  out.extend(self.write(section=this_entry))
              else:
                  out.append(self._write_line(indent_string, entry, this_entry, comment))
  
          if section is self:
              for line in self.final_comment:
                  line = self._decode_element(line)
                  stripped_line = line.strip()
                  if stripped_line:
                      if not stripped_line.startswith(cs):
                          line = csp + line
                      out.append(line)
  
              self.interpolation = int_val
          if section is not self:
              return out
          if self.filename is None:
              if outfile is None:
                  if self.encoding:
                      out = [l.encode(self.encoding) for l in out]
                  if self.BOM:
                      if self.encoding is None or (BOM_LIST.get(self.encoding.lower()) == 'utf_8'):
                          if not out:
                              out.append('')
                          out[0] = BOM_UTF8 + out[0]
                      return out
          newline = self.newlines or os.linesep
          if getattr(outfile, 'mode', None) is not None:
              if outfile.mode == 'w':
                  if sys.platform == 'win32':
                      if newline == '\r\n':
                          newline = '\n'
          output = self._a_to_u(newline).join(out)
          if not output.endswith(newline):
              output += newline
          if isinstance(output, six.binary_type):
              output_bytes = output
          else:
              output_bytes = output.encode(self.encoding or self.default_encoding or 'ascii')
          if self.BOM:
              if self.encoding is None or (match_utf8(self.encoding)):
                  output_bytes = BOM_UTF8 + output_bytes
          if outfile is not None:
              outfile.write(output_bytes)
          else:
              with open(self.filename, 'wb') as h:
                  h.write(output_bytes)
code_tokens: def write ( self , outfile = None , section = None ) : if self . indent_type is None : self . indent_type = DEFAULT_INDENT_TYPE out = [ ] cs = self . _a_to_u ( '#' ) csp = self . _a_to_u ( '# ' ) if section is None : int_val = self . interpolation self . interpolation = False section = self for line in self . initial_comment : line = self . _decode_element ( line ) stripped_line = line . strip ( ) if stripped_line : if not stripped_line . startswith ( cs ) : line = csp + line out . append ( line ) indent_string = self . indent_type * section . depth for entry in section . scalars + section . sections : if entry in section . defaults : continue else : for comment_line in section . comments [ entry ] : comment_line = self . _decode_element ( comment_line . lstrip ( ) ) if comment_line : if not comment_line . startswith ( cs ) : comment_line = csp + comment_line out . append ( indent_string + comment_line ) this_entry = section [ entry ] comment = self . _handle_comment ( section . inline_comments [ entry ] ) if isinstance ( this_entry , Section ) : out . append ( self . _write_marker ( indent_string , this_entry . depth , entry , comment ) ) out . extend ( self . write ( section = this_entry ) ) else : out . append ( self . _write_line ( indent_string , entry , this_entry , comment ) ) if section is self : for line in self . final_comment : line = self . _decode_element ( line ) stripped_line = line . strip ( ) if stripped_line : if not stripped_line . startswith ( cs ) : line = csp + line out . append ( line ) self . interpolation = int_val if section is not self : return out if self . filename is None : if outfile is None : if self . encoding : out = [ l . encode ( self . encoding ) for l in out ] if self . BOM : if self . encoding is None or ( BOM_LIST . get ( self . encoding . lower ( ) ) == 'utf_8' ) : if not out : out . append ( '' ) out [ 0 ] = BOM_UTF8 + out [ 0 ] return out newline = self . newlines or os . linesep if getattr ( outfile , 'mode' , None ) is not None : if outfile . mode == 'w' : if sys . platform == 'win32' : if newline == '\r\n' : newline = '\n' output = self . _a_to_u ( newline ) . join ( out ) if not output . endswith ( newline ) : output += newline if isinstance ( output , six . binary_type ) : output_bytes = output else : output_bytes = output . encode ( self . encoding or self . default_encoding or 'ascii' ) if self . BOM : if self . encoding is None or ( match_utf8 ( self . encoding ) ) : output_bytes = BOM_UTF8 + output_bytes if outfile is not None : outfile . write ( output_bytes ) else : with open ( self . filename , 'wb' ) as h : h . write ( output_bytes )
short_docstring: Write the current ConfigObj as a file
  tekNico: FIXME: use StringIO instead of real files
short_docstring_tokens: Write the current ConfigObj as a file tekNico : FIXME : use StringIO instead of real files
comment: """
          Write the current ConfigObj as a file
          
          tekNico: FIXME: use StringIO instead of real files
          
          >>> filename = a.filename
          >>> a.filename = 'test.ini'
          >>> a.write()
          >>> a.filename = filename
          >>> a == ConfigObj('test.ini', raise_errors=True)
          1
          >>> import os
          >>> os.remove('test.ini')
          """