Parse list of lines with metadata information from SOFT file.

    Args:
        lines (:obj:`Iterable`): Iterator over the lines.

    Returns:
        :obj:`dict`: Metadata from SOFT file.
973980
def parse_metadata(lines):
    
    meta = defaultdict(list)
    for line in lines:
        line = line.rstrip()
        if line.startswith("!"):
            if "_table_begin" in line or "_table_end" in line:
                continue
            key, value = __parse_entry(line)
            meta[key].append(value)

    return dict(meta)
432971
def iter_lines(f):
    
    linenum = 1
    try:
        for text in f.readlines():
            # ignore lines that consist entirely of whitespace
            if text.isspace():
                continue
            indent,value = parse_line(text)
            yield linenum,indent,value
            linenum += 1
    except:
        raise ParserError(linenum, 0, '', 'failed to parse line')
418054
def parse(self, line, **options):
        
        line = line.strip()
        if not line:
            return (False, (), {})
        split = line.split()
        cmd, args = split[0], split[1:]
        return (cmd, args, {})
594960
def parse_line(self, line):
        """"""
        # The parser may only need to run until it has seen a specific line.
        # Once that's occurred, it can mark itself as complete, to save
        # being run against later log lines.
        if self.parser.complete:
            return

        # Perf data is stored in a json structure contained in a single line,
        # if the MAX_LINE_LENGTH is applied the data structure could be
        # truncated, preventing it from being ingested.
        if 'PERFHERDER_DATA' not in line:
            line = line[:self.MAX_LINE_LENGTH]

        self.parser.parse_line(line, self.lineno)
        self.lineno += 1
1241776
def find_lines_with(cls, lines, what):
        
        result = []
        for line in lines:
            if what in line:
                result = result + [line]
        return result
306570
def _parse_line(self, line):
        
        fields = line.split('|', 4)  # stop splitting after fourth | found
        line_info = {'raw_message': line}
        if len(fields) == 5:
            line_info.update(dict(zip(self._fieldnames, fields)))
        return line_info
1374456
def parse_values_from_lines(self,lines):
        
        assert len(lines) == 3,"SvdData.parse_values_from_lines: expected " + \
                               "3 lines, not {0}".format(len(lines))
        try:
            self.svdmode = int(lines[0].strip().split()[0])
        except Exception as e:
            raise Exception("SvdData.parse_values_from_lines: error parsing" + \
                            " svdmode from line {0}: {1} \n".format(lines[0],str(e)))
        try:
            raw = lines[1].strip().split()
            self.maxsing = int(raw[0])
            self.eigthresh = float(raw[1])
        except Exception as e:
            raise Exception("SvdData.parse_values_from_lines: error parsing" + \
                            " maxsing and eigthresh from line {0}: {1} \n"\
                            .format(lines[1],str(e)))
        # try:
        #     self.eigwrite = int(lines[2].strip())
        # except Exception as e:
        #     raise Exception("SvdData.parse_values_from_lines: error parsing" + \
        #                     " eigwrite from line {0}: {1} \n".format(lines[2],str(e)))
        self.eigwrite = lines[2].strip()
170898
async def _parse_lines(lines, regex):
    
    results = []
    if inspect.iscoroutinefunction(lines):
        lines = await lines
    for line in lines:
        if line:
            match = regex.search(line)
            if not match:
                _LOGGER.debug("Could not parse row: %s", line)
                continue
            results.append(match.groupdict())
    return results
875380
def _line_to_dict(self, file, field_names):
        
        for line in file:
            delimiter = settings.IPGEOBASE_FILE_FIELDS_DELIMITER
            yield self._extract_data_from_line(line, field_names, delimiter)
11484
def _extract_line_features(self):
        
        for line in self.line_iterator:
            m = re.search(GENERIC_IPV4_REGEX, line)

            data = {
                'raw': line
            }

            if m:
                data['ip'] = m.group('ip')

            self.parsed_lines.append(data)
42573
def __get_line_profile_data(self):
        
        if self.line_profiler is None:
            return {}

        # the [0] is because pprofile.Profile.file_dict stores the line_dict
        # in a list so that it can be modified in a thread-safe way
        # see https://github.com/vpelletier/pprofile/blob/da3d60a1b59a061a0e2113bf768b7cb4bf002ccb/pprofile.py#L398
        return self.line_profiler.file_dict[self.pyfile.path][0].line_dict
1209607
def read_lines_from_file(cls_name, filename):
  """"""
  with tf.io.gfile.GFile(filename, "rb") as f:
    lines = [tf.compat.as_text(line)[:-1] for line in f]
  header_line = "%s%s" % (_HEADER_PREFIX, cls_name)
  if lines[0] != header_line:
    raise ValueError("File {fname} does not seem to have been created from "
                     "{name}.save_to_file.".format(
                         fname=filename, name=cls_name))
  metadata_dict = json.loads(lines[1][len(_METADATA_PREFIX):])
  return lines[2:], metadata_dict
1161761
def parse_line_headers(self, line):
        
        headers = line.split(",")
        for i, v in enumerate(headers):
            if v:
                headers[i] = v
            else:
                headers[i] = str(i)
        self.headers = headers
1253905
def parse_lines(self, lines: Iterable[str]) -> List[ParseResults]:
        """"""
        return [
            self.parseString(line, line_number)
            for line_number, line in enumerate(lines)
        ]
1298035
def iter_lines(file_like: Iterable[str]) -> Generator[str, None, None]:
    
    for line in file_like:
        line = line.rstrip('\r\n')
        if line:
            yield line
662064
def _get_lines_from_file(self, filename, lineno, context_lines, loader=None, module_name=None):
        
        source = None
        if loader is not None and hasattr(loader, "get_source"):
            try:
                source = loader.get_source(module_name)
            except ImportError:
                pass
            if source is not None:
                source = source.splitlines()
        if source is None:
            try:
                with open(filename, 'rb') as fp:
                    source = fp.read().splitlines()
            except (OSError, IOError):
                pass
        if source is None:
            return None, [], None, []

        # If we just read the source from a file, or if the loader did not
        # apply tokenize.detect_encoding to decode the source into a Unicode
        # string, then we should do that ourselves.
        if isinstance(source[0], six.binary_type):
            encoding = 'ascii'
            for line in source[:2]:
                # File coding may be specified. Match pattern from PEP-263
                # (http://www.python.org/dev/peps/pep-0263/)
                match = re.search(br'coding[:=]\s*([-\w.]+)', line)
                if match:
                    encoding = match.group(1).decode('ascii')
                    break
            source = [six.text_type(sline, encoding, 'replace') for sline in source]

        lower_bound = max(0, lineno - context_lines)
        upper_bound = lineno + context_lines

        pre_context = source[lower_bound:lineno]
        context_line = source[lineno]
        post_context = source[lineno + 1:upper_bound]

        return lower_bound, pre_context, context_line, post_context
1066922
def _parseSections(self, data):
        
        section_dict = {}
        lines = data.splitlines()
        idx = 0
        numlines = len(lines)
        section = None
        while idx < numlines:
            line = lines[idx]
            idx += 1
            mobj = re.match('^(\w[\w\s\(\)]+[\w\)])\s*:$', line)
            if mobj:
                section = mobj.group(1)
                section_dict[section] = []
            else:
                mobj = re.match('(\t|\s)\s*(\w.*)$', line)
                if mobj:
                    section_dict[section].append(mobj.group(2))
                else:
                    mobj = re.match('^(\w[\w\s\(\)]+[\w\)])\s*:\s*(\S.*)$', line)
                    if mobj:
                        section = None
                        if not section_dict.has_key(section):
                            section_dict[section] = []
                        section_dict[section].append(line)
                    else:
                        if not section_dict.has_key('PARSEERROR'):
                            section_dict['PARSEERROR'] = []
                        section_dict['PARSEERROR'].append(line)   
        return section_dict