<commit_before>import time
import requests

retryCount = 5

class Base(object):
    """The base class for oxford API clients"""

    def __init__(self, key):
        """Initializes a new instance of the class.
        Args:
            key (str). the API key to use for this client.
        """
        if key and isinstance(key, str):
            self.key = key
        else:
            raise Exception('Key is required but a string was not provided')

    def _invoke(self, invocation, retries=0):
        """Attempt to invoke the a call to oxford. If the call is trottled, retry.
        Args:
            invocation (lambda). The oxford call to issue, should return an http response
            retries (int). The number of times this call has been retried.
        """
        response = invocation()
        if response.status_code == 429: # throttling response code
            if retries <= retryCount:
                delay = int(response.headers['retry-after'])
                print 'The projectoxford API was throttled. Retrying after {0} seconds.'.format(str(delay))
                time.sleep(delay)
                return Base._invoke(self, invocation, retries + 1)
            else:
                raise Exception('retry count ({0}) exceeded: {1}'.format(str(retryCount), response.text))
        elif response.status_code == 200 or response.status_code == 201:
            result = response # return the raw response if an unexpected content type is returned
            if 'content-length' in response.headers and int(response.headers['content-length']) == 0:
                result = None
            elif 'content-type' in response.headers and isinstance(response.headers['content-type'], str):<commit_msg>remove throttling logging due to incompatibility with python 3.4<commit_after>import time
import requests

retryCount = 5

class Base(object):
    """The base class for oxford API clients"""

    def __init__(self, key):
        """Initializes a new instance of the class.
        Args:
            key (str). the API key to use for this client.
        """
        if key and isinstance(key, str):
            self.key = key
        else:
            raise Exception('Key is required but a string was not provided')

    def _invoke(self, invocation, retries=0):
        """Attempt to invoke the a call to oxford. If the call is trottled, retry.
        Args:
            invocation (lambda). The oxford call to issue, should return an http response
            retries (int). The number of times this call has been retried.
        """
        response = invocation()
        if response.status_code == 429: # throttling response code
            if retries <= retryCount:
                delay = int(response.headers['retry-after'])
                time.sleep(delay)
                return Base._invoke(self, invocation, retries + 1)
            else:
                raise Exception('retry count ({0}) exceeded: {1}'.format(str(retryCount), response.text))
        elif response.status_code == 200 or response.status_code == 201:
            result = response # return the raw response if an unexpected content type is returned
            if 'content-length' in response.headers and int(response.headers['content-length']) == 0:
                result = None
            elif 'content-type' in response.headers and isinstance(response.headers['content-type'], str):
{'fraction_non_alphanumeric': 0.09243450103032087, 'fraction_numerical': 0.00971445392993818, 'mean_word_length': 2.2516746411483255, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '197258', 'n_tokens_mistral': 882, 'n_tokens_neox': 835, 'n_words': 333}