<commit_before>import requests, sys, logging
from .errors import *
from requests.packages.urllib3.util.retry import Retry
'''
'''

__version__ = '0.0.1'


class APIEndpoint(object):
    '''
    APIEndpoint is the base model for which all API endpoint classes are
    sired from.  The main benefit is the addition of the ``_check()``
    function from which it's possible to check the type & content of a
    variable to ensure that we are passing good data to the API.

    Args:
        api (APISession): 
            The APISession (or sired child) instance that the endpoint will
            be using to perform calls to the API.
    '''

    def __init__(self, api):
        self._api = api

    def _check(self, name, obj, expected_type, 
               choices=None, default=None, case=None):<commit_msg>Generic APIResultsIterator for subclassing<commit_after>import requests, sys, logging
from .errors import *
from requests.packages.urllib3.util.retry import Retry
'''
'''

__version__ = '0.0.1'


class APIResultsIterator(object):
    '''
    The agents iterator provides a scalable way to work through agent result
    sets of any size.  The iterator will walk through each page of data,
    returning one record at a time.  If it reaches the end of a page of
    records, then it will request the next page of information and then continue
    to return records from the next page (and the next, and the next) until the
    counter reaches the total number of records that the API has reported.

    Attributes:
        count (int): The current number of records that have been returned
        page (list): 
            The current page of data being walked through.  pages will be
            cycled through as the iterator requests more information from the
            API.
        page_count (int): The number of record returned from the current page.
        total (int): 
            The total number of records that exist for the current request.
    '''
    count = 0
    page_count = 0
    total = 0
    page = []

    # The API will be grafted on here.
    _api = None

    # The page size limit
    _limit = None

    # The current record offset
    _offset = None

    # The number of pages that may be requested before bailing.  If set to
    # None, then there is no limitation to the number of pages that may be
    # requested.
    _pages_total = None
    _pages_requested = 0

    def __init__(self, api, **kw):
        self._api = api
        self.__dict__.update(kw)
        self._get_page()

    def _get_page(self):
        pass

    def __iter__(self):
        return self

    def __next__(self):
        return self.next()

    def next(self):
        '''
        Ask for the next Agent record
        '''
        # If there are no more agent records to return, then we should raise
        # a StopIteration exception to end the madness.
        if self.count >= self.total:
            raise StopIteration()

        # If we have worked through the current page of records and we still
        # haven't hit to the total number of available records, then we should
        # query the next page of records.
        elif self.page_count >= len(self.page) and self.count <= self.total:
            self._get_page()

        # Get the relevant record, increment the counters, and return the
        # record.
        else:
            item = self.page[self.page_count]
            self.count += 1
            self.page_count += 1
            return item


class APIEndpoint(object):
    '''
    APIEndpoint is the base model for which all API endpoint classes are
    sired from.  The main benefit is the addition of the ``_check()``
    function from which it's possible to check the type & content of a
    variable to ensure that we are passing good data to the API.

    Args:
        api (APISession): 
            The APISession (or sired child) instance that the endpoint will
            be using to perform calls to the API.
    '''

    def __init__(self, api):
        self._api = api

    def _check(self, name, obj, expected_type, 
               choices=None, default=None, case=None):
{'fraction_non_alphanumeric': 0.06579583938074504, 'fraction_numerical': 0.003386550556361877, 'mean_word_length': 2.3159582999198074, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, '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': '3776795', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1070, 'n_words': 506}