def filter_candidates(self, context): for source in self.__current_sources: ctx = source.context ctx['input'] = context['input'] ctx['mode'] = context['mode'] ctx['is_redraw'] = context['is_redraw'] all = ctx['all_candidates'] if ctx['is_async']: all += source.gather_candidates(ctx) if not all: continue candidates = [] for i in range(0, len(all), 1000): ctx['candidates'] = all[i:i+1000] for matcher in [self.__filters[x] for x in source.matchers if x in self.__filters]: ctx['candidates'] = matcher.filter(ctx) candidates += ctx['candidates'] if len(candidates) >= 1000: break ctx['candidates'] = candidates for filter in [self.__filters[x] for x in source.sorters + source.converters if x in self.__filters]: ctx['candidates'] = filter.filter(ctx) candidates = ctx['candidates'] for c in candidates: c['source'] = source.name ctx['candidates'] = [] yield source.name, all, candidates
def filter_candidates(self, context): for source in self.__current_sources: ctx = source.context ctx['input'] = context['input'] all = ctx['all_candidates'] if ctx['is_async']: all += source.gather_candidates(ctx) candidates = [] for i in range(0, len(all), 1000): ctx['candidates'] = all[i:i+1000] for matcher in [self.__filters[x] for x in source.matchers if x in self.__filters]: ctx['candidates'] = matcher.filter(ctx) candidates += ctx['candidates'] if len(candidates) >= 1000: break ctx['candidates'] = candidates for filter in [self.__filters[x] for x in source.sorters + source.converters if x in self.__filters]: ctx['candidates'] = filter.filter(ctx) candidates = ctx['candidates'] for c in candidates: c['source'] = source.name ctx['candidates'] = [] yield source.name, all, candidates
def filter_candidates(self, context): for source in self.__current_sources: source.context['input'] = context['input'] for filter in [ self.__filters[x] for x in source.matchers + source.sorters + source.converters if x in self.__filters ]: yield source.name, filter.filter(source.context)