Gets all section titles given the entire data file string
18949
function getTitles(fileString) {
    var headerMatchCode = '(-){4,}[\\S\\s]+?(\\n){2,}(-){4,}';
    var headerRegExp = new RegExp(headerMatchCode, 'gi');
    var rawTitleArray = fileString.match(headerRegExp);
    var titleArray = [];
    if (rawTitleArray === null) {
        return null;
    }
    for (var i = 0, len = rawTitleArray.length; i < len; i++) {
        var tempTitle = cleanUpTitle(rawTitleArray[i]);
        //exception to the rule, claim lines
        if (tempTitle.toLowerCase().indexOf("claim lines for claim number") < 0 &&
            tempTitle.length > 0) {
            titleArray[i] = tempTitle;
        }
    }
    return titleArray;
}
1131828
def find_fragments(base_directory, sections, fragment_directory, definitions):
    
    content = OrderedDict()
    fragment_filenames = []

    for key, val in sections.items():

        if fragment_directory is not None:
            section_dir = os.path.join(base_directory, val, fragment_directory)
        else:
            section_dir = os.path.join(base_directory, val)

        files = os.listdir(section_dir)

        file_content = {}

        for basename in files:
            parts = basename.split(u".")

            counter = 0
            if len(parts) == 1:
                continue
            else:
                ticket, category = parts[:2]

            # If there is a number after the category then use it as a counter,
            # otherwise ignore it.
            # This means 1.feature.1 and 1.feature do not conflict but
            # 1.feature.rst and 1.feature do.
            if len(parts) > 2:
                try:
                    counter = int(parts[2])
                except ValueError:
                    pass

            if category not in definitions:
                continue

            full_filename = os.path.join(section_dir, basename)
            fragment_filenames.append(full_filename)
            with open(full_filename, "rb") as f:
                data = f.read().decode("utf8", "replace")

            if (ticket, category, counter) in file_content:
                raise ValueError(
                    "multiple files for {}.{} in {}".format(
                        ticket, category, section_dir
                    )
                )
            file_content[ticket, category, counter] = data

        content[key] = file_content

    return content, fragment_filenames
775431
function getSectionName(article) {
  const { tiles } = article;

  if (!tiles) {
    return null;
  }

  const slices = tiles.reduce((acc, tile) => {
    acc.push(...tile.slices);
    return acc;
  }, []);
  const sections = slices.reduce((acc, slice) => {
    acc.push(...slice.sections);
    return acc;
  }, []);
  const titles = sections.map(section => section.title);

  if (titles.length === 0) {
    return null;
  }

  const nonNews = titles.filter(title => title !== "News");

  return nonNews.length ? nonNews[0] : "News";
}
740705
def read_sections(self, sections_file, get_goids_only, exclude_ungrouped):
        """"""
        ext = os.path.splitext(sections_file)[1]
        file_contents = None
        if ext == '.py':
            file_contents = self.read_py(sections_file, get_goids_only, exclude_ungrouped)
        else:
            file_contents = self.read_txt(sections_file, get_goids_only, exclude_ungrouped)
        if file_contents:
            return file_contents.get('sections', None)
969003
def _find_sections(self, name_type_pairs):
        """"""
        sections = [None] * len(name_type_pairs)
        for section in self.elf.sections:
            section_name = to_str_safe(section.name)
            section_type = section.type
            for i, name_and_type in enumerate(name_type_pairs):
                if name_and_type != (section_name, section_type):
                    continue
                if sections[i] is not None:
                    raise FlashAlgoException("Elf contains duplicate section %s attr %s" %
                                    (section_name, section_type))
                sections[i] = section
        return sections
750481
def sections(self) -> list:
        """"""
        self.config.read(self.filepath)
        return self.config.sections()
304952
def getElementText(self, node, preserve_ws=None):
        """"""
        result = []
        for child in node.childNodes:
            nodetype = child.nodeType
            if nodetype == child.TEXT_NODE or \
               nodetype == child.CDATA_SECTION_NODE:
                result.append(child.nodeValue)
        value = join(result, '')
        if preserve_ws is None:
            value = strip(value)
        return value
949260
def read_sections():
    """"""
    config = configparser.ConfigParser()
    config.read(('requirements.ini', 'setup.cfg', 'tox.ini'))
    return [
        (
            name,
            {
                key: parse_value(key, config[name][key])
                for key in config[name]
            }
        )
        for name in config.sections()
        if 'requirements' in name
    ]
271861
def _GetSectionNames(self, pefile_object):
    
    section_names = []
    for section in pefile_object.sections:
      section_name = getattr(section, 'Name', b'')
      # Ensure the name is decoded correctly.
      try:
        section_name = '{0:s}'.format(section_name.decode('unicode_escape'))
      except UnicodeDecodeError:
        section_name = '{0:s}'.format(repr(section_name))
      section_names.append(section_name)

    return section_names
801311
def all_terms(self):
        """"""

        for s_name, s in self.sections.items():

            # Yield the section header
            if s.name != 'Root':
                yield s

            # Yield all of the rows for terms in the section
            for rterm in s:
                yield rterm
                for d in rterm.descendents:
                    yield d
422409
def section_by_title(
            self,
            title: str,
    ) -> Optional[WikipediaPageSection]:
        
        if not self._called['extracts']:
            self._fetch('extracts')
        return self._section_mapping.get(title)
440876
def _get_title(self,directory,filename):
        """"""
        # =========== LOAD TITLE ========
        fullfile=os.path.join(directory,filename+'.title')
        try:
            logger.debug('trying to open [%s]'%(fullfile))
            _title=(open(fullfile).readline().strip())
            logger.debug("_updatemeta: %s - title is '%s'",filename,_title)
        except:
            _title=''

        return _title
682348
def normalized_title(title_string, type)
      return title_string if type != 'File'

      matches = title_string.match(%r{^(?<normalized_path>/|.+:/|.*[^/])/*\Z}m)
      matches[:normalized_path] || title_string
    end
855128
def get_section_hdrgos(self):
        """"""
        return set([h for _, hs in self.sections for h in hs]) if self.sections else set()
151412
def find_all(self, string, callback):
		
		for index, output in self.iter(string):
			callback(index, output)
959677
def _parseSections(self, data, imageDosHeader, imageNtHeaders, parse_header_only=False):
        """"""
        sections = []

        optional_header_offset = imageDosHeader.header.e_lfanew + 4 + sizeof(IMAGE_FILE_HEADER)
        offset = optional_header_offset + imageNtHeaders.header.FileHeader.SizeOfOptionalHeader  # start reading behind the dos- and ntheaders

        image_section_header_size = sizeof(IMAGE_SECTION_HEADER)

        for sectionNo in range(imageNtHeaders.header.FileHeader.NumberOfSections):
            ishdr = IMAGE_SECTION_HEADER.from_buffer(data, offset)

            if parse_header_only:
                raw = None
                bytes_ = bytearray()
            else:
                size = ishdr.SizeOfRawData
                raw = (c_ubyte * size).from_buffer(data, ishdr.PointerToRawData)
                bytes_ = bytearray(raw)

            sections.append(SectionData(header=ishdr, name=ishdr.Name.decode('ASCII', errors='ignore'), bytes=bytes_, raw=raw))

            offset += image_section_header_size

        return sections
1006553
def long_description(*filenames):
    """"""
    res = ['']
    for filename in filenames:
        with open(filename) as fp:
            for line in fp:
                res.append('   ' + line)
            res.append('')
        res.append('\n')
    return EMPTYSTRING.join(res)