Find a matching element in a list.
185176
def _find_match(ele, lst):
    '''
    
    '''
    for _ele in lst:
        for match_key in _MATCH_KEYS:
            if _ele.get(match_key) == ele.get(match_key):
                return ele
574647
def match(self, s):
      
      self.matches = self.re.search(s)
      return self.matches
348237
def search(cls, element, pattern):
        
        if isinstance(element, Layout):
            return [el for cell in element for el in cls.search(cell, pattern)]
        if isinstance(element, (NdOverlay, Overlay)):
            return [el for el in element if el.matches(pattern)]
        elif isinstance(element, Element):
            return [element] if element.matches(pattern) else []
107141
def intinlist(lst):
    """"""
    for item in lst:
        try:
            item = int(item)
            return True
        except ValueError:
            pass
    return False
1120811
def p_comparison_in_list(self, p):
        
        if len(p) == 2:
            p[0] = Comparison(operator=p[1])
        else:
            p[0] = Comparison(operator='%s %s' % (p[1], p[2]))
690463
def match_subselectors(self, el, selectors):
        """"""

        match = True
        for sel in selectors:
            if not self.match_selectors(el, sel):
                match = False
        return match
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)
208197
def get_matches(self, src, src_idx):
        
        if src not in ('l1', 'l2'):
            raise ValueError('Must have one of "l1" or "l2" as src')
        if src == 'l1':
            target_list = self.l2
        else:
            target_list = self.l1
        comparator = {
            'l1': lambda s_idx, t_idx: (s_idx, t_idx) in self.matches,
            'l2': lambda s_idx, t_idx: (t_idx, s_idx) in self.matches,
        }[src]

        return [(trg_idx, obj) for trg_idx, obj in enumerate(target_list)
                if comparator(src_idx, trg_idx)]
220034
function indexOf(list, element, comparator) {
			for (var i=0,item; item=list[i]; i++) {
				if (equals(item, element, comparator)) {
					return i;
				}
			}
			return -1;
		}
413076
def contains(self, element, key=lambda x: x):
        
        return self.select(key).any(lambda x: x == key(element))
975144
def is_list(node):
    """"""
    return (isinstance(node, Node)
            and len(node.children) > 1
            and isinstance(node.children[0], Leaf)
            and isinstance(node.children[-1], Leaf)
            and node.children[0].value == u"["
            and node.children[-1].value == u"]")
1133568
def match1(pattern, data, **parse_kwargs):
    """"""
    matches = match(pattern, data, **parse_kwargs)
    return matches[0] if matches else None
160321
def at_match(self, match, predicate=None, index=None):
        
        return self.at_span(match.span, predicate, index)
429792
def matches(s, t, i, j, k):
    """"""
    for d in range(k):
        if s[i + d] != t[j + d]:
            return False
    return True
848009
def find_close_value(self, LIST, value):
        '''
        
        '''
        diff = inf
        for a in LIST:
            if abs(value - a) < diff:
                diff = abs(value - a)
                result = a
        return(result)
480029
def find(self, node, interval, start, end):
        """"""
        data = []
        
        if len(interval) != 2:
            raise SyntaxError('Interval malformed %s. Allways specify start and end position for interval.' % str(interval))
        
        left = (start, node[0])
        right = (node[0], end)

        if self.overlap(left, interval):
            data.extend(node[-1])
            if node[1] != -1:
                data.extend(self.find(node[1], interval, left[0], left[1]))

        if self.overlap(right, interval):
            data.extend(node[-1])
            if node[2] != -1:
                data.extend(self.find(node[2], interval, right[0], right[1]))

        return list(set(data))
64020
def find(self, string, default=None):
        """"""
        return self.match(string) or self.search(string) or default