# Path: lib/exception.py
# class BaseException(Exception):
# class RequiredParameterMissing(BaseException):
# class DistributionError(BaseException):
# class DistributionDetectionError(DistributionError):
# class DistributionNotSupportedError(DistributionError):
# class DistributionVersionNotSupportedError(DistributionError):
# class PackageError(BaseException):
# class PackageSpecError(PackageError):
# class PackageDescriptorError(PackageError):
# class PackageDirectoryIsEmpty(PackageError):
# class RepositoryError(BaseException):
# class SubprocessError(BaseException):
# class TimeoutError(BaseException):
# class FilesToValidateNotFound(BaseException):
# class NoPackagesUpdated(BaseException):
#     DEFAULT_MESSAGE = "Failed to build packages"
#     DEFAULT_MESSAGE = "Required parameter '%(parameter)s' is missing"
#     DEFAULT_MESSAGE = "Distribution not Supported"
#     DEFAULT_MESSAGE = "Failed to detect system's GNU/Linux distribution"
#     DEFAULT_MESSAGE = "%(distribution)s distribution is not supported"
#     DEFAULT_MESSAGE = "%(distribution)s version %(version)s is not supported"
#     DEFAULT_MESSAGE = "Failed to gather %(package)s's information"
#     DEFAULT_MESSAGE = (
#         "%(package)s's spec for %(distro)s %(distro_version)s not Found.")
#     DEFAULT_MESSAGE = "Missing data in %(package)s's YAML descriptor"
#     DEFAULT_MESSAGE = "No packages to build. Packages directory is empty."
#     DEFAULT_MESSAGE = (
#         "Failed to setup %(repo_name)s's repository at %(repo_path)s.")
#     DEFAULT_MESSAGE = (
#         "%(cmd)s returned non-zero exit code: ret:%(returncode)i, "
#         "stdout: %(stdout)s, stderr: %(stderr)s")
#     DEFAULT_MESSAGE = (
#         "Timeout failure on %(func_name)s after %(num_attempts)s attempts. "
#         "Initial timeout: %(initial_timeout)s, final timeout: "
#         "%(final_timeout)s.")
#     DEFAULT_MESSAGE = (
#         "Files to be validated not found in base directory.")
#     DEFAULT_MESSAGE = (
#         "No packages were updated since last commit.")
#     def __init__(self, message=None, **kwargs):


import abc
import logging
from lib import exception
class LinuxDistribution(object):
    __metaclass__ = abc.ABCMeta
    supported_versions = []

    def __init__(self, name=None, version=None, architecture=None):
        """
        Constructor

        Args:
            name (str): distribution name
            version (str): distribution version
            architecture (str): distribution architecture codename
                (e.g. ppc64le)

        Raises:
            exception.DistributionVersionNotSupportedError: unsupported
                distribution
        """
        self.name = name
        self.architecture = architecture
        if architecture.lower() not in SUPPORTED_ARCHITECTURES:
            raise exception.DistributionVersionNotSupportedError(
                msg="Architecture not supported: %s" % architecture)

        # NOTE(maurosr): to support multiple builds of a same version
        for supported_version in self.supported_versions:
            if version.startswith(supported_version):
                self.version = supported_version
                break
        else:

# Path: lib/exception.py
# class BaseException(Exception):
# class RequiredParameterMissing(BaseException):
# class DistributionError(BaseException):
# class DistributionDetectionError(DistributionError):
# class DistributionNotSupportedError(DistributionError):
# class DistributionVersionNotSupportedError(DistributionError):
# class PackageError(BaseException):
# class PackageSpecError(PackageError):
# class PackageDescriptorError(PackageError):
# class PackageDirectoryIsEmpty(PackageError):
# class RepositoryError(BaseException):
# class SubprocessError(BaseException):
# class TimeoutError(BaseException):
# class FilesToValidateNotFound(BaseException):
# class NoPackagesUpdated(BaseException):
#     DEFAULT_MESSAGE = "Failed to build packages"
#     DEFAULT_MESSAGE = "Required parameter '%(parameter)s' is missing"
#     DEFAULT_MESSAGE = "Distribution not Supported"
#     DEFAULT_MESSAGE = "Failed to detect system's GNU/Linux distribution"
#     DEFAULT_MESSAGE = "%(distribution)s distribution is not supported"
#     DEFAULT_MESSAGE = "%(distribution)s version %(version)s is not supported"
#     DEFAULT_MESSAGE = "Failed to gather %(package)s's information"
#     DEFAULT_MESSAGE = (
#         "%(package)s's spec for %(distro)s %(distro_version)s not Found.")
#     DEFAULT_MESSAGE = "Missing data in %(package)s's YAML descriptor"
#     DEFAULT_MESSAGE = "No packages to build. Packages directory is empty."
#     DEFAULT_MESSAGE = (
#         "Failed to setup %(repo_name)s's repository at %(repo_path)s.")
#     DEFAULT_MESSAGE = (
#         "%(cmd)s returned non-zero exit code: ret:%(returncode)i, "
#         "stdout: %(stdout)s, stderr: %(stderr)s")
#     DEFAULT_MESSAGE = (
#         "Timeout failure on %(func_name)s after %(num_attempts)s attempts. "
#         "Initial timeout: %(initial_timeout)s, final timeout: "
#         "%(final_timeout)s.")
#     DEFAULT_MESSAGE = (
#         "Files to be validated not found in base directory.")
#     DEFAULT_MESSAGE = (
#         "No packages were updated since last commit.")
#     def __init__(self, message=None, **kwargs):


# Path: lib/distro.py
import abc
import logging
from lib import exception

class LinuxDistribution(object):
    __metaclass__ = abc.ABCMeta
    supported_versions = []

    def __init__(self, name=None, version=None, architecture=None):
        """
        Constructor

        Args:
            name (str): distribution name
            version (str): distribution version
            architecture (str): distribution architecture codename
                (e.g. ppc64le)

        Raises:
            exception.DistributionVersionNotSupportedError: unsupported
                distribution
        """
        self.name = name
        self.architecture = architecture
        if architecture.lower() not in SUPPORTED_ARCHITECTURES:
            raise exception.DistributionVersionNotSupportedError(
                msg="Architecture not supported: %s" % architecture)

        # NOTE(maurosr): to support multiple builds of a same version
        for supported_version in self.supported_versions:
            if version.startswith(supported_version):
                self.version = supported_version
                break
        else:

            raise exception.DistributionVersionNotSupportedError(