# Path: lib/config.py
# RAW_TEXT_ID = "R|"
# CONFIG_METADATA_FILE_PATH = "config/metadata.yaml"
# LOG_FILE_NAME = 'builds.log'
#         CONF = get_config().CONF
# def get_config():
#     def _split_lines(self, text, width):
#     def __init__(self):
#     def CONF(self):
#     def _setup_command_line_arg_from_config_metadata(
#             self, target_parser, option_name, option_dict):
#     def _setup_command_line_parser(self, config_metadata_file_path):
#     def parse_command_line_arguments(self, args):
#     def parse_command_line(self, command_line_args):
#     def parse_config_file(self, config_file_path):
#     def parse(self, command_line_args=None):
# def setup_default_config():
# class CustomHelpFormatter(argparse.HelpFormatter):
# class ConfigParser(object):
# 
# 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/utils.py
# LOG = logging.getLogger(__name__)
# def base_directory_not_found_error(err):
# def retry_on_error(f, error=Exception, failure_handler=None,
#                    max_retries=2, seconds_between_retries=5):
#     def _reraise_exception(exc):
# def retry_on_timeout(f, is_timeout_error_f,
#                      max_retries=2,
#                      seconds_between_retries=5,
#                      initial_timeout=120,
#                      timeout_incr_f=lambda t: t * 2):
# def set_http_proxy_env(proxy):
# def run_command(cmd, **kwargs):
# def create_directory(directory):
# def is_package_installed(package_name):
# def recursive_glob(directory, pattern):
# def replace_str_in_file(file_path, search, replacement):
# def force_symlink(target_path, link_path):


import glob
import os
import logging
import re
import rpmUtils.miscutils
from lib import config
from lib import exception
from lib import utils
from lib.package import Package
            # keeps backward compatibility with old yaml files which have build
            # dependencies listed as install dependencies
            if self.distro.version == "7.2":
                self.build_dependencies = list(set(
                    self.build_dependencies + self.install_dependencies))

            default_rpm_macros_file_rel_path = os.path.join(
                self.distro.name, self.distro.version, "rpmmacro")
            rpm_macros_file_rel_path = files.get('rpmmacro', default_rpm_macros_file_rel_path)
            rpm_macros_file_path = os.path.join(self.package_dir, rpm_macros_file_rel_path)
            if os.path.isfile(rpm_macros_file_path):
                self.rpmmacro = rpm_macros_file_path
            else:
                self.rpmmacro = None

            default_spec_file_rel_path = os.path.join(
                self.distro.name, self.distro.version, "%s.spec" % self.name)
            spec_file_rel_path = files.get('spec', default_spec_file_rel_path)
            self.spec_file_path = os.path.join(self.package_dir, spec_file_rel_path)
            self.spec_file = SpecFile(self.spec_file_path)

            if os.path.isfile(self.spec_file.path):
                LOG.info("Package found: %s for %s %s" % (
                    self.name, self.distro.name, self.distro.version))
            else:
                raise exception.PackageSpecError(
                    package=self.name,
                    distro=self.distro.name,
                    distro_version=self.distro.version)
        except TypeError:

# Path: lib/config.py
# RAW_TEXT_ID = "R|"
# CONFIG_METADATA_FILE_PATH = "config/metadata.yaml"
# LOG_FILE_NAME = 'builds.log'
#         CONF = get_config().CONF
# def get_config():
#     def _split_lines(self, text, width):
#     def __init__(self):
#     def CONF(self):
#     def _setup_command_line_arg_from_config_metadata(
#             self, target_parser, option_name, option_dict):
#     def _setup_command_line_parser(self, config_metadata_file_path):
#     def parse_command_line_arguments(self, args):
#     def parse_command_line(self, command_line_args):
#     def parse_config_file(self, config_file_path):
#     def parse(self, command_line_args=None):
# def setup_default_config():
# class CustomHelpFormatter(argparse.HelpFormatter):
# class ConfigParser(object):
# 
# 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/utils.py
# LOG = logging.getLogger(__name__)
# def base_directory_not_found_error(err):
# def retry_on_error(f, error=Exception, failure_handler=None,
#                    max_retries=2, seconds_between_retries=5):
#     def _reraise_exception(exc):
# def retry_on_timeout(f, is_timeout_error_f,
#                      max_retries=2,
#                      seconds_between_retries=5,
#                      initial_timeout=120,
#                      timeout_incr_f=lambda t: t * 2):
# def set_http_proxy_env(proxy):
# def run_command(cmd, **kwargs):
# def create_directory(directory):
# def is_package_installed(package_name):
# def recursive_glob(directory, pattern):
# def replace_str_in_file(file_path, search, replacement):
# def force_symlink(target_path, link_path):


# Path: lib/rpm_package.py
import glob
import os
import logging
import re
import rpmUtils.miscutils
from lib import config
from lib import exception
from lib import utils
from lib.package import Package

            # keeps backward compatibility with old yaml files which have build
            # dependencies listed as install dependencies
            if self.distro.version == "7.2":
                self.build_dependencies = list(set(
                    self.build_dependencies + self.install_dependencies))

            default_rpm_macros_file_rel_path = os.path.join(
                self.distro.name, self.distro.version, "rpmmacro")
            rpm_macros_file_rel_path = files.get('rpmmacro', default_rpm_macros_file_rel_path)
            rpm_macros_file_path = os.path.join(self.package_dir, rpm_macros_file_rel_path)
            if os.path.isfile(rpm_macros_file_path):
                self.rpmmacro = rpm_macros_file_path
            else:
                self.rpmmacro = None

            default_spec_file_rel_path = os.path.join(
                self.distro.name, self.distro.version, "%s.spec" % self.name)
            spec_file_rel_path = files.get('spec', default_spec_file_rel_path)
            self.spec_file_path = os.path.join(self.package_dir, spec_file_rel_path)
            self.spec_file = SpecFile(self.spec_file_path)

            if os.path.isfile(self.spec_file.path):
                LOG.info("Package found: %s for %s %s" % (
                    self.name, self.distro.name, self.distro.version))
            else:
                raise exception.PackageSpecError(
                    package=self.name,
                    distro=self.distro.name,
                    distro_version=self.distro.version)
        except TypeError:

            raise exception.PackageDescriptorError(package=self.name)