Format search results.

        Args:
            search_results (list of `ResourceSearchResult`): Search to format.

        Returns:
            List of 2-tuple: Text and color to print in.
1749
def format_search_results(self, search_results):
        
        formatted_lines = []

        for search_result in search_results:
            lines = self._format_search_result(search_result)
            formatted_lines.extend(lines)

        return formatted_lines
283541
def output_results(cls, sprites):
        
        print(' '.join(cls.ATTRIBUTES))
        format_strs = ['{{{}!s:^{}}}'.format(x, len(x)) for x in
                       cls.ATTRIBUTES]
        print(' '.join(format_strs).format(**cls.attribute_result(sprites)))
573788
protected void convertSearchResults(final Collection<CmsSearchResource> searchResults) {

        m_foundResources = new ArrayList<I_CmsSearchResourceBean>();
        for (final CmsSearchResource searchResult : searchResults) {
            m_foundResources.add(new CmsSearchResourceBean(searchResult, m_cmsObject));
        }
    }
367355
def _process_layperson_results(self, results):
        

        payload = {
            'results': []
        }

        for doc in results.docs:
            hl = self._process_highlight(results, doc)
            highlight = {
                'id': doc['id'],
                'highlight': hl.highlight,
                'label': doc['label'],
                'matched_synonym': hl.match
            }
            payload['results'].append(highlight)

        logging.debug('Docs: {}'.format(len(results.docs)))

        return payload
800413
def print_result(self, directory_result):
        
        for file_name, line_results_dict in directory_result.iter_line_results_items():
            full_path = path.join(directory_result.directory_path, file_name)
            self.write(full_path, 'green')
            self.write('\n')
            for line_number, line_results in sorted(line_results_dict.items()):
                self.write('%s: ' % (line_results[0].line_number))
                out = list(line_results[0].left_of_group + line_results[0].group + line_results[0].right_of_group)
                offset = 0
                for line_result in line_results:
                    group_length = len(line_result.group)
                    out.insert(offset+line_result.left_offset-1, self.colors['blue'])
                    out.insert(offset+line_result.left_offset+group_length, self.colors['end'])
                    offset += group_length + 1
                self.write(''.join(out)+'\n')
            self.write('\n')
671344
def _format_list(result):
    """"""

    if not result:
        return result

    if isinstance(result[0], dict):
        return _format_list_objects(result)

    table = Table(['value'])
    for item in result:
        table.add_row([iter_to_table(item)])
    return table
664809
def _process(self, responses):
        
        self.log.debug("Processing search results")
        items = list()
        for response in responses:
            try:
                soup = BeautifulSoup(response.content, 'html.parser',
                                     from_encoding="iso-8859-1")
            except:
                continue
            else:
                listings = soup.findAll('li', {'class': 'b_algo'})
                items.extend([l.find('a')['href'] for l in listings])
        self.log.debug("Search result URLs were extracted")
        return items
923138
def results(self):
        
        d = dict()
        words = [word.strip() for word in self.haystack]

        if not words:
            raise NoResultException('No similar word found.')

        for w in words:
            d[w] = Levenshtein.ratio(self.needle, w)

        return sorted(d.items(), key=operator.itemgetter(1), reverse=True)
1091783
def get_page(search_text):
    
    lst = search_aikif(search_text)
    txt = '<table class="as-table as-table-zebra as-table-horizontal">'
    for result in lst:
        txt += '<TR><TD>' + result + '</TD></TR>'
    txt += '</TABLE>\n\n'
    return txt
408924
def get_search_results(self, request, queryset, search_term):
        
        # Apply keyword searches.
        def construct_search(field_name):
            if field_name.startswith('^'):
                return "%s__istartswith" % field_name[1:]
            elif field_name.startswith('='):
                return "%s__iexact" % field_name[1:]
            elif field_name.startswith('@'):
                return "%s__search" % field_name[1:]
            else:
                return "%s__icontains" % field_name

        use_distinct = False
        if self.search_fields and search_term:
            orm_lookups = [construct_search(str(search_field))
                           for search_field in self.search_fields]
            for bit in search_term.split():
                or_queries = [models.Q(**{orm_lookup: bit})
                              for orm_lookup in orm_lookups]
                queryset = queryset.filter(reduce(operator.or_, or_queries))
            if not use_distinct:
                for search_spec in orm_lookups:
                    if lookup_needs_distinct(self.opts, search_spec):
                        use_distinct = True
                        break

        return queryset, use_distinct
943962
def format_result(input):
        
        items = list(iteritems(input))
        return OrderedDict(sorted(items, key=lambda x: x[0]))
153667
def search(query, num_results=10):
	
	data = download(query, num_results)
	results = re.findall(r'\<h3.*?\>.*?\<\/h3\>', data, re.IGNORECASE)
	if results is None or len(results) == 0:
		print('No results where found. Did the rate limit exceed?')
		return []
	# search has results
	links = []
	for r in results:
		mtch = re.match(r'.*?a\s*?href=\"(.*?)\".*?\>(.*?)\<\/a\>.*$', r, flags=re.IGNORECASE)
		if mtch is None:
			continue
		# parse url
		url = mtch.group(1)
		# clean url https://github.com/aviaryan/pythons/blob/master/Others/GoogleSearchLinks.py
		url = re.sub(r'^.*?=', '', url, count=1) # prefixed over urls \url=q?
		url = re.sub(r'\&amp.*$', '', url, count=1) # suffixed google things
		url = unquote(url)
		# url = re.sub(r'\%.*$', '', url) # NOT SAFE, causes issues with Youtube watch url
		# parse name
		name = prune_html(mtch.group(2))
		name = convert_unicode(name)
		# append to links
		if is_url(url): # can be google images result
			links.append((name, url))
	return links
1313309
def _process_results(self, results):
        
        results = [r for r in results if r[0] is not None]
        results = _DeepStringCoder('utf-8').decode(results)

        # The normal form of a DN is lower case.
        results = [(r[0].lower(), r[1]) for r in results]

        result_dns = [result[0] for result in results]
        logger.debug(u"search_s('%s', %d, '%s') returned %d objects: %s" %
                     (self.base_dn, self.scope, self.filterstr, len(result_dns),
                      "; ".join(result_dns)))

        return results
1261542
def format_results(self, results, request):
        
        self.prepare_sorting_fields()
        if self._sorting_fields:
            results = self.sort_results(results)

        if request.accepted_renderer.format == 'html':
            # Makes the the results available to the template context by transforming to a dict
            results = {'data': results}

        return results
488163
def format_results(self, rows):
        
        needs_utc = _DJANGO_VERSION >= 14 and settings.USE_TZ
        if not (needs_utc or not self.driver_supports_utf8):
            return tuple(rows)
        # FreeTDS (and other ODBC drivers?) don't support Unicode yet, so we
        # need to decode UTF-8 data coming from the DB
        fr = []
        for row in rows:
            if not self.driver_supports_utf8 and isinstance(row, binary_type):
                row = row.decode(self.encoding)

            elif needs_utc and isinstance(row, datetime.datetime):
                row = row.replace(tzinfo=timezone.utc)
            fr.append(row)
        return tuple(fr)
230440
def format_results(self, raw_data, options):
        '''
        
        '''
        page_data = self.paginate_results(raw_data, options)
        results = {}
        meta = options.copy()
        meta['more'] = _('Show more results')
        if page_data and page_data.has_next():
            meta['next_page'] = page_data.next_page_number()
        if page_data and page_data.has_previous():
            meta['prev_page'] = page_data.previous_page_number()
        results['data'] = [self.format_item(item) for item in page_data.object_list]
        results['meta'] = meta
        return results
196313
def _prepare_results(self, results):
        
        if self._instances:
            results = self._to_instances(results)
        else:
            results = list(results)

        # cache the len for future use
        self._len = len(results)

        return results