

def placement(out_iter, kwargs, final, capability_nodes):
    _log.debug(('shadow_match:placement BEGIN %s' % (capability_nodes,)))
    if final[0]:
        try:
            possible_nodes = set.union(*[final['node_match'] for d in kwargs['descriptions'] if ('node_match' in d)])
        except:
            possible_nodes = set([])
            if (not kwargs['capabilities']):
                out_iter.append(dynops.InfiniteElement())
                out_iter.final()
                return
        if (not possible_nodes):
            out_iter.final()
            return
        if any([isinstance(n, dynops.InfiniteElement) for n in possible_nodes]):
            out_iter.append(dynops.InfiniteElement())
            out_iter.final()
            return
        out_iter.extend(possible_nodes)
        out_iter.final()
        return
    else:
        capability = ''.join(capability_nodes[0].partition('calvinsys.')[1:])
        kwargs['capabilities'].setdefault(capability, []).append(capability_nodes[1])
    _log.debug(('shadow_match:placement EVALUATE %s' % kwargs))
    for d in kwargs['descriptions']:
        if (('node_match' not in d) and (not d['requires'])):
            _log.debug('shadow_match:placement No requires create Infinity')
            d['node_match'] = set([dynops.InfiniteElement()])
        elif (set(d['requires']) <= set(kwargs['capabilities'].keys())):
            _log.debug(('shadow_match:placement require:%s, caps:%s' % (d['requires'], kwargs['capabilities'])))
            found = set.intersection(*[set(kwargs['capabilities'][r]) for r in d['requires']])
            new = (found - d.setdefault('node_match', set([])))
            d['node_match'].update(new)

dataset/ETHPy150Open EricssonResearch/calvin-base/calvin/runtime/north/plugins/requirements/shadow_actor_reqs_match.py placement/VarMisuse@50/73 `d`->`final`