<commit_before>"""
Base utilities to build API operation managers and objects on top of.
"""
class Manager(object):
    """
    Managers interact with a particular type of resource and provide CRUD
    operations for them.
    """
    resource_class = None
    
    def __init__(self, api):
        self.api = api

    def _list(self, url, response_key=None):
        resp, body = self.api.client.get(url)
        if body:
            if response_key: 
                body = (res[response_key] for res in body)
            return [self.resource_class(self, res) for res in body]
        return body
    
    def _get(self, url, response_key=None):
        resp, body = self.api.client.get(url)
        if response_key:
            return self.resource_class(self, body[response_key])
        else:
            return self.resource_class(self, self.body)
    
    def _create(self, url, body, response_key=None):
        resp, body = self.api.client.post(url, body=body)
        if response_key:
            return self.resource_class(self, body[response_key])
        else:
            return self.resource_class(self, self.body)
        
    def _delete(self, url):
        resp, body = self.api.client.delete(url)
    
    def _update(self, url, body):
        resp, body = self.api.client.put(url, body=body)
                    
class Resource(object):
    """
    A resource represents a particular instance of a resource.
    <commit_msg>Fixed a typo in base.py.<commit_after>"""
Base utilities to build API operation managers and objects on top of.
"""
class Manager(object):
    """
    Managers interact with a particular type of resource and provide CRUD
    operations for them.
    """
    resource_class = None
    
    def __init__(self, api):
        self.api = api

    def _list(self, url, response_key=None):
        resp, body = self.api.client.get(url)
        if body:
            if response_key: 
                body = (res[response_key] for res in body)
            return [self.resource_class(self, res) for res in body]
        return body
    
    def _get(self, url, response_key=None):
        resp, body = self.api.client.get(url)
        if response_key:
            return self.resource_class(self, body[response_key])
        else:
            return self.resource_class(self, body)
    
    def _create(self, url, body, response_key=None):
        resp, body = self.api.client.post(url, body=body)
        if response_key:
            return self.resource_class(self, body[response_key])
        else:
            return self.resource_class(self, body)
        
    def _delete(self, url):
        resp, body = self.api.client.delete(url)
    
    def _update(self, url, body):
        resp, body = self.api.client.put(url, body=body)
                    
class Resource(object):
    """
    A resource represents a particular instance of a resource.
    
{'fraction_non_alphanumeric': 0.09685230024213075, 'fraction_numerical': 0.0, 'mean_word_length': 2.188533627342889, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2806271', 'n_tokens_mistral': 842, 'n_tokens_neox': 831, 'n_words': 246}