# Path: lib/packages_manager.py
# CONF = config.get_config().CONF
# LOG = logging.getLogger(__name__)
# class PackagesManager(object):
#     def __init__(self, packages_names):
#     def prepare_packages(self, packages_class=Package,
#                          download_source_code=True, **packages_keyword_args):
# def discover_packages():
# 
# Path: lib/rpm_package.py
# CONF = config.get_config().CONF
# LOG = logging.getLogger(__name__)
# PACKAGE_METADATA_TO_RPM_MACRO_MAPPING = {
#     ("sources", 0, "git", "commit_id"): "git_commit_id",
#     ("sources", 0, "svn", "commit_id"): "svn_revision",
#     ("sources", 0, "hg", "commit_id"): "hg_commit_id",
# }
#         CHANGE_LOG_TAG = "%changelog"
# def compare_versions(v1, v2):
# def get_define_line(macros):
#     def __init__(self, path):
#     def content(self):
#     def content(self, value):
#     def write_content(self):
#     def query_tag(self, tag_name, extra_args="", unexpanded_macros=[]):
#     def update_version(self, new_version):
#     def bump_release(self, change_log_lines, user_name, user_email):
#     def update_prerelease_tag(self, new_prerelease):
#     def update_commit_id(self, old_commit_id, new_commit_id):
#     def _replace_macro_definition(self, macro_name, replacement):
#     def replace_macro_definition(self, macro_name, replacement):
#     def __init__(self, name, distro, *args, **kwargs):
#     def _load(self):
#     def get_spec_macros(self):
#     def cached_build_results(self):
#     def epoch(self):
#     def version(self):
#     def release(self):
#     def macros(self):
# class SpecFile(object):
# class RPM_Package(Package):


import logging
import os
import re
from lib import packages_manager
from lib import readme
from lib import rpm_package
        versions_repo (GitRepository): versions Git repository handler
        distro (distro.LinuxDistribution): Linux distribution
        metapackage_name (str): name of the release package whose
            dependencies will be updated
        packages_names ([str]): list of dependencies of the release
            package
        user_name (str): name of the user updating the spec file
        user_name (str): email of the user updating the spec file
    """
    LOG.info("Updating release package dependencies: "
             "{}".format(", ".join(packages_names)))
    pm = packages_manager.PackagesManager(packages_names)
    # TODO: this is coupled with RPM-based Linux distributions
    pm.prepare_packages(packages_class=rpm_package.RPM_Package,
                        download_source_code=False, distro=distro)

    LOG.info("Updating release package YAML file")
    YAML_START_DELIMITER = "    install_dependencies:"
    metapackage_yaml_file_path = os.path.join(
        versions_repo.working_tree_dir, metapackage_name,
        metapackage_name + ".yaml")
    yaml_install_dependencies_string = "{start}\n{contents}".format(
        start=YAML_START_DELIMITER,
        contents=create_yaml_install_dependencies_string(pm.packages))
    readme.replace_file_section(
        metapackage_yaml_file_path, yaml_install_dependencies_string,
        YAML_START_DELIMITER)

    LOG.info("Updating release package spec file")


# Path: lib/packages_manager.py
# CONF = config.get_config().CONF
# LOG = logging.getLogger(__name__)
# class PackagesManager(object):
#     def __init__(self, packages_names):
#     def prepare_packages(self, packages_class=Package,
#                          download_source_code=True, **packages_keyword_args):
# def discover_packages():
# 
# Path: lib/rpm_package.py
# CONF = config.get_config().CONF
# LOG = logging.getLogger(__name__)
# PACKAGE_METADATA_TO_RPM_MACRO_MAPPING = {
#     ("sources", 0, "git", "commit_id"): "git_commit_id",
#     ("sources", 0, "svn", "commit_id"): "svn_revision",
#     ("sources", 0, "hg", "commit_id"): "hg_commit_id",
# }
#         CHANGE_LOG_TAG = "%changelog"
# def compare_versions(v1, v2):
# def get_define_line(macros):
#     def __init__(self, path):
#     def content(self):
#     def content(self, value):
#     def write_content(self):
#     def query_tag(self, tag_name, extra_args="", unexpanded_macros=[]):
#     def update_version(self, new_version):
#     def bump_release(self, change_log_lines, user_name, user_email):
#     def update_prerelease_tag(self, new_prerelease):
#     def update_commit_id(self, old_commit_id, new_commit_id):
#     def _replace_macro_definition(self, macro_name, replacement):
#     def replace_macro_definition(self, macro_name, replacement):
#     def __init__(self, name, distro, *args, **kwargs):
#     def _load(self):
#     def get_spec_macros(self):
#     def cached_build_results(self):
#     def epoch(self):
#     def version(self):
#     def release(self):
#     def macros(self):
# class SpecFile(object):
# class RPM_Package(Package):


# Path: lib/metapackage.py
import logging
import os
import re
from lib import packages_manager
from lib import readme
from lib import rpm_package

        versions_repo (GitRepository): versions Git repository handler
        distro (distro.LinuxDistribution): Linux distribution
        metapackage_name (str): name of the release package whose
            dependencies will be updated
        packages_names ([str]): list of dependencies of the release
            package
        user_name (str): name of the user updating the spec file
        user_name (str): email of the user updating the spec file
    """
    LOG.info("Updating release package dependencies: "
             "{}".format(", ".join(packages_names)))
    pm = packages_manager.PackagesManager(packages_names)
    # TODO: this is coupled with RPM-based Linux distributions
    pm.prepare_packages(packages_class=rpm_package.RPM_Package,
                        download_source_code=False, distro=distro)

    LOG.info("Updating release package YAML file")
    YAML_START_DELIMITER = "    install_dependencies:"
    metapackage_yaml_file_path = os.path.join(
        versions_repo.working_tree_dir, metapackage_name,
        metapackage_name + ".yaml")
    yaml_install_dependencies_string = "{start}\n{contents}".format(
        start=YAML_START_DELIMITER,
        contents=create_yaml_install_dependencies_string(pm.packages))
    readme.replace_file_section(
        metapackage_yaml_file_path, yaml_install_dependencies_string,
        YAML_START_DELIMITER)

    LOG.info("Updating release package spec file")


    metapackage = rpm_package.RPM_Package.get_instance(