A decorator that registers a single hug delete context function
422293
def delete_context(apply_globally=False, api=None):
    """"""
    def decorator(delete_context_):
        if apply_globally:
            hug.defaults.delete_context = delete_context_
        else:
            apply_to_api = hug.API(api) if api else hug.api.from_object(delete_context_)
            apply_to_api.delete_context = delete_context_
        return delete_context_
    return decorator
670534
def deleter(self, func):
        
        if not callable(func):
            raise TypeError('deleter must be callable function')
        if hasattr(func, '__code__') and func.__code__.co_argcount != 1:
            raise TypeError('deleter must be a function with two arguments')
        if func.__name__ != self.name:
            raise TypeError('deleter function must have same name as getter')
        self._del_func = func
        return self
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
959117
function(fn, context){
      var cursor = this;
      var prev;

      while (prev = cursor, cursor = cursor.handler)
        if (cursor.fn === fn && cursor.context === context)
        {
          // make it non-callable
          cursor.fn = $undef;
          cursor.destroy = cursor.destroy && $undef;

          // remove from list
          prev.handler = cursor.handler;

          return;
        }

      /** @cut */ consoleMethods.warn('basis.Token#detach: fn & context pair not found, nothing was removed');
    }
1004402
def deleteBy(self, func):
        ''
        oldrows = copy(self.rows)
        oldidx = self.cursorRowIndex
        ndeleted = 0

        row = None   # row to re-place cursor after
        while oldidx < len(oldrows):
            if not func(oldrows[oldidx]):
                row = self.rows[oldidx]
                break
            oldidx += 1

        self.rows.clear()
        for r in Progress(oldrows, 'deleting'):
            if not func(r):
                self.rows.append(r)
                if r is row:
                    self.cursorRowIndex = len(self.rows)-1
            else:
                ndeleted += 1

        status('deleted %s %s' % (ndeleted, self.rowtype))
        return ndeleted
17540
def register_vcs_handler(vcs, method):  # tyoe: (str, str) -> typing.Callable  # decorator
    """"""
    def decorate(f):
        """Store f in HANDLERS[vcs][method]."""
        if vcs not in HANDLERS:
            HANDLERS[vcs] = {}
        HANDLERS[vcs][method] = f
        return f
    return decorate
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
292649
def unregister(self, name, func):
        
        try:
            templatehook = self._registry[name]
        except KeyError:
            return

        templatehook.unregister(func)
926421
def context_cache(func):
    '''
    
    '''
    def context_cache_wrap(*args, **kwargs):
        func_context = func.__globals__['__context__']
        func_opts = func.__globals__['__opts__']
        func_name = func.__globals__['__name__']

        context_cache = ContextCache(func_opts, func_name)
        if not func_context and os.path.isfile(context_cache.cache_path):
            salt.utils.dictupdate.update(func_context, context_cache.get_cache_context())
        else:
            context_cache.cache_context(func_context)
        return func(*args, **kwargs)
    return context_cache_wrap
942257
def _strip_odict(wrapped):
    '''
    
    '''
    @functools.wraps(wrapped)
    def strip(*args):
        return salt.utils.json.loads(salt.utils.json.dumps(wrapped(*args)))
    return strip
710829
def strippen(function):
    ""
    def wrapper(*args, **kwargs):
        return strip_strings(function(*args, **kwargs))
    return wrapper
418728
def wrap_context(func):
    
    @functools.wraps(func)
    def wrapper(self, request, context):
        return func(self, request, LogFieldsContext(context))

    return wrapper
122643
def _tp_cache(func):
    

    cached = functools.lru_cache()(func)
    _cleanups.append(cached.cache_clear)

    @functools.wraps(func)
    def inner(*args, **kwds):
        try:
            return cached(*args, **kwds)
        except TypeError:
            pass  # All real errors (not unhashable args) are raised below.
        return func(*args, **kwds)

    return inner
204984
def memoize(f, refresh_keyword='mrefresh'):
    
    f.mcache = {}
    f.mrefresh_keyword = refresh_keyword
    return decorator.decorator(_memoize, f)
1214421
function bind (fn, context) {
  return fn.bind ? fn.bind(context) : function () {
    fn.apply(context, arguments)
  }
}
217492
def decorator(func):
  
  """
  def wrapper(__decorated__=None, *Args, **KwArgs):
    if __decorated__ is None: # the decorator has some optional arguments.
      return lambda _func: func(_func, *Args, **KwArgs)

    else:
      return func(__decorated__, *Args, **KwArgs)

  return wrap(wrapper, func)
713292
def remove_from_context(self, name, *args):
        
        context = self.get_context(name=name)
        attrs_ = context['context']
        for a in args:
            del attrs_[a]