# Path: hotness/exceptions/notifier_exception.py
# class NotifierException(BaseHotnessException):
#     """
#     Class representing notifier exception.
#     This exception is raised by notifier
#     when it encounters error with external notifier system.
# 
#     Attributes:
#         message: Error message.
#     """
# 
#     def __init__(self, message: str) -> None:
#         """
#         Class constructor.
#         """
#         self.message = message
#         super(NotifierException, self).__init__(self.message)
# 
# Path: hotness/domain/package.py
# class Package:
#     """
#     Internal representation of package object.
# 
#     Attributes:
#         name (str): Name of the package
#         version (str): Latest version of the package
#         distro (str): Distribution assigned
#     """
# 
#     def __init__(self, name: str, version: str, distro: str) -> None:
#         """
#         Class constructor
#         """
#         self.name = name
#         self.version = version
#         self.distro = distro
# 
#     def to_dict(self) -> dict:
#         """
#         Convert object to dictionary.
# 
#         Return:
#             Dictionary created from package object.
#         """
#         return {"name": self.name, "version": self.version, "distro": self.distro}
# 
#     @classmethod
#     def from_dict(cls, package_dict: dict) -> object:
#         """
#         Convert dictionary to object.
# 
#         Params:
#             package_dict: Dictionary to create package from.
# 
#         Return:
#             Package object.
#         """
#         package = Package(
#             name=package_dict["name"],
#             version=package_dict["version"],
#             distro=package_dict["distro"],
#         )
#         return package
# 
#     def __eq__(self, other: object) -> bool:
#         """
#         Compare method for package object.
# 
#         Params:
#             other: object to compare with
# 
#         Return:
#             Compare result.
#         """
#         return self.to_dict() == other.to_dict()  # type: ignore
# 
# Path: hotness/notifiers/notifier.py
# class Notifier:
#     """
#     Abstract class for notifiers used by the-new-hotness to sent a notification.
#     This class must be inherited by every external notifier.
#     """
# 
#     def notify(self, package: Package, message: str, opts: dict) -> dict:
#         """
#         Notify method that should be implemented by every child class.
# 
#         It should sent notification using the external system and
#         return dictionary containing any related info.
# 
#         In case of any issue that would prevent sending a notification, method should
#         raise an exception.
# 
#         Params:
#            package: Package to notify about.
#            message: Message to sent.
#            opts: Additional options for specific notifier.
# 
#         Returns:
#            Dictionary containing output of the operation.
#         """
#         raise NotImplementedError


import logging
import bugzilla  # type: ignore
from hotness.exceptions import NotifierException
from hotness.domain.package import Package
from .notifier import Notifier
                    "bz_id": 100, # Bugzilla ticket id, if provided the
                                  # new message will be added as new comment to this ticket
                    "bz_short_desc": "test-1.0 is available" # Short description (title) to use
                                                             # when searching for the ticket
                                                             # If not found the new bug will be
                                                             # created with this short description
                                                             # containing `message`
                }

        Returns:
            Dictionary containing ticket bugzilla id
            Example:
            {
                "bz_id": 100
            }

        Raises:
            NotifierException: When the required `opts` parameters are missing.
        """
        output = {}
        bug_id = opts.get("bz_id", 0)
        short_desc = opts.get("bz_short_desc", "")
        # If bugzilla ticket id is provided, just follow up on the bug
        if not bug_id == 0:
            _logger.info("Bug id provided. Updating %s" % bug_id)
            self._update_bug(bug_id, message)
            output["bz_id"] = bug_id
            return output

        if not short_desc:

# Path: hotness/exceptions/notifier_exception.py
# class NotifierException(BaseHotnessException):
#     """
#     Class representing notifier exception.
#     This exception is raised by notifier
#     when it encounters error with external notifier system.
# 
#     Attributes:
#         message: Error message.
#     """
# 
#     def __init__(self, message: str) -> None:
#         """
#         Class constructor.
#         """
#         self.message = message
#         super(NotifierException, self).__init__(self.message)
# 
# Path: hotness/domain/package.py
# class Package:
#     """
#     Internal representation of package object.
# 
#     Attributes:
#         name (str): Name of the package
#         version (str): Latest version of the package
#         distro (str): Distribution assigned
#     """
# 
#     def __init__(self, name: str, version: str, distro: str) -> None:
#         """
#         Class constructor
#         """
#         self.name = name
#         self.version = version
#         self.distro = distro
# 
#     def to_dict(self) -> dict:
#         """
#         Convert object to dictionary.
# 
#         Return:
#             Dictionary created from package object.
#         """
#         return {"name": self.name, "version": self.version, "distro": self.distro}
# 
#     @classmethod
#     def from_dict(cls, package_dict: dict) -> object:
#         """
#         Convert dictionary to object.
# 
#         Params:
#             package_dict: Dictionary to create package from.
# 
#         Return:
#             Package object.
#         """
#         package = Package(
#             name=package_dict["name"],
#             version=package_dict["version"],
#             distro=package_dict["distro"],
#         )
#         return package
# 
#     def __eq__(self, other: object) -> bool:
#         """
#         Compare method for package object.
# 
#         Params:
#             other: object to compare with
# 
#         Return:
#             Compare result.
#         """
#         return self.to_dict() == other.to_dict()  # type: ignore
# 
# Path: hotness/notifiers/notifier.py
# class Notifier:
#     """
#     Abstract class for notifiers used by the-new-hotness to sent a notification.
#     This class must be inherited by every external notifier.
#     """
# 
#     def notify(self, package: Package, message: str, opts: dict) -> dict:
#         """
#         Notify method that should be implemented by every child class.
# 
#         It should sent notification using the external system and
#         return dictionary containing any related info.
# 
#         In case of any issue that would prevent sending a notification, method should
#         raise an exception.
# 
#         Params:
#            package: Package to notify about.
#            message: Message to sent.
#            opts: Additional options for specific notifier.
# 
#         Returns:
#            Dictionary containing output of the operation.
#         """
#         raise NotImplementedError


# Path: hotness/notifiers/bugzilla.py
import logging
import bugzilla  # type: ignore
from hotness.exceptions import NotifierException
from hotness.domain.package import Package
from .notifier import Notifier

                    "bz_id": 100, # Bugzilla ticket id, if provided the
                                  # new message will be added as new comment to this ticket
                    "bz_short_desc": "test-1.0 is available" # Short description (title) to use
                                                             # when searching for the ticket
                                                             # If not found the new bug will be
                                                             # created with this short description
                                                             # containing `message`
                }

        Returns:
            Dictionary containing ticket bugzilla id
            Example:
            {
                "bz_id": 100
            }

        Raises:
            NotifierException: When the required `opts` parameters are missing.
        """
        output = {}
        bug_id = opts.get("bz_id", 0)
        short_desc = opts.get("bz_short_desc", "")
        # If bugzilla ticket id is provided, just follow up on the bug
        if not bug_id == 0:
            _logger.info("Bug id provided. Updating %s" % bug_id)
            self._update_bug(bug_id, message)
            output["bz_id"] = bug_id
            return output

        if not short_desc:

            raise NotifierException(