# Path: ros_buildfarm/common.py
# def get_os_package_name(rosdistro_name, ros_package_name):
#     return '%s%s' % \
#         (get_os_package_name_prefix(rosdistro_name),
#          ros_package_name.replace('_', '-'))
# 
# Path: ros_buildfarm/release_common.py
# def dpkg_parsechangelog(source_dir, fields):
#     cmd = ['dpkg-parsechangelog']
#     output = subprocess.check_output(cmd, cwd=source_dir)
#     values = {}
#     for line in output.decode().splitlines():
#         for field in fields:
#             prefix = '%s: ' % field
#             if line.startswith(prefix):
#                 values[field] = line[len(prefix):]
#     assert len(fields) == len(values.keys())
#     return [values[field] for field in fields]


import os
import subprocess
from urllib.error import HTTPError
from urllib.request import urlretrieve
from ros_buildfarm.common import get_os_package_name
from ros_buildfarm.release_common import dpkg_parsechangelog
    from rosdistro import get_cached_distribution
    from rosdistro import get_index
    from catkin_pkg.package import parse_package
    prefix = debian_package_name[0]
    for repo in debian_repository_urls:
        url = URL_TEMPLATE % (repo, prefix, debian_package_name, filename)

        output_file = os.path.join(sources_dir, '..', filename)
        try:
            urlretrieve(url, output_file)
            print("Downloaded original tarball '%s' to '%s'" %
                  (url, output_file))
            break
        except HTTPError:
            print("No tarball found at '%s'" % url)

    # output package version for job description
    print("Package '%s' version: %s" % (pkg_name, source_version))

    # output package maintainers for job notification
    pkg = parse_package(sources_dir)
    maintainer_emails = set([])
    for m in pkg.maintainers:
        maintainer_emails.add(m.email)
    if maintainer_emails:
        print('Package maintainer emails: %s' %
              ' '.join(sorted(maintainer_emails)))


def _get_source_tag(
        rosdistro_name, pkg_name, pkg_version, os_name, os_code_name):
    assert os_name in ['debian', 'ubuntu']
    return 'debian/%s_%s_%s' % \

# Path: ros_buildfarm/common.py
# def get_os_package_name(rosdistro_name, ros_package_name):
#     return '%s%s' % \
#         (get_os_package_name_prefix(rosdistro_name),
#          ros_package_name.replace('_', '-'))
# 
# Path: ros_buildfarm/release_common.py
# def dpkg_parsechangelog(source_dir, fields):
#     cmd = ['dpkg-parsechangelog']
#     output = subprocess.check_output(cmd, cwd=source_dir)
#     values = {}
#     for line in output.decode().splitlines():
#         for field in fields:
#             prefix = '%s: ' % field
#             if line.startswith(prefix):
#                 values[field] = line[len(prefix):]
#     assert len(fields) == len(values.keys())
#     return [values[field] for field in fields]


# Path: ros_buildfarm/sourcedeb_job.py
import os
import subprocess
from urllib.error import HTTPError
from urllib.request import urlretrieve
from ros_buildfarm.common import get_os_package_name
from ros_buildfarm.release_common import dpkg_parsechangelog
    from rosdistro import get_cached_distribution
    from rosdistro import get_index
    from catkin_pkg.package import parse_package

    prefix = debian_package_name[0]
    for repo in debian_repository_urls:
        url = URL_TEMPLATE % (repo, prefix, debian_package_name, filename)

        output_file = os.path.join(sources_dir, '..', filename)
        try:
            urlretrieve(url, output_file)
            print("Downloaded original tarball '%s' to '%s'" %
                  (url, output_file))
            break
        except HTTPError:
            print("No tarball found at '%s'" % url)

    # output package version for job description
    print("Package '%s' version: %s" % (pkg_name, source_version))

    # output package maintainers for job notification
    pkg = parse_package(sources_dir)
    maintainer_emails = set([])
    for m in pkg.maintainers:
        maintainer_emails.add(m.email)
    if maintainer_emails:
        print('Package maintainer emails: %s' %
              ' '.join(sorted(maintainer_emails)))


def _get_source_tag(
        rosdistro_name, pkg_name, pkg_version, os_name, os_code_name):
    assert os_name in ['debian', 'ubuntu']
    return 'debian/%s_%s_%s' % \

        (get_os_package_name(rosdistro_name, pkg_name),