Attempt to fuzzily find matching lines.
508599
def _find_fuzzy_line(
        py_line_no, py_by_line_no, cheetah_by_line_no, prefer_first
):
    """"""
    stripped_line = _fuzz_py_line(py_by_line_no[py_line_no])
    cheetah_lower_bound, cheetah_upper_bound = _find_bounds(
        py_line_no, py_by_line_no, cheetah_by_line_no,
    )

    sliced = list(enumerate(cheetah_by_line_no))[
        cheetah_lower_bound:cheetah_upper_bound
    ]
    if not prefer_first:
        sliced = reversed(sliced)

    for line_no, line in sliced:
        if stripped_line in _fuzz_cheetah_line(line):
            return line_no
    else:
        # We've failed to find a matching line
        return 0
165559
def match(self, filepath):
        
        for pattern in self.__pattern:
            if len(fnmatch.filter([filepath], pattern)) > 0:
                return True
        return False
1035238
def is_splitter(line):
    '''
    
    '''
    for pattern in SPLITTER_PATTERNS:
        matcher = re.match(pattern, line)
        if matcher:
            return matcher
160646
def fuzzy_match(self, proc):
        
        return any(proc in row[self.command_name] for row in self.data)
429792
def matches(s, t, i, j, k):
    """"""
    for d in range(k):
        if s[i + d] != t[j + d]:
            return False
    return True
1221190
def _fuzzily_matches(response, candidate):
    ''''''
    r_words = response.split()
    c_words = candidate.split()
    # match whole words first
    for word in r_words:
        if word in c_words:
            r_words.remove(word)
            c_words.remove(word)
    # match partial words, fewest matches first
    match_pairs = []
    for partial in sorted(r_words, key=lambda p: len(p), reverse=True):
        matches = [w for w in c_words if partial in w]
        match_pairs.append((partial, matches))
    # if all items can be uniquly matched, the match is passed
    while len(match_pairs):
        min_pair = min(match_pairs, key=lambda x:len(x[1]))
        # this is the partial and matches with the shortest match list
        # if there are ever no matches for something, the match is failed
        if len(min_pair[1]) == 0:
            return False
        # choose the match with the fewest matches to remaining partials.
        # that way we leave more options for more partials, for the best
        # chance of a full match
        partials_left = [p[0] for p in match_pairs]
        min_option = min(min_pair[1], key=lambda x:len([p for p in partials_left if x in p]))
        # remove the current pair - we've matched it now
        match_pairs.remove(min_pair)
        # remove the matched option from all pairs' options so it won't be matched again
        for pair in match_pairs:
            pair_options = pair[1]
            if min_option in pair_options:
                pair_options.remove(min_option)
    # if all the items in the response were matched, this is match
    return True
565088
def match_indices(match):
    """"""
    a, b, size = match
    for i in range(size):
        yield a + i, b + i
1346834
def best_match_from_list(item,options,fuzzy=90,fname_match=True,fuzzy_fragment=None,guess=False):
    ''''''
    matches = matches_from_list(item,options,fuzzy,fname_match,fuzzy_fragment,guess)
    if len(matches)>0:
        return matches[0]
    return None
601270
def _fn_matches(fn, glob):
    """"""
    if glob not in _pattern_cache:
        pattern = _pattern_cache[glob] = re.compile(fnmatch.translate(glob))
        return pattern.match(fn)
    return _pattern_cache[glob].match(fn)
951424
def _matches(o, pattern):
    """"""
    if not len(o) == len(pattern):
        return False
    comps = zip(o,pattern)
    return all(isinstance(obj,kind) for obj,kind in comps)
872017
def match(self, pattern):
        """"""

        m = pattern.match(self._string, self._index)
        if m:
            self._index = m.end()
        return m
1073895
def find_matches(self, text):
        """"""
        if self.use_main_ns:
            self.namespace = __main__.__dict__

        if "." in text:
            return self.attr_matches(text)
        else:
            return self.global_matches(text)
1298370
def fnmatches(entry, *pattern_list):
    

    for pattern in pattern_list:
        if pattern and fnmatch(entry, pattern):
            return True
    return False
849051
def findLastCharIndexMatching(text, func):
    
    for i in range(len(text) - 1, -1, -1):
      if func(text[i]):
        return i
311039
def get_unaligned_lines(self):
    """"""
    sys.stderr.write("error unimplemented get_unaligned_lines\n")
    sys.exit()
    return [self._lines[x-1] for x in self._unaligned]
1204015
def get_lines(fname):
    """"""
    for line in fileinput.input(fname):
        yield fileinput.filelineno(), line.strip()
1241776
def find_lines_with(cls, lines, what):
        
        result = []
        for line in lines:
            if what in line:
                result = result + [line]
        return result