<commit_before>#!/usr/bin/env python
#
# Copyright 2016 Opsview Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


class EMSException(Exception):
    """
    Base exception.
    """
    pass


class SchemaException(EMSException):
    """
    Exceptions pertaining to schema definitions.
    """
    pass


class ValidationException(EMSException):
    """
    Exceptions pertaining to validation of values as per their given schemas.
    """
    pass


class RestrictionException(ValidationException):
    """
    Exceptions pertaining to user-defined restrictons for field values.
    """
    pass


class XMLException(EMSException):
    """
    Exceptions pertaining to parsing of XML into objects.
    """
    pass


class EMSAPIException(EMSException):
    """
    Exceptions pertaining to the Sentinel EMS API.
    """
    def __init__(self, ems_error):
        self.code = ems_error.code
        self.description = ems_error.description

        message = "[%d] %s" % (ems_error.code, ems_error.description)
        super(EMSException, self).__init__(message)


api_exceptions = {}


def register_api_exception(cls):
    api_exceptions[cls.error_code] = cls<commit_msg>Allow to create api exception from tuple<commit_after>#!/usr/bin/env python
#
# Copyright 2016 Opsview Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


class EMSException(Exception):
    """
    Base exception.
    """
    pass


class SchemaException(EMSException):
    """
    Exceptions pertaining to schema definitions.
    """
    pass


class ValidationException(EMSException):
    """
    Exceptions pertaining to validation of values as per their given schemas.
    """
    pass


class RestrictionException(ValidationException):
    """
    Exceptions pertaining to user-defined restrictons for field values.
    """
    pass


class XMLException(EMSException):
    """
    Exceptions pertaining to parsing of XML into objects.
    """
    pass


class EMSAPIException(EMSException):
    """
    Exceptions pertaining to the Sentinel EMS API.
    """
    def __init__(self, ems_error):
        if isinstance(ems_error, tuple):
            self.code = ems_error[0]
            self.description = ems_error[1]
        else:
            self.code = ems_error.code
            self.description = ems_error.description

        message = "[%d] %s" % (ems_error.code, ems_error.description)
        super(EMSException, self).__init__(message)


api_exceptions = {}


def register_api_exception(cls):
    api_exceptions[cls.error_code] = cls
{'fraction_non_alphanumeric': 0.08714164064717571, 'fraction_numerical': 0.00510928186204939, 'mean_word_length': 3.292326431181486, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1729086', 'n_tokens_mistral': 1000, 'n_tokens_neox': 947, 'n_words': 335}