Remove decorators from the source code
544271
def remove_decorators(src):
    
    src = src.strip()
    src_lines = src.splitlines()
    multi_line = False
    n_deleted = 0
    for n in range(len(src_lines)):
        line = src_lines[n - n_deleted].strip()
        if (line.startswith('@') and 'Benchmark' in line) or multi_line:
            del src_lines[n - n_deleted]
            n_deleted += 1
            if line.endswith(')'):
                multi_line = False
            else:
                multi_line = True
    setup_src = '\n'.join(src_lines)
    return setup_src
1309467
def disallow_positional_args(wrapped=None, allowed=None):
  """"""
  # See
  # https://wrapt.readthedocs.io/en/latest/decorators.html#decorators-with-optional-arguments
  # for decorator pattern.
  if wrapped is None:
    return functools.partial(disallow_positional_args, allowed=allowed)

  @wrapt.decorator
  def disallow_positional_args_dec(fn, instance, args, kwargs):
    ismethod = instance is not None
    _check_no_positional(fn, args, ismethod, allowed=allowed)
    _check_required(fn, kwargs)
    return fn(*args, **kwargs)

  return disallow_positional_args_dec(wrapped)
1025085
def unbind(self, func, etype):
        '''
        
        '''
        i= self.event_funcs[etype].index(func)
        del self.event_funcs[etype][i]
189848
def unbare_repo(func):
    """"""

    @wraps(func)
    def wrapper(self, *args, **kwargs):
        if self.repo.bare:
            raise InvalidGitRepositoryError("Method '%s' cannot operate on bare repositories" % func.__name__)
        # END bare method
        return func(self, *args, **kwargs)
    # END wrapper
    return wrapper
983647
def declassify(to_remove, *args, **kwargs):
    
    def argdecorate(fn):
        """ enable the to_remove argument to the decorator. """
        # wrap the function to get the original docstring
        @wraps(fn)
        def declassed(*args, **kwargs):
            # call the method
            ret = fn(*args, **kwargs)
            # catch errors that are thrown by the api
            try:
                # ensure that ret is a list
                if type(ret) is list:
                    return [r[to_remove] for r in ret]
                return ret[to_remove]
            except KeyError:
                return ret
        return declassed
    return argdecorate
1102034
def deprecated(func, *args, **kwargs):
    '''  '''
    warnings.warn(
        '{} is deprecated and should no longer be used.'.format(func),
        DeprecationWarning,
        stacklevel=3
    )
    return func(*args, **kwargs)
150895
def hide(*keys):
    
    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            g.hide_request_fields = keys
            g.hide_response_fields = keys
            return func(*args, **kwargs)
        return wrapper
    return decorator
281307
def XXX_REMOVEME(func):
    
    @wraps(func)
    def decorator(self, *args, **kwargs):
        msg = "~~~~~~~ XXX REMOVEME marked method called: {}.{}".format(
            self.__class__.__name__, func.func_name)
        raise RuntimeError(msg)
        return func(self, *args, **kwargs)
    return decorator
1302927
def deprecated(message=None):
    

    def decorated_method_to_deprecate(func):
        if inspect.isclass(func):
            # Handle a deprecated class differently from a deprecated method
            msg = "Class {}() is DEPRECATED! *** ".format(func.__name__)
            if message:
                msg += "<> %s <>" % message
            warnings.simplefilter('always', DeprecationWarning)  # See Warnings
            warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
            warnings.simplefilter('default', DeprecationWarning)  # Set Default
            return func

        @wraps(func)
        def new_func(*args, **kwargs):
            msg = "Method {}() is DEPRECATED! *** ".format(func.__name__)
            if message:
                msg += "<> %s <>" % message
            warnings.simplefilter('always', DeprecationWarning)  # See Warnings
            warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
            warnings.simplefilter('default', DeprecationWarning)  # Set Default
            return func(*args, **kwargs)
        return new_func
    return decorated_method_to_deprecate
229625
def disable_logging(func):
    return func
    
    handler = logging.NullHandler()

    @wraps(func)
    def wrapper(*args, **kwargs):
        logger = logging.getLogger()
        logger.addHandler(handler)
        resp = func(*args, **kwargs)
        logger.removeHandler(handler)
        return resp
    return wrapper
669266
def _remove_non_methods():
  """"""
  cur_module = sys.modules[__name__]
  my_globals = dict(globals())
  # Import here so that it doesn't get added to the global namespace or deleted.
  # pylint: disable=g-import-not-at-top
  from prettytensor.pretty_tensor_class import PrettyTensor
  for name, _ in six.iteritems(my_globals):
    if not hasattr(PrettyTensor, name):
      delattr(cur_module, name)
  # Remove a couple of special ones....
  if hasattr(cur_module, 'bookkeeper'):
    delattr(cur_module, 'bookkeeper')
1122518
def RemoveMethod(self, function):
        
        self.added_methods = [dm for dm in self.added_methods if not dm.method is function]
986616
def deprecated(func):
    
    def decorated(*args, **kwargs):
        warnings.warn('Call to deprecated function %s.' % func.__name__,
                      category=DeprecationWarning,
                      stacklevel=2)
        return func(*args, **kwargs)
    decorated.__name__ = func.__name__
    decorated.__doc__ = func.__doc__
    decorated.__dict__.update(func.__dict__)
    return decorated
1049628
def wraps(function):
    """"""
    def wrap(decorator):
        decorator = functools.wraps(function)(decorator)
        if not hasattr(function, 'original'):
            decorator.original = function
        else:
            decorator.original = function.original
            delattr(function, 'original')
        return decorator
    return wrap
1107985
def remove(self, name, func):
        '''  '''
        was_empty = self._empty()
        if name in self.hooks and func in self.hooks[name]:
            self.hooks[name].remove(func)
        if self.app and not was_empty and self._empty(): self.app.reset()
417456
def deprecate(func):
  
  @wraps(func)
  def wrapper(*args, **kwargs):
    warn("Deprecated, this will be removed in the future", DeprecationWarning)
    return func(*args, **kwargs)
  wrapper.__doc__ = "Deprecated.\n" + (wrapper.__doc__ or "")
  return wrapper
1326192
private void trimCandidatesUsingOnCost() {
    Iterator<Entry<String, FunctionState>> i;
    for (i = fns.entrySet().iterator(); i.hasNext(); ) {
      FunctionState functionState = i.next().getValue();
      if (functionState.hasReferences()) {
        // Only inline function if it decreases the code size.
        boolean lowersCost = minimizeCost(functionState);
        if (!lowersCost) {
          // It shouldn't be inlined; remove it from the list.
          i.remove();
        }
      } else if (!functionState.canRemove()) {
        // Don't bother tracking functions without references that can't be
        // removed.
        i.remove();
      }
    }
  }