Match past relationship.
350930
def match_past_relations(self, el, relation):
        """"""

        found = False
        if relation[0].rel_type == REL_PARENT:
            parent = self.get_parent(el, no_iframe=self.iframe_restrict)
            while not found and parent:
                found = self.match_selectors(parent, relation)
                parent = self.get_parent(parent, no_iframe=self.iframe_restrict)
        elif relation[0].rel_type == REL_CLOSE_PARENT:
            parent = self.get_parent(el, no_iframe=self.iframe_restrict)
            if parent:
                found = self.match_selectors(parent, relation)
        elif relation[0].rel_type == REL_SIBLING:
            sibling = self.get_previous_tag(el)
            while not found and sibling:
                found = self.match_selectors(sibling, relation)
                sibling = self.get_previous_tag(sibling)
        elif relation[0].rel_type == REL_CLOSE_SIBLING:
            sibling = self.get_previous_tag(el)
            if sibling and self.is_tag(sibling):
                found = self.match_selectors(sibling, relation)
        return found
323298
def __unify_unique_identities(self, uidentities, matcher,
                                  fast_matching, interactive):
        """"""

        self.total = len(uidentities)
        self.matched = 0

        if self.recovery and self.recovery_file.exists():
            print("Loading matches from recovery file: %s" % self.recovery_file.location())
            matched = self.recovery_file.load_matches()
        else:
            matched = match(uidentities, matcher, fastmode=fast_matching)
            # convert the matched identities to a common JSON format to ease resuming operations
            matched = self.__marshal_matches(matched)

        self.__merge(matched, interactive)

        if self.recovery:
            self.recovery_file.delete()
500619
def match(self, models, results, relation):
        
        return self.match_many(models, results, relation)
1305497
final boolean match(JmsJcaUserDetails userDetails,
                        SICoreConnection coreConnection) {

        boolean usersMatch = (_userDetails == null) ? (userDetails == null)
                        : (_userDetails.equals(userDetails));
        boolean coreConnectionsMatch = (coreConnection == null)
                                       || coreConnection.isEquivalentTo(_coreConnection);

        return usersMatch && coreConnectionsMatch && isValid();
    }
61323
def _hashes_match(self, a, b):
        """"""
        if len(a) != len(b):
            return False
        diff = 0
        if six.PY2:
            a = bytearray(a)
            b = bytearray(b)
        for x, y in zip(a, b):
            diff |= x ^ y
        return not diff
362375
def _match_state(self, state):
        """"""
        return (self.names == '*'
                or state in self.names
                or state.name in self.names)
836483
def check_next_match(self, match, new_relations, subject_graph, one_match):
        """"""
        # only returns true for ecaxtly one set of new_relations from all the
        # ones that are symmetrically equivalent
        if not (self.criteria_sets is None or one_match):
            for check in self.duplicate_checks:
                vertex_a = new_relations.get(check[0])
                vertex_b = new_relations.get(check[1])
                if vertex_a is None and vertex_b is None:
                    continue # if this pair is completely absent in the new
                    # relations, it is either completely in the match or it
                    # is to be matched. So it is either already checked for
                    # symmetry duplicates, or it will be check in future.
                if vertex_a is None:
                    # maybe vertex_a is in the match and vertex_b is the only
                    # one in the new relations. try to get vertex_a from the
                    # match.
                    vertex_a = match.forward.get(check[0])
                    if vertex_a is None:
                        # ok, vertex_a is to be found, don't care about it right
                        # now. it will be checked in future calls.
                        continue
                elif vertex_b is None:
                    # maybe vertex_b is in the match and vertex_a is the only
                    # one in the new relations. try to get vertex_b from the
                    # match.
                    vertex_b = match.forward.get(check[1])
                    if vertex_b is None:
                        # ok, vertex_b is to be found, don't care about it right
                        # now. it will be checked in future calls.
                        continue
                if vertex_a > vertex_b:
                    # Why does this work? The answer is not so easy to explain,
                    # and certainly not easy to find. if vertex_a > vertex_b, it
                    # means that there is a symmetry operation that leads to
                    # an equivalent match where vertex_b < vertex_a. The latter
                    # match is preferred for as much pairs (vertex_a, vertex_b)
                    # as possible without rejecting all possible matches. The
                    # real difficulty is to construct a proper list of
                    # (vertex_a, vertex_b) pairs that will reject all but one
                    # matches. I conjecture that this list contains all the
                    # first two vertices from each normalized symmetry cycle of
                    # the pattern graph. We need a math guy to do the proof. -- Toon
                    return False
            return True
        return True
639999
def match_paren(self, tokens, item):
        """"""
        match, = tokens
        return self.match(match, item)
68499
def duplicate(self):
        """"""
        other = Matcher(self.loc, self.check_var, self.checkdefs, self.names, self.var_index)
        other.insert_check(0, "not " + self.check_var)
        self.others.append(other)
        return other
714493
def _match(filtered, matcher):
    """"""

    def match_filtered_identities(x, ids, matcher):
        """Check if an identity matches a set of identities"""

        for y in ids:
            if x.uuid == y.uuid:
                return True
            if matcher.match_filtered_identities(x, y):
                return True
        return False

    # Find subsets of matches
    matched = []

    while filtered:
        candidates = []
        no_match = []

        x = filtered.pop(0)

        while matched:
            ids = matched.pop(0)

            if match_filtered_identities(x, ids, matcher):
                candidates += ids
            else:
                no_match.append(ids)

        candidates.append(x)

        # Generate the new list of matched subsets
        matched = [candidates] + no_match

    return matched
112756
def matches_pattern(self, other):
        """"""
        ismatch = False
        if isinstance(other, Userdata):
            for key in self._userdata:
                if self._userdata[key] is None or other[key] is None:
                    ismatch = True
                elif self._userdata[key] == other[key]:
                    ismatch = True
                else:
                    ismatch = False
                    break
        return ismatch
174486
def _match_net(self, net):
        """"""
        if self.network:
            return match_list(self.network, net)
        else:
            return True
476081
def __merge(self, matched, interactive):
        """"""

        for m in matched:
            identities = m['identities']
            uuid = identities[0]

            try:
                for c in identities[1:]:
                    if self.__merge_unique_identities(c, uuid, interactive):
                        self.matched += 1

                        # Retrieve unique identity to show updated info
                        if interactive:
                            uuid = api.unique_identities(self.db, uuid=uuid)[0]
            except Exception as e:
                if self.recovery:
                    self.recovery_file.save_matches(matched)
                raise e

            m['processed'] = True
1161590
def get_relationships(manager, handle_id1, handle_id2, rel_type=None, legacy=True):
    
    if rel_type:
        q = """
        MATCH (a:Node {{handle_id: {{handle_id1}}}})-[r:{rel_type}]-(b:Node {{handle_id: {{handle_id2}}}})
        RETURN collect(r) as relationships
        """.format(rel_type=rel_type)
    else:
        q = """
            MATCH (a:Node {handle_id: {handle_id1}})-[r]-(b:Node {handle_id: {handle_id2}})
            RETURN collect(r) as relationships
            """
    with manager.session as s:
        if legacy:
            relationships = s.run(q, {'handle_id1': handle_id1, 'handle_id2': handle_id2}).single()['relationships']
            return [relationship.id for relationship in relationships]
        return s.run(q, {'handle_id1': handle_id1, 'handle_id2': handle_id2}).single()['relationships']
29344
def match_blocks(hash_func, old_children, new_children):
    """"""
    sm = difflib.SequenceMatcher(
        _is_junk,
        a=[hash_func(c) for c in old_children],
        b=[hash_func(c) for c in new_children],
    )
    return sm
557272
def _match_member(self, i, column):
        """"""
        self.col_match = self.RE_MEMBERS.match(self._source[i])
        if self.col_match is not None:
            if column < self._source[i].index(":"):
                self.el_call = "name"
            else:
                self.el_call = "assign"
            
            return True
        else:
            return False
1252512
def __match_ancestry(self, ancestry):
        
        stack = self.__stack
        if len(stack) == 1:
            return stack[0], ancestry
        previous = stack[0]
        for frame, n in zip(stack[1:], xrange(len(ancestry))):
            if frame.id() is not ancestry[n]:
                return previous, ancestry[n:]
            previous = frame
        return frame, ancestry[n + 1:]