Register filters for specific language.
    If language == None the filter applies for all languages.
    Filter will not apply for stop words in cache.
    :param func: callable
    :param language: string|None
    :return:
487877
def add_filter(func, language=None):
    
    if language not in _filters:
        _filters[language] = []
    _filters[language].append(func)
91950
def _load_language_or_die(f):
	'''  '''

	# This decorator checks if there's a custom method for a given language.
	# If so, prefer the custom method, otherwise raise exception NotImplementedError.

	@wraps(f)
	def loader(language, word, *args, **kwargs):
		method = f.func_name
		try:
			if isinstance(language, (list, tuple)):
				_lltk = __import__('lltk.' + language[0], globals(), locals(), [method], -1)
			else:
				_lltk = __import__('lltk.' + language, globals(), locals(), [method], -1)
		except ImportError:
			from lltk.exceptions import LanguageNotSupported
			raise LanguageNotSupported('The language ' + language + ' is not supported so far.')

		if hasattr(_lltk, method):
			function = getattr(_lltk, method)
			if callable(function):
				return function(word, *args, **kwargs)
		# No custom method implemented, yet.
		raise NotImplementedError('Method lltk.' + language + '.' + method +'() not implemented, yet.')
	return loader
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()
1167104
def char_between(lower, upper, func_name): 
  ''''''
  function = register_function(func_name, 
                      lambda char: lower<=char<=upper)
  return char_on_predicate(function)
1090241
def set_cache_policy(self, func):
    
    if func is None:
      func = self.default_cache_policy
    elif isinstance(func, bool):
      func = lambda unused_key, flag=func: flag
    self._cache_policy = func
968512
def filtered(f):
    '''
    
    '''

    def _filter(f, self, *args, **kwargs):
        frame = f(self, *args, **kwargs)
        ret = type(self)(frame)
        ret._lbound = self._lbound
        ret._rbound = self._rbound
        return ret

    if HAS_DECORATOR:
        return decorator(_filter, f)
    else:
        def err_func(*args, **kwargs):
            raise RuntimeError("`pip install decorator` required")
        return err_func
980647
function translateInLanguageFilter(key, locale) {
    for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
      args[_key - 2] = arguments[_key];
    }

    return translateInLanguage.apply(void 0, [locale, key].concat(args));
  }
701101
def dont_cache():
    
    def decorate_func(func):
        @wraps(func)
        def decorate_func_call(*a, **kw):
            callback = SetCacheControlHeadersForNoCachingCallback()
            registry_provider = AfterThisRequestCallbackRegistryProvider()
            registry = registry_provider.provide()
            registry.add(callback)
            return func(*a, **kw)
        return decorate_func_call
    return decorate_func
626806
def register_function_compilation(self, func, compilation_cbk, listclass):
        
        self.compilations_function[func] = {
            'callback':  compilation_cbk,
            'listclass': listclass
        }
1146267
function register(fn, p, key) {
    if (key != undefined && typeof key !== 'string')
      throw 'The filter key "'+ key.toString() +'" must be a string.';

    if (key != undefined && !key.length)
      throw 'The filter key must be a non-empty string.';

    if (typeof fn !== 'function')
      throw 'The predicate of key "'+ key +'" must be a function.';

    if ('undo' === key)
      throw '"undo" is a reserved key.';

    if (_keysIndex[key])
      throw 'The filter "' + key + '" already exists.';

    if (key)
      _keysIndex[key] = true;

    _chain.push({
      'key': key,
      'processor': fn,
      'predicate': p
    });
  }
662777
def filter(self, func):
        """"""
        return self.__class__( [ i for i in self.res if func(*i) ], name='filtered %s'%self.listname)
1233937
def apply(filter):
    
    def decorator(callable):
        return lambda *args, **kwargs: filter(callable(*args, **kwargs))
    return decorator
1156892
def register(**kwargs):
    
    def decorator(func):
        _CALL_REGISTRY[kwargs.get(API_SYM, func.__name__)] = func
        return func

    return decorator
281292
def proxy_register(register_funtion):
    
    def wrapper(function):
        @functools.wraps(function)
        def register(excepted, filter_function=None):
            if inspect.isfunction(excepted):
                register_funtion(excepted.__name__, excepted)
            elif isinstance(excepted, str) and filter_function:
                if not inspect.isfunction(filter_function):
                    raise RegisterError('Registered must be a function.')
                filter_function.__name__ = excepted
                register_funtion(excepted, filter_function)
            elif isinstance(excepted, str):
                def register_wrapper(func):
                    if not inspect.isfunction(func):
                        raise RegisterError('Registered must be a function.')
                    func.__name__ = excepted
                    register_funtion(excepted, func)
                return register_wrapper
        return register
    return wrapper
104825
def binding(key, registry=None):
    
    if registry is None:
        registry = _registry

    def decorator(func):
        registry.bind(key, func)
        return func
    return decorator
163720
def atexit_register(func):
    
    try:
        import uwsgi

        orig = getattr(uwsgi, "atexit", None)

        def uwsgi_atexit():
            if callable(orig):
                orig()
            func()

        uwsgi.atexit = uwsgi_atexit
    except ImportError:
        atexit.register(func)
260996
def filter(self, func):
        
        return self._wrap(list(filter(func, self.obj)))