Call given function in all submodules with given parameters
969376
def module_broadcast(m, broadcast_fn, *args, **kwargs):
    
    apply_leaf(m, lambda x: module_apply_broadcast(x, broadcast_fn, args, kwargs))
885088
def call(self, module, *args, **kwargs):
        '''
        
        '''

        module = self._resolver.load_module(module)
        if not hasattr(module, 'main'):
            raise CommandExecutionError('This module is not callable '
                                        '(see "ansible.help {0}")'.format(module.__name__.replace('ansible.modules.',
                                                                                                  '')))
        if args:
            kwargs['_raw_params'] = ' '.join(args)
        js_args = str('{{"ANSIBLE_MODULE_ARGS": {args}}}')  # future lint: disable=blacklisted-function
        js_args = js_args.format(args=salt.utils.json.dumps(kwargs))

        proc_out = salt.utils.timed_subprocess.TimedProc(
            ["echo", "{0}".format(js_args)],
            stdout=subprocess.PIPE, timeout=self.timeout)
        proc_out.run()
        proc_exc = salt.utils.timed_subprocess.TimedProc(
            ['python', module.__file__],
            stdin=proc_out.stdout, stdout=subprocess.PIPE, timeout=self.timeout)
        proc_exc.run()

        try:
            out = salt.utils.json.loads(proc_exc.stdout)
        except ValueError as ex:
            out = {'Error': (proc_exc.stderr and (proc_exc.stderr + '.') or six.text_type(ex))}
            if proc_exc.stdout:
                out['Given JSON output'] = proc_exc.stdout
            return out

        if 'invocation' in out:
            del out['invocation']

        out['timeout'] = self.timeout

        return out
537759
def include(_name_or_func, *args,
            _module=None, _default='includeme', **kwargs):
    
    if callable(_name_or_func):
        resolved = _name_or_func
    else:
        resolved = resolve_str(_name_or_func, _module, _default)

    resolved(*args, **kwargs)
423129
function(parentModule, id, callback) {

  // Try to load the module.
  return Promise.try(function() {
    return parentModule.require(id);
  })
  // Ignore module not found errors, and decorate all others.
  .catch(function(err) {
    if (err.code !== 'MODULE_NOT_FOUND') {
      throw new KboxRequireError(id, err);
    }
  })
  // Return.
  .nodeify(callback);

}
38853
function loadAll( state, resourcePath ) {
	var loadActions = [ loadResources( state, resourcePath ) ] || [];
	if ( state.config.modules ) {
		_.each( state.config.modules, function( mod ) {
			var modPath;
			if ( /[\/]/.test( mod ) ) {
				modPath = require.resolve( path.resolve( process.cwd(), mod ) );
			} else {
				modPath = require.resolve( mod );
			}
			loadActions.push( loadModule( state, modPath ) );
		} );
	}
	loadActions.push( loadModule( state, './ahResource' ) );
	return when.all( loadActions );
}
668105
def _import(func):
        """"""
        func_name = func.__name__

        # from foo.bar import func // func()
        # WARNING: May be broken in IPython, in which case the widget will use a fallback
        if func_name in globals():
            return func_name

        # import foo.bar // foo.bar.func()
        module_name = func.__module__
        submodules = module_name.split('.')

        if submodules[0] in globals():
            return module_name + '.' + func_name

        # from foo import bar // bar.func()
        for i in range(len(submodules)):
            m = submodules[i]
            if m in globals():
                return '.'.join(submodules[i:]) + '.' + func_name

        # import foo.bar as fb // fb.func()
        module_ref = sys.modules[func.__module__]
        all_globals = globals()

        for n in all_globals:
            if all_globals[n] == module_ref:
                return n + '.' + func_name

        # Not Found, return function name
        return func_name
20669
def is_mod_function(mod, fun):
    
    return inspect.isfunction(fun) and inspect.getmodule(fun) == mod
57158
function callNativeModule (instanceId, module, method, args, options) {
  return processCall(instanceId, { module, method, args })
}
1293487
def runAllInDir(dir_path, exclude=[], add_args=(), ignoreErrors=True):
    
    print('testing all modules of %s' % dir_path)

    if type(add_args) in (tuple, list):
        sys.argv.extend(add_args)
    else:
        sys.argv.append(add_args)
    t = 0
    failed = []
    for _, modname, ispkg in pkgutil.walk_packages(
            [dir_path],
            #onerror=lambda x: None
    ):
        if not ispkg and modname != thismodname and modname not in exclude:  # don't test this module
            print('... %s' % modname)
            t0 = time()
            try:
                runpy.run_module(
                    modname,
                    init_globals=None,
                    run_name='__main__',
                    alter_sys=False)
            except Exception as err:
                if ignoreErrors:
                    print("FAILED: %s" % err)
                else:
                    raise err
                failed.append((modname, err))
            dt = time() - t0
            t += dt
            print('execution time=%s' % dt)
    print('----------------')
    print('time needed=%s' % t)
    if failed:
        print('=======================')
        print('failed for %s modules' % len(failed))
        print('-----------------------')
        for mod, err in failed:
            print(mod, err)
271173
function recursiveCall(i, callback) {
            if(i >= _modules.length) {
                callback();
            } else {
                _modules[i].check(req, res, function () {
                    recursiveCall(++i, callback);
                })
            }
        }
92081
function invoke(moduleName, method, extraArgs, callback) {
    var module = self.modules[moduleName];
    var invoke = module[method];
    if (invoke) {
      if (invoke.length === (1 + extraArgs.length)) {
        return invoke.apply(module, extraArgs.concat([callback]));
      } else if (invoke.length === extraArgs.length) {
        return setImmediate(function () {
          try {
            invoke.apply(module, extraArgs);
          } catch (e) {
            return callback(e);
          }
          return callback(null);
        });
      } else {
        return callback(moduleName + ' module: your ' + method + ' method must take ' + extraArgs.length + ' arguments, plus an optional callback.');
      }
    } else {
      return setImmediate(callback);
    }
  }
1211228
def call(self):
        """"""
        assert self.satisfied, self
        LOG.debug('call %s.%s', self.func.__module__, self.func.__qualname__)
        kwargs = {arg.name: arg.read() for arg in self.args}
        out_value = self.func(**kwargs)
        if self.writeto is None:
            writeto = set()
        elif isinstance(self.writeto, Variable):
            self.writeto.write(out_value)
            writeto = {self.writeto}
        else:
            # A variable can be written multiple times, but we only
            # return a unique set of variables.
            for var, value in zip(self.writeto, out_value):
                var.write(value)
            writeto = set(self.writeto)
        self._release()  # Only call _release() on normal exit.
        return writeto
167005
def invoke_function(self, ctx, name, arguments):
        
        from temba_expressions import EvaluationError, conversions

        # find function with given name
        func = self.get_function(name)
        if func is None:
            raise EvaluationError("Undefined function: %s" % name)

        args, varargs, defaults = self._get_arg_spec(func)

        call_args = []
        passed_args = list(arguments)

        for arg in args:
            if arg == 'ctx':
                call_args.append(ctx)
            elif passed_args:
                call_args.append(passed_args.pop(0))
            elif arg in defaults:
                call_args.append(defaults[arg])
            else:
                raise EvaluationError("Too few arguments provided for function %s" % name)

        if varargs is not None:
            call_args.extend(passed_args)
            passed_args = []

        # any unused arguments?
        if passed_args:
            raise EvaluationError("Too many arguments provided for function %s" % name)

        try:
            return func(*call_args)
        except Exception as e:
            pretty_args = []
            for arg in arguments:
                if isinstance(arg, str):
                    pretty = '"%s"' % arg
                else:
                    try:
                        pretty = conversions.to_string(arg, ctx)
                    except EvaluationError:
                        pretty = str(arg)
                pretty_args.append(pretty)

            raise EvaluationError("Error calling function %s with arguments %s" % (name, ', '.join(pretty_args)), e)
124189
def execute_import_function(name, *args)
    func = @function_imports[name]

    # Check the args making sure that more weren't passed in than the function needs
    param_count = func[:parameters].nil? ? 0 : func[:parameters].count
    arg_count = args.nil? ? 0 : args[0].count
    if arg_count > param_count
      raise ArgumentError, "wrong number of arguments (#{arg_count} for #{param_count})"
    end

    # Convert the parameters to a hash
    params = {}
    func[:parameters].keys.each_with_index { |key, i| params[key] = args[0][i] } unless func[:parameters].nil?

    function_uri = build_function_import_uri(name, params)
    result = OData::Resource.new(function_uri, @rest_options).send(func[:http_method].downcase, {})

    # Is this a 204 (No content) result?
    return true if result.status == 204

    # No? Then we need to parse the results. There are 4 kinds...
    if func[:return_type] == Array
      # a collection of entites
      return build_classes_from_result(result.body) if @classes.include?(func[:inner_return_type].to_s)
      # a collection of native types
      elements = Nokogiri::XML(result.body).xpath("//ds:element", @ds_namespaces)
      results = []
      elements.each do |e|
        results << parse_primative_type(e.content, func[:inner_return_type])
      end
      return results
    end

    # a single entity
    if @classes.include?(func[:return_type].to_s)
      entry = Nokogiri::XML(result.body).xpath("atom:entry[not(ancestor::atom:entry)]", @ds_namespaces)
      return entry_to_class(entry)
    end

    # or a single native type
    unless func[:return_type].nil?
      e = Nokogiri::XML(result.body).xpath("/*").first
      return parse_primative_type(e.content, func[:return_type])
    end

    # Nothing could be parsed, so just return if we got a 200 or not
    return (result.status == 200)
  end
725024
def function_call(self, function, arguments):
        
        #push each argument to stack
        for arg in arguments:
            self.push(self.symbol(arg))
            self.free_if_register(arg)
        self.newline_text("CALL\t"+self.symtab.get_name(function), True)
        args = self.symtab.get_attribute(function)
        #generates stack cleanup if function has arguments
        if args > 0:
            args_space = self.symtab.insert_constant("{0}".format(args * 4), SharedData.TYPES.UNSIGNED)
            self.arithmetic("+", "%15", args_space, "%15")
927978
def do_base(self, args):
        """"""
        func = getattr(args, 'func', None)
        if func is not None:
            # Call whatever sub-command function was selected
            func(self, args)
        else:
            # No sub-command was provided, so call help
            self.do_help('base')
35148
def setup(self):
        """"""
        # get all routes from submodules
        for prefix, routes in self.sub_rt:
            routes.prefix = self.prefix + prefix
            routes.setup()

            fn_name_prefixes = {}
            for fn_key, fn in routes.fn_namespace.items():
                self.fn_namespace[routes.name + '.' + fn_key] = fn
                fn_prefix = routes.name
                if '.' in fn_key:
                    fn_prefix += '.' + fn_key.rsplit('.', 1)[0]
                fn_name_prefixes[fn] = fn_prefix

            for key in self:
                funcs = set(rule[1] for rule in self[key])
                for route, route_module, module, fn in routes.get(key, []):
                    if fn not in funcs:
                        new_route = Route(prefix + route.path)
                        fn.rw_route = new_route
                        fn_name_prefix = fn_name_prefixes[fn]
                        data = (new_route, fn_name_prefix, module, fn)
                        self[key].append(data)

        # sort all rules
        for key in self:
            self[key].sort(key=lambda rule: rule[0])