<commit_before>#!/usr/bin/env python
# coding: utf-8

"""
Exception classes used in smtplibaio package.
"""


class SMTPException(Exception):
    """
    Base class for all exceptions.
    """
    default_message = ""

    def __init__(self, message=None):
        """
        """
        m = self.__class__.default_message

        if message is not None:
            m = "{0} ({1})".format(m, message)

        self.message = m


class SMTPResponseException(SMTPException):
    """
    Base class for all exceptions that include an SMTP error code.

    Raised when the SMTP server returns an error code.

    The error code is stored in `code`.
    The error message is stored in `message`.
    """
    def __init__(self, code, message=None):
        """
        """
        super().__init__(message)
        self.code = code


class SMTPCommandNotSupportedError(SMTPResponseException):
    """
    Raised when the server refuses a command we sent.
    """
    default_message = "Command not supported by the server."


class SMTPSenderRefusedError(SMTPResponseException):
    """
    Raised when the server refuses the sender address.

    In addition to the attributes set by on all `SMTPResponseException`,
    this sets `sender` to the string that the SMTP refused.
    """
    default_message = "Sender refused by the server."

    def __init__(self, sender, code, message=None):
        """
        """
        super().__init__(code, message)
        self.sender = sender


class SMTPRecipientRefusedError(SMTPResponseException):
    """
    Raised when the server refuses a recipient address.

    In addition to the attributes set by on all `SMTPResponseException`,
    this sets `recipient` to the string that the SMTP server refused.
    """
    default_message = "Recipient refused by the server."

    def __init__(self, recipient, code, message=None):
        """
        """
        super().__init__(code, message)
        self.recipient = recipient


class SMTPAllRecipientsRefusedError(SMTPException):
    """
    Raised when the server refuses all recipients addresses.

    Simply wraps a list of `SMTPRecipientRefusedError` exceptions.
    """
    def __init__(self, excs):
        """
        """
        self.recipients = excs


class SMTPDataRefusedError(SMTPResponseException):
    """
    Raised when the server refuses our DATA content.
    """
    default_message = "DATA refused by the server."


class SMTPHelloRefusedError(SMTPResponseException):
    """
    Raised when the server refuses our HELO/EHLO greeting.
    """
    default_message = "HELO or EHLO refused by the server."


class SMTPAuthenticationError(SMTPResponseException):
    """
    Raised when the server rejects our authentication attempt.
    """
    default_message = "Authentication failed."<commit_msg>Fixed docstrings in the exceptions module.<commit_after>#!/usr/bin/env python
# coding: utf-8

"""
Exception classes used in smtplibaio package.
"""


class SMTPException(Exception):
    """
    Base class for all exceptions related to smtplibaio.

    Attributes:
        message (str): Exception message, ideally providing help for the user.

    Class attributes:
        default_message (str): Generic exception message.

    .. note:: You SHOULD NOT use this class directly. Instead, you should
        subclass it or use one of the existing subclasses provided in this
        module.
    """
    default_message = ""

    def __init__(self, message=None):
        """
        Initializes a new instance of SMTPException.

        If ``message`` is given (not *None*), it is appended to the subclass
        ``default_message`.
        The ``default_message`` should give a general clue about what's
        going on.
        The ``message`` should give more details about the exception.

        .. note:: You SHOULD NOT use this class directly. Instead, you should
            subclass it or use one of the existing subclasses provided in this
            module.
        """
        m = self.__class__.default_message

        if message is not None:
            m = "{0} ({1})".format(m, message)

        self.message = m

    def __str__(self):
        """
        """
        return self.message

class SMTPAllRecipientsRefusedError(SMTPException):
    """
    Raised when the server refuses all recipients addresses.

    Attributes:
        exceptions (list of :obj:`SMTPRecipientRefusedError`): List of
            exceptions that were raised and that conducted to this exception
            being raised.

    Inherited attributes:
        message (str): Exception message, ideally providing help for the user.

    Inherited class attributes:
        default_message (str): Generic exception message.

    .. seealso:: :meth:`sendmail` source code.
    """
    def __init__(self, excs):
        """
        Initializes a new instance of SMTPAllRecipientsRefusedError.

        Args:
            excs (list of :obj:`SMTPRecipientRefusedError`): List of
                exceptions that were raised and that conducted to this
                exception being raised.
        """
        self.exceptions = excs

    def __str__(self):
        """
        """
        return "\n".join(self.exceptions)

class SMTPResponseException(SMTPException):
    """
    Base class for all exceptions that include an SMTP error code.

    Inherited attributes:
        message (str): Exception message, ideally providing help for the user.
        code (int): Error code returned by the SMTP server.

    Inherited class attributes:
        default_message (str): Generic exception message.
    """
    def __init__(self, code, message=None):
        """
        Initializes a new instance of SMTPReponseException.

        Args:
            code (int): Error code returned by the SMTP server.
            message (str): Exception message, ideally providing help for the
                user.
        """
        super().__init__(message)
        self.code = code

    def __str__(self):
        """
        """
        return "{} (Returned code was: {})".format(self.message, self.code)

class SMTPCommandNotSupportedError(SMTPResponseException):
    """
    Raised when the server refuses a command we sent.

    Inherited attributes:
        message (str): Exception message, ideally providing help for the user.
        code (int): Error code returned by the SMTP server.

    Inherited class attributes:
        default_message (str): Generic exception message.
    """
    default_message = "Command not supported by the server."


class SMTPSenderRefusedError(SMTPResponseException):
    """
    Raised when the server refuses the sender address.

    Attributes:
        sender (str): Sender address that is refused.

    Inherited attributes:
        message (str): Exception message, ideally providing help for the user.
        code (int): Error code returned by the SMTP server.

    Inherited class attributes:
        default_message (str): Generic exception message.
    """
    default_message = "Sender refused by the server."

    def __init__(self, sender, code, message=None):
        """
        Initializes a new instance of SMTPSenderRefusedError.

        Args:
            sender (str): Sender e-mail address that was refused.
            code (int): Error code returned by the SMTP server.
            message (str): Exception message, ideally providing help for the
                user.
        """
        super().__init__(code, message)
        self.sender = sender

    def __str__(self):
        """
        """
        return "Sender <{}>: {}".format(self.sender, self.message)

class SMTPRecipientRefusedError(SMTPResponseException):
    """
    Raised when the server refuses a recipient address.

    Attributes:
        recipient (str): Recipient address that is refused.

    Inherited attributes:
        message (str): Exception message, ideally providing help for the user.
        code (int): Error code returned by the SMTP server.

    Inherited class attributes:
        default_message (str): Generic exception message.
    """
    default_message = "Recipient refused by the server."

    def __init__(self, recipient, code, message=None):
        """
        Initializes a new instance of SMTPRecipientRefusedError.

        Args:
            recipient (str): Recipient e-mail address that was refused.
            code (int): Error code returned by the SMTP server.
            message (str): Exception message, ideally providing help for the
                user.

        """
        super().__init__(code, message)
        self.recipient = recipient

    def __str__(self):
        """
        """
        return "Recipient <{}>: {}".format(self.recipient, self.message)

class SMTPDataRefusedError(SMTPResponseException):
    """
    Raised when the server refuses our DATA content.

    Inherited attributes:
        message (str): Exception message, ideally providing help for the user.
        code (int): Error code returned by the SMTP server.

    Inherited class attributes:
        default_message (str): Generic exception message.
   """
    default_message = "DATA refused by the server."


class SMTPHelloRefusedError(SMTPResponseException):
    """
    Raised when the server refuses our HELO/EHLO greeting.

    Inherited attributes:
        message (str): Exception message, ideally providing help for the user.
        code (int): Error code returned by the SMTP server.

    Inherited class attributes:
        default_message (str): Generic exception message.
   """
    default_message = "HELO or EHLO refused by the server."


class SMTPAuthenticationError(SMTPResponseException):
    """
    Raised when the server rejects our authentication attempt.

    Inherited attributes:
        message (str): Exception message, ideally providing help for the user.
        code (int): Error code returned by the SMTP server.

    Inherited class attributes:
        default_message (str): Generic exception message.
   """
    default_message = "Authentication failed."
{'fraction_non_alphanumeric': 0.08425455631909172, 'fraction_numerical': 0.0005975500448162533, 'mean_word_length': 2.578759800427655, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5779925', 'n_tokens_mistral': 2660, 'n_tokens_neox': 2542, 'n_words': 960}