Register a new output filter. Whenever bottle hits a handler output
            matching `ftype`, `func` is applyed to it.
771760
def add_filter(self, ftype, func):
        '''  '''
        if not isinstance(ftype, type):
            raise TypeError("Expected type object, got %s" % type(ftype))
        self.castfilter = [(t, f) for (t, f) in self.castfilter if t != ftype]
        self.castfilter.append((ftype, func))
        self.castfilter.sort()
1299602
function registerValueHandler (handlers, type, handler) {
  let typeofType = typeof type;

  if (typeofType !== 'function' && typeofType !== 'string') {
    throw new Error("type must be a class constructor or string");
  }

  if (typeof handler !== 'function') {
    throw new Error("handler must be a function");
  }

  for (let typeHandler of handlers) {
    if (typeHandler.type === type) {
      typeHandler.handler = handler;

      return;
    }
  }

  handlers.push({
    type: type,
    handler: handler,
  });
}
71873
def bind(self, func, etype):
        '''
        
        '''
        self.event_funcs.setdefault(etype, [])
        # Don't add multiple times!
        if func not in self.event_funcs[etype]:
            self.event_funcs[etype].append(func)
567785
def _register_function(name: str, func, universe: bool, in_place: bool):
    
    if name in mapped:
        mapped_func = mapped[name]
        raise PipelineNameError('{name} is already registered with {func_mod}.{func_name}'.format(
            name=name,
            func_mod=mapped_func.__module__,
            func_name=mapped_func.__name__
        ))

    mapped[name] = func

    if universe:
        universe_map[name] = func

    if in_place:
        in_place_map[name] = func

    if _has_arguments(func, universe):
        has_arguments_map[name] = func
    else:
        no_arguments_map[name] = func

    return func
198244
def filter(self, filter_fn):
        
        op = Operator(
            _generate_uuid(),
            OpType.Filter,
            "Filter",
            filter_fn,
            num_instances=self.env.config.parallelism)
        return self.__register(op)
935803
def register_helper(self, func):
        

        self._helper_names.add(func.__name__)
        return self.register(func)
1185769
def add_handler(self, func, type='all'):
        
        if not callable(func):
            raise ValueError("{} is not callable".format(func))

        self._handlers[type].append(
            (func, len(signature(func).parameters.keys()))
        )
753275
def register(self, event, fn):
        

        # TODO: Can we check the method signature?
        self._handler_dict.setdefault(event, [])
        if fn not in self._handler_dict[event]:
            self._handler_dict[event].append(fn)
853468
def _apply_outputter(self, func, mod):
        '''
        
        '''
        if hasattr(mod, '__outputter__'):
            outp = mod.__outputter__
            if func.__name__ in outp:
                func.__outputter__ = outp[func.__name__]
451854
def registerExcept(func):
    
    setup()
    ref = weakref.ref(func)
    if ref not in _excepthooks:
        _excepthooks.append(ref)
741723
def register(self, name):
        """"""
        def decorator(func):
            """Register decorated function."""
            self[name] = func
            return func

        return decorator
908678
def register_errors_handler(self, callback, *custom_filters, exception=None, run_task=None, **kwargs):
        
        filters_set = self.filters_factory.resolve(self.errors_handlers,
                                                   *custom_filters,
                                                   exception=exception,
                                                   **kwargs)
        self.errors_handlers.register(self._wrap_async_task(callback, run_task), filters_set)
453173
def register(cls, func):
		
		cls._add_version_info(func)
		cls._upgrade_funcs.add(func)
		return func
1127544
def register_output_format(name):
    

    def check_decorator(fn):
        _output_format_map[name] = fn

        def wrapper(*args, **kwargs):
            return fn(*args, **kwargs)

        return wrapper

    return check_decorator
396455
def apply(self, callback, context):  # pragma: no cover
        

        def wrapper(*args, **kwargs):
            try:
                return callback(*args, **kwargs)
            except bottle.HTTPError as error:
                return self.error_wrapper.from_status(
                    status_line=error.status_line,
                    msg=error.body
                )

        return wrapper
965520
def register_function(cls, fn, label):
        """"""
        if label in cls.registered_functions:
            log.warning("Overwriting existing registered function %s", label)

        fn.label = label
        cls.registered_functions[fn.label] = fn
1011284
def handler_all(func=None):
	
	if not func:
		return functools.partial(handler_all)

	registrations_global.append(func)

	return func