<commit_before># -*- coding: utf-8 -*-
'''
    IntelMQ Exception Class
'''
import traceback

__all__ = ['InvalidArgument', 'ConfigurationError', 'IntelMQException',
           'IntelMQHarmonizationException', 'InvalidKey', 'InvalidValue',
           'KeyExists', 'KeyNotExists', 'PipelineError',
           'MissingDependencyError',
           ]


class IntelMQException(Exception):

    def __init__(self, message):
        super().__init__(message)


'''
    IntelMQ Exception SubClasses
'''


class InvalidArgument(IntelMQException):

    def __init__(self, argument, got=None, expected=None, docs=None):
        message = "Argument {} is invalid.".format(repr(argument))
        if expected is list:
            message += " Should be one of: {}.".format(list)
        elif expected:  # not None
            message += " Should be of type: {}.".format(expected)
        if got:
            message += " Got {}.".format(repr(got))
        if docs:
            message += " For more information see {}".format(docs)
        super().__init__(message)


class PipelineError(IntelMQException):

    def __init__(self, argument):
        if type(argument) is type and issubclass(argument, Exception):
            message = "pipeline failed - %s" % traceback.format_exc(argument)
        else:
            message = "pipeline failed - %s" % repr(argument)
        super().__init__(message)


class ConfigurationError(IntelMQException):

    def __init__(self, config, argument):
        message = "%s configuration failed - %s" % (config, argument)
        super().__init__(message)


class PipelineFactoryError(IntelMQException):
    pass


'''
    IntelMQ Harmonization Exception Class
'''


class IntelMQHarmonizationException(IntelMQException):

    def __init__(self, message):
        super().__init__(message)


'''
    IntelMQ Harmonization Exception sub classes
'''


class InvalidValue(IntelMQHarmonizationException):

    def __init__(self, key, value, reason=None):
        message = ("invalid value {value!r} ({type}) for key {key!r}{reason}"
                   "".format(value=value, type=type(value), key=key,
                             reason=': ' + reason if reason else ''))
        super().__init__(message)


class InvalidKey(IntelMQHarmonizationException):

    def __init__(self, key):
        message = "invalid key %s" % repr(key)
        super().__init__(message)


class KeyExists(IntelMQHarmonizationException):

    def __init__(self, key):
        message = "key %s already exists" % repr(key)
        super().__init__(message)


class KeyNotExists(IntelMQHarmonizationException):

    def __init__(self, key):
        message = "key %s not exists" % repr(key)
        super().__init__(message)


class MissingDependencyError(IntelMQException):
    """
    A missing dependency was detected. Log instructions on installation.
    """
    def __init__(self, dependency):
        message = ("Could not load dependency {dependency!r}, please install it "
                   "with apt/yum/dnf/zypper (possibly named "
                   "python3-{dependency}) or pip3."
                   "".format(dependency=dependency))
        super().__init__(message)<commit_msg>ENH: lib/exceptions: MissingDependencyError: version<commit_after># -*- coding: utf-8 -*-
'''
    IntelMQ Exception Class
'''
import traceback

__all__ = ['InvalidArgument', 'ConfigurationError', 'IntelMQException',
           'IntelMQHarmonizationException', 'InvalidKey', 'InvalidValue',
           'KeyExists', 'KeyNotExists', 'PipelineError',
           'MissingDependencyError',
           ]


class IntelMQException(Exception):

    def __init__(self, message):
        super().__init__(message)


'''
    IntelMQ Exception SubClasses
'''


class InvalidArgument(IntelMQException):

    def __init__(self, argument, got=None, expected=None, docs=None):
        message = "Argument {} is invalid.".format(repr(argument))
        if expected is list:
            message += " Should be one of: {}.".format(list)
        elif expected:  # not None
            message += " Should be of type: {}.".format(expected)
        if got:
            message += " Got {}.".format(repr(got))
        if docs:
            message += " For more information see {}".format(docs)
        super().__init__(message)


class PipelineError(IntelMQException):

    def __init__(self, argument):
        if type(argument) is type and issubclass(argument, Exception):
            message = "pipeline failed - %s" % traceback.format_exc(argument)
        else:
            message = "pipeline failed - %s" % repr(argument)
        super().__init__(message)


class ConfigurationError(IntelMQException):

    def __init__(self, config, argument):
        message = "%s configuration failed - %s" % (config, argument)
        super().__init__(message)


class PipelineFactoryError(IntelMQException):
    pass


'''
    IntelMQ Harmonization Exception Class
'''


class IntelMQHarmonizationException(IntelMQException):

    def __init__(self, message):
        super().__init__(message)


'''
    IntelMQ Harmonization Exception sub classes
'''


class InvalidValue(IntelMQHarmonizationException):

    def __init__(self, key, value, reason=None):
        message = ("invalid value {value!r} ({type}) for key {key!r}{reason}"
                   "".format(value=value, type=type(value), key=key,
                             reason=': ' + reason if reason else ''))
        super().__init__(message)


class InvalidKey(IntelMQHarmonizationException):

    def __init__(self, key):
        message = "invalid key %s" % repr(key)
        super().__init__(message)


class KeyExists(IntelMQHarmonizationException):

    def __init__(self, key):
        message = "key %s already exists" % repr(key)
        super().__init__(message)


class KeyNotExists(IntelMQHarmonizationException):

    def __init__(self, key):
        message = "key %s not exists" % repr(key)
        super().__init__(message)


class MissingDependencyError(IntelMQException):
    """
    A missing dependency was detected. Log instructions on installation.
    """
    def __init__(self, dependency, version=None):
        appendix = ""
        if version:
            appendix = (" Please note that this bot requires "
                        "{dependency} {version}!".format(dependency=dependency,
                                                         version=version))
        message = ("Could not load dependency {dependency!r}, please install it "
                   "with apt/yum/dnf/zypper (possibly named "
                   "python3-{dependency}) or pip3.{appendix}"
                   "".format(dependency=dependency,
                             appendix=appendix))
        super().__init__(message)
{'fraction_non_alphanumeric': 0.11991117690599556, 'fraction_numerical': 0.0008882309400444115, 'mean_word_length': 2.745011086474501, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2818361', 'n_tokens_mistral': 1922, 'n_tokens_neox': 1805, 'n_words': 459}