Check if function has a "last_result" parameter.

    Needed to provide backward compatibility for wait functions that didn't
    take "last_result" in the beginning.
170393
def func_takes_last_result(waiter):
    
    if not six.callable(waiter):
        return False
    if not inspect.isfunction(waiter) and not inspect.ismethod(waiter):
        # waiter is a class, check dunder-call rather than dunder-init.
        waiter = waiter.__call__
    waiter_spec = _utils.getargspec(waiter)
    return 'last_result' in waiter_spec.args
643008
def get(self, timeout=None):
        
        if not self.wait(timeout):
            raise TimeoutError("Result not available within %fs" % timeout)
        if self._success:
            return self._data
        raise self._data[0]
1244419
function isSatisfiable (comparators, options) {
  var result = true
  var remainingComparators = comparators.slice()
  var testComparator = remainingComparators.pop()

  while (result && remainingComparators.length) {
    result = remainingComparators.every(function (otherComparator) {
      return testComparator.intersects(otherComparator, options)
    })

    testComparator = remainingComparators.pop()
  }

  return result
}
643330
function getLastResult() {
    if (argv._.length >= 2) {
        try {
            return JSON.parse(argv._[1]);
        } catch (err) {
            // pass
        }
    }

    return null;
}
202126
def has_arg(fn, arg_name):
    
    if sys.version_info < (3,):
        if isinstance(fn, types.FunctionType) or isinstance(fn, types.MethodType):
            arg_spec = inspect.getargspec(fn)
        else:
            try:
                arg_spec = inspect.getargspec(fn.__call__)
            except AttributeError:
                return False
        return (arg_name in arg_spec.args)
    elif sys.version_info < (3, 6):
        arg_spec = inspect.getfullargspec(fn)
        return (arg_name in arg_spec.args or
                arg_name in arg_spec.kwonlyargs)
    else:
        try:
            signature = inspect.signature(fn)
        except ValueError:
            # handling Cython
            signature = inspect.signature(fn.__call__)
        parameter = signature.parameters.get(arg_name)
        if parameter is None:
            return False
        return (parameter.kind in (inspect.Parameter.POSITIONAL_OR_KEYWORD,
                                   inspect.Parameter.KEYWORD_ONLY))
588661
function waitForever(fun) {
  var timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  var interval = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 20;

  return new Promise(function (res) {});
}
84629
def wait(self):
        
        text = input(
            "Press return for next %d result%s (or type 'all'):"
            % (self.pagesize, plural(self.pagesize))
        )
        if text:
            if text.lower() in ["a", "all"]:
                self._pagesize = 0
            elif text.isdigit():
                self._pagesize = int(text)
158794
function waitUntil(fun) {
    var timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
    var interval = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 20;

    var timedOut = false;
    var ok = false;

    if (timeout !== 0) (0, _wait2['default'])(timeout).then(function () {
        return timedOut = true;
    });

    return new Promise(function (resolve, reject) {
        var runLoop = function runLoop() {
            if (ok) {
                resolve();
                return;
            }
            if (timedOut) {
                reject(new Error('AsyncTestUtil.waitUntil(): reached timeout of ' + timeout + 'ms'));
                return;
            }
            (0, _wait2['default'])(interval).then(function () {
                var value = (0, _promisify2['default'])(fun());
                value.then(function (val) {
                    ok = val;
                    runLoop();
                });
            });
        };
        runLoop();
    });
}
426258
def _check_callback(callback, fargs, what="Callback functions"):
    ''''''
    sig = signature(callback)
    formatted_args = format_signature(sig)
    error_msg = what + " must have signature func(%s), got func%s"

    all_names, default_values = get_param_info(sig)

    nargs = len(all_names) - len(default_values)
    if nargs != len(fargs):
        raise ValueError(error_msg % (", ".join(fargs), formatted_args))
744871
def check_for_error(func):
    

    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        try:
            response = func(*args, **kwargs)
            status_code = response.status_code
            if status_code in range(200, 204):
                return response
            if status_code == 204:
                return
            data = response.json()
            e = {
                400: BadRequest,
                401: Unauthorized,
                403: Forbidden,
                404: NotFound,
                405: MethodNotAllowed,
                408: RequestTimeout,
                409: Conflict,
                429: TooManyRequests,
                500: ServerError,
                503: ServiceUnavailable,
            }.get(status_code, SbgError)()
            if 'message' in data:
                e.message = data['message']
            if 'code' in data:
                e.code = data['code']
            if 'status' in data:
                e.status = data['status']
            if 'more_info' in data:
                e.more_info = data['more_info']
            raise e
        except requests.RequestException as e:
            raise SbgError(message=six.text_type(e))
        except JSONDecodeError:
            message = (
                'Service might be unavailable. Can also occur by providing '
                'too many query parameters.'
            )
            raise_from(
                ServiceUnavailable(message=six.text_type(message)), None
            )
        except ValueError as e:
            raise SbgError(message=six.text_type(e))

    return wrapper
1208650
def get_last_upload_results(self):
        
        if os.path.isfile(constants.last_upload_results_file):
            logger.debug('Last upload file %s found, reading results.', constants.last_upload_results_file)
            with open(constants.last_upload_results_file, 'r') as handler:
                return handler.read()
        else:
            logger.debug('Last upload file %s not found, cannot read results', constants.last_upload_results_file)
            return False
986683
function last(args) {
  return args.length > 0?  Maybe.Just(args[args.length - 1])
  :      /* otherwise */   Maybe.Nothing();
}
436207
def has(self, decorated_function, *args, **kwargs):
		
		return self.get_cache(decorated_function, *args, **kwargs).has_value
404147
function(callback) {
            callback = callback || function() {};
            
            var that = this;
            var params = {
                count: this._pagesize,
                offset: this._offset
            };
            return this._endpoint(params, function(err, results) {
                if (err) {
                    callback(err);
                }
                else {                    
                    var numResults = (results.rows ? results.rows.length : 0);
                    that._offset += numResults;
                    
                    callback(null, results, numResults > 0);
                }
            });
        }
1058084
function() {
        var _status = STATUS_PENDING;
        var _args;
        var _callbacks = {
            success: [],
            fail: [],
            done: []
        };

        function _registerCallback(resultType, callback) {
            if (typeof callback !== 'function') {
                //Invalid input args. Throw an error.
                throw 'Invalid argument: callback. Must be a function.';
            }

            if (_status !== STATUS_PENDING) {
                if (_status === resultType || resultType === RESULT_TYPE_DONE) {
                    // Promise has already been satisfied. Just invoke the
                    // callback.
                    callback.apply(null, _args);
                }
            } else {
                // Promise has not yet been satisfied. Remember it, and
                // invoke when ready.
                _callbacks[resultType].push(callback);
            }
        }

        function _satisfy(resultType, args) {
            if (_status !== STATUS_PENDING) {
                return;
            }
            _args = args;
            _status = resultType;

            function doCallback(item, index) {
                item.apply(null, _args);
            }

            //Trigger any callbacks that have been queued.
            _callbacks[resultType].forEach(doCallback);
            _callbacks.done.forEach(doCallback);

            //Clear out any callback references.
            _callbacks.succes = [];
            _callbacks.fail = [];
            _callbacks.done = [];
        }

        var _promise = {
            /*
             * Invoked to allow callers to register callbacks that will be
             * triggered on completion of the deferred activity. This callback
             * will be triggered whether or not the completion was successful.
             */
            done: function(callback) {
                _registerCallback(RESULT_TYPE_DONE, callback);
                return (_promise);
            },

            /*
             * Invoked to allow callers to register callbacks that will be
             * triggered on successful completion of the deferred activity.
             */
            success: function(callback) {
                _registerCallback(STATUS_SUCCESS, callback);
                return (_promise);
            },

            /*
             * Invoked to allow callers to register callbacks that will be
             * triggered on unsuccessful completion of the deferred activity.
             */
            fail: function(callback) {
                _registerCallback(STATUS_FAIL, callback);
                return (_promise);
            },

            /* 
             * Returns the results returned by the deferred activity.
             */
            results: function() {
                return _args;
            }
        }

        var deferredObject = {
            /*
             * Allows a callback to be registered that will be called once the
             * deferred has been resolved or rejected.
             */
            done: _promise.done,

            /*
             * Allows a callback to be registered that will be called once the
             * deferred has been resolved.
             */
            success: _promise.success,

            /*
             * Allows a callback to be registered that will be called once the
             * deferred has been rejected.
             */
            fail: _promise.fail,

            /*
             * Fulfills the promise by resolving it.
             */
            resolve: function() {
                _satisfy(STATUS_SUCCESS, Array.prototype.slice.call(arguments, 0));
            },

            /*
             * Fulfills the promise by rejecting it.
             */
            reject: function() {
                _satisfy(STATUS_FAIL, Array.prototype.slice.call(arguments, 0));
            },

            /*
             * Gets a promise associated with the deferred object.
             */
            promise: function() {
                return Object.create(_promise);
            },

            /*
             * Generates a callback that resolves/rejects the deferred object
             * based on the success/failure of an operation, determined by the
             * first argument in.
             */
            getResolver: function() {
                var ctxArgs = Array.prototype.slice.call(arguments, 0);
                return function(err, data) {
                    if (!err) {
                        var args = Array.prototype.slice.call(arguments, 1);
                        deferredObject.resolve.apply(null,
                            ctxArgs.concat(args));
                    } else {
                        deferredObject.reject.apply(null,
                            ctxArgs.concat([err]));
                    }
                };
            },

            /*
             * Generates a callback that resolves/rejects the deferred after a
             * specified number of steps have been completed, indicated by the
             * invocation of stepComplete().
             */
            getMultiStepResolver: function(count) {
                var _count = count;
                var ctxArgs = Array.prototype.slice.call(arguments, 1);

                // If the step count is zero, resolve immediately.
                if (_count === 0) {
                    deferredObject.resolve.apply(null, ctxArgs);
                }

                return {
                    /*
                     * Indicates that a specific step was completed. The
                     * promise will be treated as resolved if this method
                     * is invoked a given number of times.
                     */
                    stepComplete: function() {
                        var ca
                        _count--;
                        if (_count === 0) {
                            var args = Array.prototype.slice.call(arguments, 0);
                            deferredObject.resolve.apply(null,
                                ctxArgs.concat(args));
                        }
                    },

                    /*
                     * Rejects the deferred object without waiting for any
                     * further processing.
                     */
                    reject: function() {
                        var args = Array.prototype.slice.call(arguments, 0);
                        deferredObject.reject.apply(null, ctxArgs.concat(args));
                    }
                }
            }
        };

        return deferredObject;
    }
974160
def wait_for_result(timeout)
        # do the deadline maths
        time_to_stop = timeout ? (Time.now + timeout) : nil # slight time slippage between here
                                                            #
        until @result                                       #
          if timeout                                        # and here
            now = Time.now

            if @result
              return
            elsif (now >= time_to_stop)
              @result = TIMED_OUT
              return
            end

            @cond.wait(time_to_stop.to_f - now.to_f)
          else
            @cond.wait_until { @result }
          end
        end
      end
935206
function() {
            if (self._disposed) {
                clearTimeout(timeout)
                timeout = self = null
                return
            }

            var last = getTime() - timestamp

            if (last < wait && last >= 0) {
                timeout = setTimeout(later, wait - last)
            } else {
                timeout = null
                // result = func.apply(context, args)
                func()
                // context = args = null
            }
        }