<commit_before># -*- coding: utf-8 -*-


class BaseManager(object):
    """
        Base class for database managers
    """
    __model__ = None

    def __init__(self, session):
        self.session = session

    def get(self, item_id):
        """
            Get object by id
        """
        return self.session.query(self.__model__).get(item_id)

    def from_dict(self, d):
        """
            Create new instance with properties set from dict
        """
        obj = self.__model__(**d)
        self.session.add(obj)
        self.session.flush()
        return obj

    def all(self):
        """
            Return all entities
        """
        return self.session.query(self.__model__).all()

    def find(self, **kwargs):
        """
            Returns a list of instances of the service's model filtered by the
            specified key word arguments.
        """
        return self.session.query(self.__model__).filter_by(**kwargs)

    def get_or_insert(self, **kwargs):
        """
            Find and return first entry or create a new one
        """
        entry = self.find(**kwargs).first()
        if not entry:
            entry = self.from_dict(kwargs)

        return entry

    def delete(self, entry):
        """
            Delete entry from db
        """
        self.session.delete(entry)

    def delete_by_id(self, pk):
        """
            Delete entry by id
        """
        entry = self.get(pk)
        self.delete(entry)
<commit_msg>Delete all method<commit_after># -*- coding: utf-8 -*-


class BaseManager(object):
    """
        Base class for database managers
    """
    __model__ = None

    def __init__(self, session):
        self.session = session

    def get(self, item_id):
        """
            Get object by id
        """
        return self.session.query(self.__model__).get(item_id)

    def from_dict(self, d):
        """
            Create new instance with properties set from _values
        """
        obj = self.__model__(**d)
        self.session.add(obj)
        self.session.flush()
        return obj

    def all(self):
        """
            Return all entities
        """
        return self.session.query(self.__model__).all()

    def find(self, **kwargs):
        """
            Returns a list of instances of the service's model filtered by the
            specified key word arguments.
        """
        return self.session.query(self.__model__).filter_by(**kwargs)

    def get_or_insert(self, **kwargs):
        """
            Find and return first entry or create a new one
        """
        entry = self.find(**kwargs).first()
        if not entry:
            entry = self.from_dict(kwargs)

        return entry

    def delete(self, entry):
        """
            Delete entry from db
        """
        self.session.delete(entry)

    def delete_by_id(self, pk):
        """
            Delete entry by id
        """
        entry = self.get(pk)
        self.delete(entry)

    def delete_all(self):
        """
            Delete all records from table
        """
        return self.session.query(self.__model__).delete()

{'fraction_non_alphanumeric': 0.11217032094057833, 'fraction_numerical': 0.0006355258976803305, 'mean_word_length': 1.6655376799322608, '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': '6860083', 'n_tokens_mistral': 865, 'n_tokens_neox': 837, 'n_words': 233}