Write the top section of the txt file.
        :param int section_num: Section number
        :return none:
357707
def __write_top(self, filename_txt):
        
        logger_lpd_noaa.info("writing section: {}".format("top"))
        self.__create_blanks("Top", self.noaa_data_sorted["Top"])

        # Start writing the NOAA file section by section, starting at the very top of the template.
        self.noaa_txt += "# {}".format(self.noaa_data_sorted["Top"]['Study_Name'])
        self.__write_template_top()
        # We don't know what the full online resource path will be yet, so leave the base path only
        self.__write_k_v("Online_Resource", "{}/{}".format(self.wds_url, filename_txt), top=True)
        self.__write_k_v("Online_Resource_Description", " This file.  NOAA WDS Paleo formatted metadata and data for version {} of this dataset.".format(self.version), indent=True)
        self.__write_k_v("Online_Resource", "{}".format(self.lpd_file_url), top=True)
        self.__write_k_v("Online_Resource_Description", " Linked Paleo Data (LiPD) formatted file containing the same metadata and data as this file, for version {} of this dataset.".format(self.version), indent=True)
        self.__write_k_v("Original_Source_URL", self.noaa_data_sorted["Top"]['Original_Source_URL'], top=True)
        self.noaa_txt += "\n# Description/Documentation lines begin with #\n# Data lines have no #\n#"
        self.__write_k_v("Archive", self.noaa_data_sorted["Top"]['Archive'])
        self.__write_k_v("Parameter_Keywords", self.noaa_data_sorted["Top"]['Parameter_Keywords'])

        # get the doi from the pub section of self.steps_dict[6]
        # doi = self.__get_doi()
        self.__write_k_v("Dataset_DOI",  ', '.join(self.doi), False, True, False, False)
        # self.__write_k_v("Parameter_Keywords", self.steps_dict[section_num]['parameterKeywords'])
        self.__write_divider()
        logger_lpd_noaa.info("exit write_top")
        return
1187715
def _write_default_sections(self):
        
        self.config.add_section('metadata')
        self.config.set('metadata', 'shared', 'common')
        self.config.add_section('common')
        self.config.add_section('development')
        self.config.add_section('production')
146219
def set_section_order(self, section_name_list):
        
        self.section_headings = section_name_list[:]
        for section_name in self.sections.keys():
            if section_name not in section_name_list:
                self.section_headings.append(section_name)
        return
823707
def write(self, fp):
        """"""
        if self._defaults:
            fp.write("[%s]\n" % DEFAULTSECT)
            for (key, value) in self._defaults.items():
                fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t')))
            fp.write("\n")
        for section in self._sections:
            fp.write("[%s]\n" % section)
            for (key, value) in self._sections[section].items():
                if key == "__name__":
                    continue
                if (value is not None) or (self._optcre == self.OPTCRE):
                    key = " = ".join((key, str(value).replace('\n', '\n\t')))
                fp.write("%s\n" % (key))
            fp.write("\n")
1035910
def section(self, section):
        
        if isinstance(section, list):
            for h in section:
                self.add_section(h)
        else:
            self.add_section(section)
1363948
def add_section(self, section):
        

        if not issubclass(section.__class__, SubSection):
            raise TypeError("Argument should be a subclass of SubSection, \
                             not :" + str(section.__class__))
        self.sections[section.name] = section
        return section
1032483
def wr_py_sections(self, fout_py, sections, doc=None):
        """"""
        if sections is None:
            sections = self.grprobj.get_sections_2d()
        sec2d_nt = self.get_sections_2dnt(sections)  # lists of GO Grouper namedtuples
        with open(fout_py, 'w') as prt:
            self._prt_py_sections(sec2d_nt, prt, doc)
            dat = SummarySec2dHdrGos().summarize_sec2hdrgos(sections)
            sys.stdout.write(self.grprobj.fmtsum.format(
                GO_DESC='hdr', SECs=len(dat['S']), GOs=len(dat['G']),
                UNGRP=len(dat['U']), undesc="unused",
                ACTION="WROTE:", FILE=fout_py))
763104
def finalizeSection(section):
    
    cur = section.first_child
    last = section.last_child
    if last is not None:
        last.nxt = None

    while cur is not None:
        cur.parent = section
        cur = cur.nxt
995105
def update_line(self, section, old_line, new_line, once=False):
        
        try:
            s = self._get_section(section, create=False)
        except KeyError:
            return 0
        return s.update(old_line, new_line, once=once)
276791
def write(self, fp, space_around_delimiters=True):
        
        if space_around_delimiters:
            d = " {0} ".format(self._delimiters[0])
        else:
            d = self._delimiters[0]
        if self._defaults:
            self._write_section(fp, self.default_section,
                                    self._defaults.items(), d)
        for section in self._sections:
            self._write_section(fp, section,
                                self._sections[section].items(), d)
607392
def section(self, section, skip=['type', 'order']):
        
        return [(key, val) for key, val in self.parser.items(section)
                if key not in skip]
642557
def per_section(it, is_delimiter=lambda x: x.isspace()):
    
    ret = []
    for line in it:
        if is_delimiter(line):
            if ret:
                yield ret  # OR  ''.join(ret)
                ret = []
        else:
            ret.append(line.rstrip())  # OR  ret.append(line)
    if ret:
        yield ret
1005967
function section(state, startLine, endLine, silent) {
  var ch,
    level,
    tmp,
    pos = state.bMarks[startLine] + state.tShift[startLine],
    max = state.eMarks[startLine];

  if (pos >= max) {
    return false;
  }

  ch = state.src.charCodeAt(pos);

  if (ch !== 0x23 /* # */ || pos >= max) {
    return false;
  }

  // count heading level
  level = 1;
  ch = state.src.charCodeAt(++pos);
  while (ch === 0x23 /* # */ && pos < max && level <= 6) {
    level++;
    ch = state.src.charCodeAt(++pos);
  }

  if (level > 6 || (pos < max && ch !== 0x20) /* space */) {
    return false;
  }

  pos++;
  let posibleMarker = state.src.substring(pos, pos + SECTION_MARKER.length);

  if (posibleMarker !== SECTION_MARKER) {
    return false;
  }
  pos = pos + SECTION_MARKER.length;

  // Let's cut tails like '    ###  ' from the end of string

  max = state.skipCharsBack(max, 0x20, pos); // space
  tmp = state.skipCharsBack(max, 0x23, pos); // #
  if (tmp > pos && state.src.charCodeAt(tmp - 1) === 0x20 /* space */) {
    max = tmp;
  }

  state.line = startLine + 1;

  let sectionHeader = state.src.slice(pos, max).trim();

  let nextLine = startLine + 1;
  let endRecoginzed = false;
  let contentEndLine;
  let innerSectionCounter = 0;

  for (; nextLine < endLine; nextLine++) {
    let line = state.getLines(nextLine, nextLine + 1, 0, false);

    if (SECTION_OPEN_REGEXP.test(line)) {
      innerSectionCounter++;
    }
    if (line === SECTION_MARKER) {
      // skip inner sections
      if (innerSectionCounter > 0) {
        innerSectionCounter--;
        continue;
      }
      contentEndLine = nextLine - 1;
      endRecoginzed = true;
      break;
    }
  }

  if (!endRecoginzed) {
    return false;
  }

  if (silent) {
    return true;
  }

  state.line = contentEndLine + 2;

  state.tokens.push({
    type: "section_open",
    hLevel: level,
    lines: [startLine, state.line],
    level: state.level,
    header: sectionHeader
  });

  state.line = startLine + 1;
  state.parser.tokenize(state, startLine + 1, contentEndLine, false);

  state.tokens.push({
    type: "section_close",
    hLevel: level,
    level: state.level
  });

  state.line = contentEndLine + 2;
  return true;
}
196090
def _write(self, fp):
        """"""
        def write_section(name, section_dict):
            fp.write(("[%s]\n" % name).encode(defenc))
            for (key, value) in section_dict.items():
                if key != "__name__":
                    fp.write(("\t%s = %s\n" % (key, self._value_to_string(value).replace('\n', '\n\t'))).encode(defenc))
                # END if key is not __name__
        # END section writing

        if self._defaults:
            write_section(cp.DEFAULTSECT, self._defaults)
        for name, value in self._sections.items():
            write_section(name, value)
604559
def GetSectionByIndex(self, section_index):
    
    if not self._is_parsed:
      self._Parse()
      self._is_parsed = True

    if section_index < 0 or section_index >= len(self._sections):
      return None

    return self._sections[section_index]
715741
def write(self):
        ''''''
        f = open('status.txt', mode='w')
        self.show(f)
        f.close()
559311
def wr_txt_nts(self, fout_txt, desc2nts, prtfmt=None):
        """"""
        with open(fout_txt, 'w') as prt:
            summary_dct = self._prt_txt_desc2nts(prt, desc2nts, prtfmt)
            if summary_dct:
                print(self.sortobj.grprobj.fmtsum.format(
                    ACTION="WROTE:", FILE=fout_txt, **summary_dct))
            else:
                print("  WROTE: {TXT}".format(TXT=fout_txt))