Find lines that match the linespec regex.

        :param linespec: regular expression of line to match
        :return: list of LineItem objects
356439
def find_objects(self, linespec):
        
        # Note(asr1kteam): In this code we are only adding children one-level
        # deep to a given parent (linespec), as that satisfies the IOS conf
        # parsing.
        # Note(asr1kteam): Not tested with tabs in the config. Currently used
        # with IOS config where we haven't seen tabs, but may be needed for a
        # more general case.
        res = []
        self._build_indent_based_list()
        for item, index in self._find_starts(linespec):
            parent = LineItem(item[1])
            next_ident_level = self._find_next_indent_level(index)
            if next_ident_level:
                # We start iterating from the next element
                for item in self._indent_list[(index + 1):]:
                    if item[0] == next_ident_level:
                        parent.add_children(LineItem(item[1]))
                    elif item[0] > next_ident_level:  # We skip higher indent
                        continue
                    else:  # Indent level is same or lesser than item
                        break
            res.append(parent)
        return res
768274
def has_multiline_items(maybe_list: Optional[Sequence[str]]):
    """"""
    return maybe_list and any(is_multiline(item) for item in maybe_list)
304498
def get_lines(self):
        
        code = []

        for counter, item in enumerate(self.model._default_manager.all()):
            instance = InstanceCode(instance=item, id=counter + 1, context=self.context, stdout=self.stdout, stderr=self.stderr, options=self.options)
            self.instances.append(instance)
            if instance.waiting_list:
                code += instance.lines

        # After each instance has been processed, try again.
        # This allows self referencing fields to work.
        for instance in self.instances:
            if instance.waiting_list:
                code += instance.lines

        return code
1068780
def get_matches_lineno(code, fn_name):
    ""
    class Walker(ast.NodeVisitor):
        def __init__(self):
            self._hits = set()

        #pylint: disable=E0213,E1102    
        def onvisit(fn):
            def wrap(self, node):
                fn(self,node)
                super(Walker, self).generic_visit(node)
            return wrap
        
        @onvisit
        def visit_FunctionDef(self, node):
            if node.name == fn_name:
                self._hits.add(node)
            return node
        
        @property
        def hits(self):
            return list(sorted([n.lineno + 1 for n in self._hits]))
    
    walker = Walker()
    walker.visit(ast.parse(code))
    return walker.hits
1034871
def _scan_line(self, line):
        
        is_quote_header = self.QUOTE_HDR_REGEX.match(line) is not None
        is_quoted = self.QUOTED_REGEX.match(line) is not None
        is_header = is_quote_header or self.HEADER_REGEX.match(line) is not None

        if self.fragment and len(line.strip()) == 0:
            if self.SIG_REGEX.match(self.fragment.lines[-1].strip()):
                self.fragment.signature = True
                self._finish_fragment()

        if self.fragment \
                and ((self.fragment.headers == is_header and self.fragment.quoted == is_quoted) or
                         (self.fragment.quoted and (is_quote_header or len(line.strip()) == 0))):

            self.fragment.lines.append(line)
        else:
            self._finish_fragment()
            self.fragment = Fragment(is_quoted, line, headers=is_header)
1035238
def is_splitter(line):
    '''
    
    '''
    for pattern in SPLITTER_PATTERNS:
        matcher = re.match(pattern, line)
        if matcher:
            return matcher
834975
def _lines(self):
        

        chunkIndices = self._listChunks()
        for chunkIndex in chunkIndices:
            with self._openChunk(chunkIndex) as chunk:
                yield from chunk._lines()
1062206
def _get_other_names(self, line):
        
        m = re.search(self.compound_regex['other_names'][0], line, re.IGNORECASE)
        if m:
            self.other_names.append(m.group(1).strip())
129327
def expr_match(line, expr):
    '''
    
    '''
    if line == expr:
        return True
    if fnmatch.fnmatch(line, expr):
        return True
    try:
        if re.match(r'\A{0}\Z'.format(expr), line):
            return True
    except re.error:
        pass
    return False
142097
def _findlinestarts(code):
  
  byte_increments = [ord(c) for c in code.co_lnotab[0::2]]
  line_increments = [ord(c) for c in code.co_lnotab[1::2]]

  lastlineno = None
  lineno = code.co_firstlineno
  addr = 0
  for byte_incr, line_incr in zip(byte_increments, line_increments):
    if byte_incr:
      if lineno != lastlineno:
        yield (addr, lineno)
        lastlineno = lineno
      addr += byte_incr
    lineno += line_incr
  if lineno != lastlineno:
    yield (addr, lineno)
1065915
def matches(self, msg_seq: int, msg: MessageInterface) -> bool:
        
        return all(crit.matches(msg_seq, msg) for crit in self.all_criteria)
404134
def get_line(self, text, on_unicode_error='strict'):
        

        def check(entry):
            if entry.find('\n') != -1:
                raise ValueError(
                    "get_line processes one line at a time (remove \'\\n\')"
                )
            entry += "\n"
            return entry

        if type(text) == list:
            text = [check(entry) for entry in text]
            return self.f.multilineGetLine(text, on_unicode_error)
        else:
            text = check(text)
            return self.f.getLine(text, on_unicode_error)
1241776
def find_lines_with(cls, lines, what):
        
        result = []
        for line in lines:
            if what in line:
                result = result + [line]
        return result
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)
945011
def filter_lines(lines, filter_regex, groups=None):
    
    pattern = re.compile(filter_regex)
    for line in lines:
        match = pattern.search(line)
        if match:
            if groups is None:
                yield line
            elif len(groups) == 1:
                yield match.group(groups[0])
            else:
                matched_groups = match.groupdict()
                yield tuple(matched_groups.get(group) for group in groups)
1329377
def join_lines(lines_enum):
    # type: (ReqFileLines) -> ReqFileLines
    
    primary_line_number = None
    new_line = []  # type: List[Text]
    for line_number, line in lines_enum:
        if not line.endswith('\\') or COMMENT_RE.match(line):
            if COMMENT_RE.match(line):
                # this ensures comments are always matched later
                line = ' ' + line
            if new_line:
                new_line.append(line)
                yield primary_line_number, ''.join(new_line)
                new_line = []
            else:
                yield line_number, line
        else:
            if not new_line:
                primary_line_number = line_number
            new_line.append(line.strip('\\'))

    # last line contains \
    if new_line:
        yield primary_line_number, ''.join(new_line)
572605
def match(line, keyword):
    

    line = line.lstrip()
    length = len(keyword)
    if line[:length] == keyword:
        return line[length:]
    else:
        if keyword in line:
            return line[line.index(keyword):]
        else:
            return None