<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-

"""
Python library for the League of Legends official API
Copyright (c) 2013 <NAME> <<EMAIL>>

The LoL API belongs to Riot and can be found here:
https://developer.riotgames.com/

This product is not endorsed, certified or otherwis
approved in any way by Riot Games, Inc. or any of its affiliates.
"""

__author__ = '<NAME>'
__version__ = '0.1'

import urllib.request
import urllib.error
import json
import unicodedata
import re
import time

class LeagueOfLegends:

    API_BASE_URL = 'https://na.api.pvp.net/api/lol'
    api_version = '1.4'
    api_region = 'na'
    api_url = API_BASE_URL + '/' + api_region + '/' + 'v' + api_version + '/'

    def __init__(self, api_key):
        self.api_key = api_key
        self.request_times = [0, 0, 0, 0]

    def __webrequest(self, url):
        # print('Making request to: ' + url)
        try:
            # if we've made four calls in the last 10 seconds wait until we can make another request
            now = time.time()
            if now - self.request_times[0] < 10:
                time.sleep(min(10 - (now - self.request_times[0]), 10)) # limit waiting to 10 seconds in case system clock changes

            self.request_times[0] = self.request_times[1]
            self.request_times[1] = self.request_times[2]
            self.request_times[2] = self.request_times[3]
            self.request_times[3] = time.time()

            opener = urllib.request.build_opener(NotModifiedHandler())
            req = urllib.request.Request(url)

            url_handle = opener.open(req)

            headers = url_handle.info()
            response = url_handle.read()
<commit_msg>Increased the amount of API requests we will allow before throttling<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-

"""
Python library for the League of Legends official API
Copyright (c) 2013 <NAME> <<EMAIL>>

The LoL API belongs to Riot and can be found here:
https://developer.riotgames.com/

This product is not endorsed, certified or otherwis
approved in any way by Riot Games, Inc. or any of its affiliates.
"""

__author__ = '<NAME>'
__version__ = '0.1'

import urllib.request
import urllib.error
import json
import unicodedata
import re
import time

class LeagueOfLegends:

    API_BASE_URL = 'https://na.api.pvp.net/api/lol'
    api_version = '1.4'
    api_region = 'na'
    api_url = API_BASE_URL + '/' + api_region + '/' + 'v' + api_version + '/'
    max_calls_per_ten_seconds = 8

    def __init__(self, api_key):
        self.api_key = api_key
        self.request_times = []
        for i in range(self.max_calls_per_ten_seconds):
            self.request_times.append(0)

    def __webrequest(self, url):
        # print('Making request to: ' + url)
        try:
            # if we've made four calls in the last 10 seconds wait until we can make another request
            now = time.time()
            if now - self.request_times[0] < 10:
                time.sleep(min(10 - (now - self.request_times[0]), 10)) # limit waiting to 10 seconds in case system clock changes

            for i in range(self.max_calls_per_ten_seconds - 1):
                self.request_times[i] = self.request_times[i + 1]

            self.request_times[-1] = time.time()

            opener = urllib.request.build_opener(NotModifiedHandler())
            req = urllib.request.Request(url)

            url_handle = opener.open(req)

            headers = url_handle.info()
            response = url_handle.read()

{'fraction_non_alphanumeric': 0.10968660968660969, 'fraction_numerical': 0.016524216524216526, 'mean_word_length': 2.557244174265451, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5514194', 'n_tokens_mistral': 1168, 'n_tokens_neox': 1096, 'n_words': 319}