

def _wiki_request(params):
    '\n  Make a request to the Wikipedia API using the given search parameters.\n  Returns a parsed dict of the JSON response.\n  '
    global RATE_LIMIT_LAST_CALL
    global USER_AGENT
    params['format'] = 'json'
    if (not ('action' in params)):
        params['action'] = 'query'
    headers = {
        'User-Agent': USER_AGENT,
    }
    if (RATE_LIMIT and RATE_LIMIT_LAST_CALL and ((RATE_LIMIT_LAST_CALL + RATE_LIMIT_MIN_WAIT) > datetime.now())):
        wait_time = ((RATE_LIMIT_LAST_CALL + RATE_LIMIT_MIN_WAIT) - datetime.now())
        time.sleep(int(wait_time.total_seconds()))
    r = requests.get(API_URL, params=params, headers=headers)
    if RATE_LIMIT:
        RATE_LIMIT_LAST_CALL = datetime.now()
    return r.json()

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