<commit_before>__author__ = 'pp'


class ModelError(Exception):
    HTTP_STATUS_CODE = 500


class ModelNotFound(ModelError):
    HTTP_STATUS_CODE = 404


class ModelKeyExists(ModelError):
    HTTP_STATUS_CODE = 412


class ModelInvalidData(ModelError):
    HTTP_STATUS_CODE = 400


class Model(object):
    """The way to persist, (de)serialize objects
    """
    def from_primitive(self, primitive):
        """from primitive representation

        :param primitive: primitive python obj
        :returns: obj
        :raises ModelInvalidData: invalid primitive
        """
        raise NotImplementedError

    def from_str(self, serialized):
        """from string representation

        :param serialized: serialized obj
        :returns: obj
        :raises ModelInvalidData: invalid serialized
        """
        raise NotImplementedError

    def as_primitive(self, obj):
        """json-serializable python object

        :returns: literal-serialized obj
        :raises ModelInvalidData: invalid obj
        """
        raise NotImplementedError

    def as_str(self, obj):
        """to string representation

        :returns: string-serialized obj
        :raises ModelInvalidData: invalid obj
        """
        raise NotImplementedError

    def create(self, obj, namespace=None):
        """
        :returns: key, metadata
        :raises ModelInvalidData: invalid obj
        """
        raise NotImplementedError

    def put(self, obj, key, namespace=None, etag=None):
        """
        :returns: metadata
        :raises ModelInvalidData: invalid obj
        :raises ModelKeyExists: etag error
        """
        raise NotImplementedError

    def get(self, key, namespace=None):
        """
        :returns: obj, metadata
        :raises ModelNotFound: no such obj
        """
        raise NotImplementedError

    # def delete(self, key, namespace=None):
    #     raise NotImplementedError<commit_msg>add more doc in base<commit_after>__author__ = 'pp'


class ModelError(Exception):
    HTTP_STATUS_CODE = 500


class ModelNotFound(ModelError):
    HTTP_STATUS_CODE = 404


class ModelKeyExists(ModelError):
    HTTP_STATUS_CODE = 412


class ModelInvalidData(ModelError):
    HTTP_STATUS_CODE = 400


class Model(object):
    """The way to persist, (de)serialize objects
    """
    def from_primitive(self, primitive):
        """from primitive representation

        :param primitive: primitive python obj
        :returns: obj
        :raises ModelInvalidData: invalid primitive
        """
        raise NotImplementedError

    def from_str(self, serialized):
        """from string representation

        :param serialized: serialized obj
        :returns: obj
        :raises ModelInvalidData: invalid serialized
        """
        raise NotImplementedError

    def as_primitive(self, obj):
        """json-serializable python object

        :returns: literal-serialized obj
        :raises ModelInvalidData: invalid obj
        """
        raise NotImplementedError

    def as_str(self, obj):
        """to string representation

        :returns: string-serialized obj
        :raises ModelInvalidData: invalid obj
        """
        raise NotImplementedError

    def create(self, obj, namespace=None):
        """
        :arg namespace: storage namespace
        :returns: key, metadata
        :raises ModelInvalidData: invalid obj
        """
        raise NotImplementedError

    def put(self, obj, key, namespace=None, etag=None):
        """
        :arg key: storage key
        :arg namespace: storage namespace
        :arg etag: check etag consistency if provided
        :returns: metadata
        :raises ModelInvalidData: invalid obj
        :raises ModelKeyExists: etag error
        """
        raise NotImplementedError

    def get(self, key, namespace=None):
        """
        :arg key: storage key
        :arg namespace: storage namespace
        :returns: obj, metadata
        :raises ModelNotFound: no such obj
        """
        raise NotImplementedError

    # def delete(self, key, namespace=None):
    #     raise NotImplementedError
{'fraction_non_alphanumeric': 0.08060208788540908, 'fraction_numerical': 0.005826656955571741, 'mean_word_length': 2.4738617200674535, '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': '5356484', 'n_tokens_mistral': 1100, 'n_tokens_neox': 1041, 'n_words': 318}