:returns: A list of block matches which appear to be identical
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
408776
def identical(self, a, b):
        
        return self._identical(self.convert(a), self.convert(b))
995869
def matches(self, event):
        '''
        
        '''
        ret = []
        self._matches(event, set(), ret)
        return tuple(r[0] for r in ret)
381870
def blocks_with_differing_constants(self):
        
        differing_blocks = []
        diffs = dict()
        for (block_a, block_b) in self._block_matches:
            if self.blocks_probably_identical(block_a, block_b) and \
                    not self.blocks_probably_identical(block_a, block_b, check_constants=True):
                differing_blocks.append((block_a, block_b))
        for block_a, block_b in differing_blocks:
            ba = NormalizedBlock(block_a, self._function_a)
            bb = NormalizedBlock(block_b, self._function_b)
            diffs[(block_a, block_b)] = FunctionDiff._block_diff_constants(ba, bb)
        return diffs
321166
def textBlocks(self):
        '''
            
        '''
        myBlocks = self.blocks

        return [block for block in myBlocks if not issubclass(block.__class__, AdvancedTag)]
1351872
def do_symbols_matching(self):
        
        self._clear_decorations()
        current_block = self.editor.textCursor().block()
        data = get_block_symbol_data(self.editor, current_block)
        pos = self.editor.textCursor().block().position()
        for symbol in [PAREN, SQUARE, BRACE]:
            self._match(symbol, data, pos)
1057406
def each(&block)
      return @results.each(&block) if @results
      @results = []
      cur_v_i = Array.new(@data.keys.length, 0)
      keys = @data.keys.sort_by(&:to_s)
      result = {}
      keys.each do |key|
        result[key] = @data[key][0]
      end
      while true
        r = result.dup
        @results << r
        block.call(r) if block
        keys.each_with_index do |k, k_i|
          v_i = ((cur_v_i[k_i] = (1 + cur_v_i[k_i]) % @data[k].length))
          result[k] = @data[k][v_i]
          if v_i > 0 # Found next ?
            break
          elsif k_i == keys.length - 1 # Last?
            return
          end
        end
      end
      @results
    end
1028973
def differing_functions(self):
        
        different_funcs = []
        for (func_a, func_b) in self.function_matches:
            if not self.functions_probably_identical(func_a, func_b):
                different_funcs.append((func_a, func_b))
        return different_funcs
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
391800
def get_opcodes(matching_blocks):
    """"""
    sm = difflib.SequenceMatcher(a=[], b=[])
    sm.matching_blocks = matching_blocks
    return sm.get_opcodes()
616281
def _match_batches(tumor, normal):
    
    def _get_batch(x):
        b = dd.get_batch(x)
        return [b] if not isinstance(b, (list, tuple)) else b
    if normal:
        tumor = copy.deepcopy(tumor)
        normal = copy.deepcopy(normal)
        cur_batch = list(set(_get_batch(tumor)) & set(_get_batch(normal)))
        assert len(cur_batch) == 1, "No batch overlap: %s and %s" % (_get_batch(tumor), _get_batch(normal))
        cur_batch = cur_batch[0]
        tumor["metadata"]["batch"] = cur_batch
        normal["metadata"]["batch"] = cur_batch
    return tumor, normal
538832
def _subsequent_step_to_match(match_step):
    """"""
    if not isinstance(match_step.root_block, (Traverse, Recurse)):
        raise AssertionError(u'Expected Traverse root block, received: '
                             u'{} {}'.format(match_step.root_block, match_step))

    is_recursing = isinstance(match_step.root_block, Recurse)

    match_step.root_block.validate()

    traversal_command = u'.%s(\'%s\')' % (match_step.root_block.direction,
                                          match_step.root_block.edge_name)

    parts = []
    if match_step.coerce_type_block:
        coerce_type_set = match_step.coerce_type_block.target_class
        if len(coerce_type_set) != 1:
            raise AssertionError(u'Found MATCH type coercion block with more than one target class:'
                                 u' {} {}'.format(coerce_type_set, match_step))
        coerce_type_target = list(coerce_type_set)[0]
        parts.append(u'class: %s' % (coerce_type_target,))

    if is_recursing:
        # In MATCH, "$depth < 1" means "include the source vertex and its immediate neighbors."
        # Yes, the "<" is intentional -- it's not supposed to be a "<=".
        parts.append(u'while: ($depth < %d)' % (match_step.root_block.depth,))

    if match_step.where_block:
        match_step.where_block.validate()
        parts.append(u'where: (%s)' % (match_step.where_block.predicate.to_match(),))

    if not is_recursing and match_step.root_block.optional:
        parts.append(u'optional: true')

    if match_step.as_block:
        match_step.as_block.validate()
        parts.append(u'as: %s' % (_get_vertex_location_name(match_step.as_block.location),))

    return u'%s {{ %s }}' % (traversal_command, u', '.join(parts))
458403
def blocks_by_text(cls, text):
        
        text = kurt.BlockType._strip_text(text)
        matches = []
        for block in cls.blocks:
            for pbt in block.conversions:
                if pbt.stripped_text == text:
                    matches.append(block)
                    break
        return matches
1374293
def Match(self, artifact=None, os_name=None, cpe=None, label=None):
    
    return [
        c for c in self.conditions if c.Match(artifact, os_name, cpe, label)
    ]
1369428
def _blockedPairs(self, blocks):
        

        block, blocks = core.peek(blocks)
        self._checkBlock(block)

        combinations = itertools.combinations

        pairs = (combinations(sorted(block), 2) for block in blocks)

        return pairs
484334
private boolean blocksEquals(Block[] a1, Block[] a2, boolean closedFile) {
    if (a1 == a2)
      return true;
    if (a1 == null || a2 == null || a2.length != a1.length)
      return false;

    for (int i = 0; i < a1.length; i++) {
      Block b1 = a1[i];
      Block b2 = a2[i];

      if (b1 == b2)
        continue;
      if (b1 == null || b2 == null)
        return false;

      // compare ids and gen stamps
      if (!(b1.getBlockId() == b2.getBlockId() && b1.getGenerationStamp() == b2
          .getGenerationStamp()))
        return false;

      // for open files check len-2 blocks only
      if (!closedFile && i >= a1.length - 2)
        continue;

      // check block size
      if (b1.getNumBytes() != b2.getNumBytes())
        return false;
    }
    return true;
  }
858827
def identical_functions(self):
        
        identical_funcs = []
        for (func_a, func_b) in self.function_matches:
            if self.functions_probably_identical(func_a, func_b):
                identical_funcs.append((func_a, func_b))
        return identical_funcs