Inject functions to retrieve arguments.

@param {Object} funcs reference
@param {Object} task
@param {Object} args
509098
function injectArguments (funcs, task, args) {
  function getArgument (index) {
    return args[index]
  }

  /**
   * Inject arguments.
   */

  function inject (taskKey) {
    var funcName = task[taskKey]

    if (funcName === 'arguments') {
      funcs[funcName] = function getArguments () { return args }
    } else {
      var arg = regexArgument.exec(funcName)

      if (arg) {
        funcs[funcName] = getArgument.bind(null, arg[1])
      }
    }
  }

  Object.keys(task)
    .forEach(inject)
}
1359987
function (caller_args, caller_result) {
            if (!this.enabled())
                return undefined;
            var args = [];
            if (this.async()) {
                args.push(function (value) {
                    if (typeof caller_result === "function")
                        caller_result(value);
                });
            }
            args = _cs.concat(args, this.args(), caller_args);
            return this.func().apply(this.ctx(), args);
        }
273247
def _invoke(task, args):
	''''''
	kwargs = task.defaults.copy()
	if task.kwargs:
		temp_kwargs, args = getopt.getopt(args, '', task.kwargs)
		temp_kwargs = _opts_to_dict(*temp_kwargs)
		kwargs.update(temp_kwargs)

	if task.args:
		for arg in task.args:
			if not len(args):
				abort(LOCALE['error_wrong_args'], task, len(task.args))
			kwargs.update({arg: args[0]})
			args = args[1:]

	if task.consume:
		task(*args, **kwargs)
		return []
	else:
		task(**kwargs)
		return args
750877
function(task, option) {

  // Code reuse!
  var toMsg = function(propertyName) {
    return 'Invalid task ' + propertyName + ':' +
      ' task.path=' + task.path + ' ' + pp(option);
  };

  // Validate name.
  if (typeof option.name !== 'string') {
    throw new TypeError(toMsg('name'));
  }

  // Validate alias.
  if (typeof option.alias !== 'string' && option.alias !== null) {
    throw new TypeError(toMsg('alias'));
  }

  // Validate kind.
  if (typeof option.kind !== 'string') {
    throw new TypeError(toMsg('kind'));
  }

  // Validate description.
  if (typeof option.description !== 'string') {
    throw new TypeError(toMsg('description'));
  }

  // Validate object keys.
  _.each(Object.keys(option), function(key) {
    if (!_.contains(validOptionKeys, key)) {
      throw new TypeError('Invalid task option property: ' +
        'key=' + key + ' ' + pp(task));
    }
  });

}
1315854
def _taskify(func):
	''''''
	if not isinstance(func, _Task):
		func = _Task(func)

		spec = inspect.getargspec(func.func)
		if spec.args:
			num_args = len(spec.args)
			num_kwargs = len(spec.defaults or [])
			isflag = lambda x, y: '' if x.defaults[y] is False else '='

			func.args = spec.args[:(num_args - num_kwargs)]
			func.defaults = {spec.args[i - num_kwargs]: spec.defaults[i] for i in range(num_kwargs)}
			func.kwargs = [key.replace('_','-') + isflag(func, key) for key in func.defaults]

		if not func.name.startswith('_'):
			TASKS.append(func)

	return func
277114
function(task) {

  // Validate object keys.
  _.each(Object.keys(task), function(key) {
    if (!_.contains(validKeys, key)) {
      throw new TypeError('Invalid task property: ' +
        key + ' ' + pp(task));
    }
  });

  // Validate __isTask.
  if (!isTask(task)) {
    throw new TypeError('Invalid task: ' + pp(task));
  }

  // Validate path.
  if (!Array.isArray(task.path)) {
    throw new TypeError('Invalid task path: ' + pp(task));
  }
  if (task.path.length === 0) {
    throw new TypeError('Empty task path: ' + pp(task));
  }
  task.path.forEach(function(atom) {
    if (typeof atom !== 'string') {
      throw new TypeError('Invalid task path: ' + pp(task));
    }
  });

  // Validate category.
  var cat = task.category;
  if (typeof cat !== 'string' || !_.includes(validCategories, cat)) {
    throw new TypeError('Invalid task category: ' + pp(task));
  }

  // Validate description.
  if (typeof task.description !== 'string' || task.description.length === 0) {
    throw new TypeError('Invalid task description: ' + pp(task));
  }

  // Validate kind.
  if (typeof task.kind !== 'string') {
    throw new TypeError('Invalid task kind: ' + pp(task));
  }
  parseKind(task.kind);

  // Validate options.
  if (!Array.isArray(task.options)) {
    throw new TypeError('Invalid task options: ' + pp(task));
  }
  _.each(task.options, function(option) {
    invariantOption(task, option);
  });

  // Validate function.
  if (typeof task.func !== 'function') {
    throw new TypeError('Invalid task function: ' + pp(task));
  }
  if (task.func.length > 1) {
    throw new TypeError('Wrong number of arguments in task function: ' +
      task.func.toString());
  }

}
121675
def new_task(func):
    

    @wraps(func)
    async def wrapper(self, *args, **kwargs):
        loop = get_event_loop()
        loop.create_task(func(self, *args, **kwargs))
    return wrapper
1137309
def create_task(function, *args, **kwargs):
    
    name = "{}".format(uuid4())
    handler = None
    deps = set()

    if 'name' in kwargs:
        name = kwargs['name']
        del kwargs['name']
    elif function is not None:
        name = "{}-{}".format(function.__name__, name)

    if 'handler' in kwargs:
        handler = kwargs['handler']
        del kwargs['handler']

    if 'dependencies' in kwargs:
        for dep in kwargs['dependencies']:
            deps.add(dep)
        del kwargs['dependencies']

    for arg in args:
        if isinstance(arg, Task):
            deps.add(arg.name)

    for key in kwargs:
        if isinstance(kwargs[key], Task):
            deps.add(kwargs[key].name)

    return Task(name, function, handler, frozenset(deps), args, kwargs)
997193
function(funcID, args)
    {
        var result;
        var func = this.localFunctionCache[funcID];

        if(func != undefined)
        {
            result = this.serialize(func.apply(null, this.deserialize(args)));
        }

        return result;
    }
1029676
def action(source, func):
    
    if asyncio.iscoroutinefunction(func):
        async def innerfunc(arg):
            await func(arg)
            return arg
    else:
        def innerfunc(arg):
            func(arg)
            return arg
    return map.raw(source, innerfunc)
440092
def callback(func):
    
    @functools.wraps(func)
    def wrapped(*args, **kwargs):
        result = func(*args, **kwargs)
        if inspect.iscoroutine(result):
            aio_loop.create_task(result)

    return wrapped
492760
function Task(task) {
  _.extend(this, task);
  if (task != undefined) this.createId();

  // Short id
  this.__defineGetter__('id', function () {
    return this.__uuid__.substr(0, 8).toString();
  });

  // Keyword
  this.__defineGetter__('keyword', function () {
    return this.labels[0].replace('#', '').toUpperCase();
  });

  // Stemmed
  this.__defineGetter__('stemmed', function () {
    return (this.title+' '+this.body).toLowerCase()
      .split(' ').map(stem).join(' ');
  });

  // All
  this.__defineGetter__('all', function () {
    return '*';
  });
}
1132282
def execute_function(self, func, *nargs, **kwargs):
        
        # makes a copy of the func
        import types
        fn = types.FunctionType(func.func_code,
                                func.func_globals.copy(),
                                name=func.func_name,
                                argdefs=func.func_defaults,
                                closure=func.func_closure)
        fn.func_globals.update(self.globals)

        error_class = Exception if config.catch_rex_errors else None

        try:
            return fn(*nargs, **kwargs)
        except RexError:
            raise
        except error_class as e:
            from inspect import getfile

            stack = traceback.format_exc()
            filename = getfile(func)

            raise RexError("Failed to exec %s:\n\n%s" % (filename, stack))
23509
function(kind) {
  if (typeof kind !== 'string')  {
    throw new TypeError('Invalid task kind: ' + kind);
  }

  if (kind === 'delegate') {
    // Delegate.
    return {
      kind: kind,
      argvCount: Infinity
    };
  } else if (kind === 'argv*') {
    // Infinite argv allowed.
    return {
      kind: 'argv',
      argvCount: Infinity
    };
  } else if (_.startsWith(kind, 'argv')) {
    // Specific number of argv allowed.
    var parsedInt;
    try {
      parsedInt = _.parseInt(kind.slice('argv'.length));
    }
    catch (err) {
      throw new Error('Invalid task kind: ' + kind);
    }
    return {
      kind: 'argv' ,
      argvCount: parsedInt
    };
  } else {
    // Unexpected task kind, so throw an error.
    throw new TypeError('Invalid task kind: ' + kind);
  }

}
794734
def taskit(func):
    
    class NewTask(Task):
        def work(self, *args, **kw):
            return func(*args, **kw)
    return NewTask()
544754
function Task(func) {
        _super.call(this);
        if (!TypeUtils.isNullOrUndefined(func)) {
            if (typeof func !== "function") {
                throw "'func' must be a function!";
            }
        }
        this._FUNC = func;
        this.updateStatus(TaskStatus.Created);
    }
1219234
async function execTasks(tasks, taskType) {
  debug(`execTasks: called for ${taskType}`);
  if (!(_.isEmpty(tasks))) {
    if (taskType) console.log(`running ${taskType}...`);
    const output = await Promise.mapSeries(tasks, async(task) => {
      const result = await execTask(task);
      if (_.isString(result.stdout) && (!_.isEmpty(result.stdout)))
        console.log(result.stdout.trim());
      if (_.isString(result.stderr) && (!_.isEmpty(result.stderr)))
        console.log(result.stderr.trim());
      return result;
    });
    return output;
  }
  debug("execTasks: nothing to do; resolving");
  return;
}