:returns: A list of block matches which appear to differ
760332
def differing_blocks(self):
        
        differing_blocks = []
        for (block_a, block_b) in self._block_matches:
            if not self.blocks_probably_identical(block_a, block_b):
                differing_blocks.append((block_a, block_b))
        return differing_blocks
27841
def get_asides(self, block):
        
        aside_instances = [
            self.get_aside_of_type(block, aside_type)
            for aside_type in self.applicable_aside_types(block)
        ]
        return [
            aside_instance for aside_instance in aside_instances
            if aside_instance.should_apply_to_block(block)
        ]
1360858
def _rule_compare(rule1, rule2):
    '''
    
    '''

    commonkeys = set(rule1.keys()).intersection(rule2.keys())
    for key in commonkeys:
        if rule1[key] != rule2[key]:
            return False
    return True
391800
def get_opcodes(matching_blocks):
    """"""
    sm = difflib.SequenceMatcher(a=[], b=[])
    sm.matching_blocks = matching_blocks
    return sm.get_opcodes()
57338
def find_block_end(row, line_list, sentinal, direction=1):
    
    import re
    row_ = row
    line_ = line_list[row_]
    flag1 = row_ == 0 or row_ == len(line_list) - 1
    flag2 = re.match(sentinal, line_)
    if not (flag1 or flag2):
        while True:
            if (row_ == 0 or row_ == len(line_list) - 1):
                break
            line_ = line_list[row_]
            if re.match(sentinal, line_):
                break
            row_ += direction
    return row_
1325882
def iter_block_items(self):
        
        block_item_tags = (qn('w:p'), qn('w:tbl'), qn('w:sdt'))
        for child in self:
            if child.tag in block_item_tags:
                yield child
52204
def get_matching_blocks(self):
        
        if self.matching_blocks is not None:
            return self.matching_blocks

        matching_blocks = _cdifflib.matching_blocks(self)
        matching_blocks.append((len(self.a), len(self.b), 0))
        self.matching_blocks = matching_blocks

        return map(_Match._make, self.matching_blocks)
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
1112164
def get_matching_blocks(self):
        """"""
        opcodes = self.get_opcodes()
        match_opcodes = filter(lambda x: x[0] == EQUAL, opcodes)
        return map(lambda opcode: [opcode[1], opcode[3], opcode[2] - opcode[1]],
                   match_opcodes)
671152
def get_nested_blocks_spec(self):
        
        return [
            block_spec if isinstance(block_spec, NestedXBlockSpec) else NestedXBlockSpec(block_spec)
            for block_spec in self.allowed_nested_blocks
        ]
1357960
def difference(a: Iterable[Any], b: Container[Any]) -> List[Any]:
    
    d = []
    for item in a:
        if item not in b:
            d.append(item)
    return d
950915
def find_matches(self, list_title):
        
        list_title_matches = []
        # Generate every possible tuple of titles and safe the matched string in a list.
        for a, b, in itertools.combinations(list_title, 2):
            if a == b:
                list_title_matches.append(a)

        return list_title_matches
765439
def identical_blocks(self):
        
        identical_blocks = []
        for (block_a, block_b) in self._block_matches:
            if self.blocks_probably_identical(block_a, block_b):
                identical_blocks.append((block_a, block_b))
        return identical_blocks
1131479
def difference (b, a):
    
    a = set(a)
    result = []
    for item in b:
        if item not in a:
            result.append(item)
    return result
829365
def blocks_with_differing_constants(self):
        
        diffs = dict()
        for (func_a, func_b) in self.function_matches:
            diffs.update(self.get_function_diff(func_a, func_b).blocks_with_differing_constants)
        return diffs
541106
def _rule_block(self):
        

        name = self._get_token(self.RE_NAME)
        self._expect_token('{')

        # consume additional options if available
        options = []
        while self._lookahead_token() != '}':
            options.append(self._rule_option())

        self._expect_token('}')
        return [name, options]
961279
def match_similar(base, items):
    
    finds = list(find_similar(base, items))
    if finds:
        return max(finds, key=base.similarity)  # TODO: make O(n)

    return None