A function to wrap shutil.which for universal usage
19134
def where(cmd, path=None):
    
    raw_result = shutil.which(cmd, os.X_OK, path)
    if raw_result:
        return os.path.abspath(raw_result)
    else:
        raise ValueError("Could not find '{}' in the path".format(cmd))
433249
def decorate_callable(self, func):
        
        def wrapper(*args, **kwargs):
            try:
                with self:
                    result = func(*args, **kwargs)
                return result
            except DBMutexError as e:
                if self.suppress_acquisition_exceptions:
                    LOG.error(e)
                else:
                    raise e
        functools.update_wrapper(wrapper, func)
        return wrapper
446636
def wraps(__fn, **kw):
        """"""
        kw['assigned'] = kw.get('assigned', WRAPPER_ASSIGNMENTS)
        return functools.wraps(__fn, **kw)
651342
def wrap_connection(func_, *args, **kwargs):
    
    if not args[-1]:
        new_args = list(args)
        new_args[-1] = connect()
        args = tuple(new_args)
    return func_(*args, **kwargs)
319888
function wrap_cb(fn, P) {
  return function (params) {
    return new P(function (resolve, reject) {
      fn(params, function (err) { return !err ? resolve() : reject(err); });
    });
  };
}
917401
def wrap_function(self, func):
        
        def f(*args, **kwds):
            # Start time
            timestamps = [_get_memory(os.getpid(), timestamps=True)]
            self.functions[func].append(timestamps)
            try:
                result = func(*args, **kwds)
            finally:
                # end time
                timestamps.append(_get_memory(os.getpid(), timestamps=True))
            return result
        return f
1210353
def safe_wraps(wrapper, *args, **kwargs):
    """"""
    while isinstance(wrapper, functools.partial):
        wrapper = wrapper.func
    return functools.wraps(wrapper, *args, **kwargs)
700569
function wrap(fn) {
  // Error handling middleware
  if (fn.length === 4) {
    return async function wrappedErrorHandler(error, req, res, next) {
      next = _once(next);
      try {
        await fn(error, req, res, next);
        res.headersSent ? null : next();
      } catch(err) {
        res.headersSent ? null : next(err);
      }
    };
  }

  return async function wrappedMiddleware(req, res, next) {
    next = _once(next);
    try {
      await fn(req, res, next);
      res.headersSent ? null : next();
    } catch(err) {
      res.headersSent ? null : next(err);
    }
  };
}
1036895
def partition_t(wrap, func):
    
    return Transformation(
        'partition({0})'.format(name(func)),
        partial(partition_impl, wrap, func),
        None
    )
967055
def noisy_wrap(__func: Callable) -> Callable:
    
    # pylint: disable=missing-docstring
    def wrapper(*args, **kwargs):
        DebugPrint.enable()
        try:
            __func(*args, **kwargs)
        finally:
            DebugPrint.disable()
    return wrapper
871637
def call(self, func, *args, **kwargs):
        
        wrapped = self.wrap(func)
        return wrapped(*args, **kwargs)
498904
function wrapper() {
        context = this;
        args = arguments;
        if (!no_postpone) {
          cancel();
          timeout = $timeout(ping, wait);
        } else if (executed) {
          executed = false;
          timeout = $timeout(ping, wait);
        }
      }
906146
function wrap(callback, name) {
  var isLST
    , stack
    , d

  if ('function' !== typeof callback || callback && callback.name === '_trycatchOnError') return callback

  isLST = options['long-stack-traces']
  d = process.domain
  if (isLST) {
    stack = getStack(d)
  }

  // Inherit from callback for when properties are added
  newCallback.__proto__ = callback
  return newCallback

  function newCallback() {
    if (isLST && d) d.currentStack = stack

    runInDomain(d, callback, trycatchitApply, [this, arguments])
  }
}
133267
function wrap(fn) {
  return function () {
    var self = this, args = arguments;
    this.domain.run(function () {
      fn.apply(self, args);
    });
  };
}
1271213
def wrap_ufunc_base(name, n_in, n_out, doc):
    """"""
    ufunc = getattr(np, name)
    if n_in == 1:
        if n_out == 1:
            def wrapper(self, out=None, **kwargs):
                if out is None or isinstance(out, (type(self.elem),
                                                   type(self.elem.data))):
                    out = (out,)

                return self.elem.__array_ufunc__(
                    ufunc, '__call__', self.elem, out=out, **kwargs)

        elif n_out == 2:
            def wrapper(self, out=None, **kwargs):
                if out is None:
                    out = (None, None)

                return self.elem.__array_ufunc__(
                    ufunc, '__call__', self.elem, out=out, **kwargs)

        else:
            raise NotImplementedError

    elif n_in == 2:
        if n_out == 1:
            def wrapper(self, x2, out=None, **kwargs):
                return self.elem.__array_ufunc__(
                    ufunc, '__call__', self.elem, x2, out=(out,), **kwargs)

        else:
            raise NotImplementedError
    else:
        raise NotImplementedError

    wrapper.__name__ = wrapper.__qualname__ = name
    wrapper.__doc__ = doc
    return wrapper
205185
function wrapHandler(handler) {
  return function (state, ...args) {
    return _.assign({}, state, handler(state, ...args));
  };
}
588110
function wrap(input, wrap, ends) {

  if(!isString(input) || isUndefined(wrap)) {
    return input;
  }

  return [wrap, input, ends || wrap].join('');

}