def check_deps(fun, locals, globals):
    """ Analyse the source code of fun to get the signals that the reactive
    function depends on. It then registers the function at these signals.
    """
    
    # Get source of function and find uses of inputs
    # todo: use AST parsing instead
    s = inspect.getsource(fun._fun)
    matches = re.findall(r'([a-zA-Z0-9_.]+?)\.get_signal\([\'\"](\w+?)[\'\"]\)', s)
    fun._nmatches = 0
    
    # print('found %i deps on %r' % (len(matches), fun))
    # For each used input, try to retrieve the actual object
    for match in matches:
        ob = locals.get(match[0], globals.get(match[0], None))
        if ob is None:
            print('could not locate dependency %r' % match[0])
        else:
            ob._bind_signal(match[1], fun)
            fun._nmatches += 1
            # print('bound signal for', ob)
            #dep = getattr(ob, 'input_'+match[1])
            #print('found dep ', dep)
    
    # Detect outputs
    #matches = re.findall(r'([a-zA-Z0-9_.]+?)\.set_output\([\'\"](\w+?)[\'\"]\,', s)
    
    # Detect calls
    if fun._nmatches:
        matches = re.findall(r'([a-zA-Z0-9_.]+?)\(', s)
        for match in matches:
            ob = locals.get(match[0], globals.get(match[0], None))
            if isinstance(ob, Signal):
                ob._dependers.append(fun)
    
    # # For each used input, try to retrieve the actual object
    # for match in matches:
    #     ob = locals.get(match[0], globals.get(match[0], None))
    #     if ob is None:
    #         print('could not locate dependency %r' % match[0])
    #     else:
    #         ob._bind_signal(match[1], fun2)
    fun._deps_checked = len(matches)
dataset/ETHPy150Open zoofIO/flexx/exp/reactive.py/check_deps/original