Get an enclosing frame that skips decorator code
544525
def enclosing_frame(frame=None, level=2):
    """"""
    frame = frame or sys._getframe(level)
    while frame.f_globals.get('__name__') == __name__: frame = frame.f_back
    return frame
657467
def _get_v23_frame(self, **kwargs):
        

        new_kwargs = {}
        for checker in self._framespec:
            name = checker.name
            value = getattr(self, name)
            new_kwargs[name] = checker._validate23(self, value, **kwargs)

        for checker in self._optionalspec:
            name = checker.name
            if hasattr(self, name):
                value = getattr(self, name)
                new_kwargs[name] = checker._validate23(self, value, **kwargs)

        return type(self)(**new_kwargs)
176028
def _onDecorator(self, name, line, pos, absPosition):
        """"""
        # A class or a function must be on the top of the stack
        d = Decorator(name, line, pos, absPosition)
        if self.__lastDecorators is None:
            self.__lastDecorators = [d]
        else:
            self.__lastDecorators.append(d)
621074
def make_context_aware(func, numargs):
    
    try:
        if inspect.ismethod(func):
            arg_count = len(inspect.getargspec(func).args) - 1
        elif inspect.isfunction(func):
            arg_count = len(inspect.getargspec(func).args)
        elif inspect.isclass(func):
            arg_count = len(inspect.getargspec(func.__init__).args) - 1
        else:
            arg_count = len(inspect.getargspec(func.__call__).args) - 1
    except TypeError:
        arg_count = numargs

    if arg_count <= numargs:
        def normalized(*args):
            return func(*args[:-1])

        return normalized

    return func
111526
def _wrap(cls, func):
        

        if isinstance(func, cls):
            return func
        return functools.update_wrapper(cls(func), func)
185338
def _wrap_in_place(func):  # noqa: D202
        """"""

        @wraps(func)
        def wrapper(graph, *args, **kwargs):
            """Apply the enclosed function and returns the graph."""
            func(graph, *args, **kwargs)
            return graph

        return wrapper
1217652
def _skip_saveframe(self, lexer):
        
        token = u""
        while token != u"save_":
            token = next(lexer)
449087
def decorate(decorator_cls, *args, **kwargs):
    """"""
    global _wrappers

    wrapper_cls = _wrappers.get(decorator_cls, None)
    if wrapper_cls is None:

        class PythonWrapper(decorator_cls):
            pass

        wrapper_cls = PythonWrapper
        wrapper_cls.__name__ = decorator_cls.__name__ + "PythonWrapper"
        _wrappers[decorator_cls] = wrapper_cls

    def decorator(fn):
        wrapped = wrapper_cls(fn, *args, **kwargs)
        _update_wrapper(wrapped, fn)
        return wrapped

    return decorator
1236286
def _unwrap_func(cls, decorated_func):
        '''
        
        '''
        if click is not None:
            # Workaround for click.command() decorator not setting
            # __wrapped__
            if isinstance(decorated_func, click.Command):
                return cls._unwrap_func(decorated_func.callback)

        if hasattr(decorated_func, '__wrapped__'):
            # Recursion: unwrap more if needed
            return cls._unwrap_func(decorated_func.__wrapped__)
        else:
            # decorated_func isn't actually decorated, no more
            # unwrapping to do
            return decorated_func
1150992
function makeLostContextFunctionWrapper(ctx, functionName) {
    var f = ctx[functionName];
    return function() {
      // log("calling:" + functionName);
      // Only call the functions if the context is not lost.
      loseContextIfTime();
      if (!contextLost_) {
        //if (!checkResources(arguments)) {
        //  glErrorShadow_[wrappedContext_.INVALID_OPERATION] = true;
        //  return;
        //}
        var result = f.apply(ctx, arguments);
        return result;
      }
    };
  }
989280
def include_original(dec):
    """"""
    def meta_decorator(method):
        """Yo dawg, I heard you like decorators..."""
        # pylint: disable=protected-access
        decorator = dec(method)
        decorator._original = method
        return decorator
    return meta_decorator
467562
def getinnerframes(tb, context=1):
    """"""
    framelist = []
    while tb:
        framelist.append((tb.tb_frame,) + getframeinfo(tb, context))
        tb = tb.tb_next
    return framelist
32489
def after(f, chain=False):
    """"""
    def decorator(g):
        @wraps(g)
        def h(*args, **kargs):
            if chain:
                return f(g(*args, **kargs))
            else:
                r = g(*args, **kargs)
                f(*args, **kargs)
                return r
        return h
    return decorator
1111552
def extract_view(view, decorators=None):
    
    # http://stackoverflow.com/questions/9222129/python-inspect-getmembers-does-not-return-the-actual-function-when-used-with-dec
    if decorators is None:
        decorators = []
    if getattr(view, 'func_closure', None) is not None:
        decorators.append(view)
        for closure in view.func_closure:
            if callable(closure.cell_contents):
                return extract_view(closure.cell_contents, decorators)
    if inspect.isfunction(view) or inspect.ismethod(view):
        pass
    elif inspect.isclass(view):
        pass
    else:
        view = view.__class__
    return view, decorators
446816
function checkDecorator(decorator, value, node) {
      const decoratorLine = decorator.loc.start.line;
      const decoratorColumn = decorator.loc.end.column;
      const valueLine = value.loc.start.line;

      if (config === 'always') {
        if (decoratorLine === valueLine) {
          context.report({
            node,
            loc: { line: decoratorLine, column: decoratorColumn },
            message: ALWAYS_MESSAGE,
          });
        }
      } else {
        if (decoratorLine !== valueLine) { // eslint-disable-line
          context.report({
            node,
            loc: { line: decoratorLine, column: decoratorColumn },
            message: NEVER_MESSAGE,
          });
        }
      }
    }
860725
def _make_wrapper(f):
    """"""
    @wraps(f)
    def wrapper(*args, **kwargs):
        return f(*args, **kwargs)
    wrapper._pecan = f._pecan.copy()
    return wrapper
1352406
function wrapCallback( fn, frameLocation ) {
  const traceError = new Error();
  traceError.__location = frameLocation;
  traceError.__previous = currentTraceError;

  return function $wrappedCallback( ...args ) {
    currentTraceError = traceError;
    try {
      return fn.call( this, ...args );
    } catch ( e ) {
      throw e; // we just need the the 'finally'
    } finally {
      currentTraceError = null;
    }
  };
}