

@cache
def search(query, results=10, suggestion=False):
    '\n  Do a Wikipedia search for `query`.\n\n  Keyword arguments:\n\n  * results - the maxmimum number of results returned\n  * suggestion - if True, return results and suggestion (if any) in a tuple\n  '
    search_params = {
        'list': 'search',
        'srprop': '',
        'srlimit': results,
        'limit': results,
        'srsearch': query,
    }
    if suggestion:
        search_params['srinfo'] = 'suggestion'
    raw_results = _wiki_request(search_params)
    if ('error' in raw_results):
        if (raw_results['error']['info'] in ('HTTP request timed out.', 'Pool queue is full')):
            raise HTTPTimeoutError(query)
        else:
            raise WikipediaException(raw_results['error']['info'])
    search_results = (d['title'] for d in raw_results['query']['search'])
    if suggestion:
        if raw_results['query'].get('searchinfo'):
            return (list(search_results), raw_results['query']['searchinfo']['suggestion'])
        else:
            return (list(search_results), None)
    return list(search_results)

dataset/ETHPy150Open goldsmith/Wikipedia/wikipedia/wikipedia.py search/original