<commit_before>#!/usr/bin/python

from __future__ import print_function

import sys

from launchpadlib.launchpad import Launchpad


def copy_packages(lp, version, from_archive_name, to_archive_name):
    packaging_team = lp.people['juju-packaging']
    build_archive = packaging_team.getPPAByName(name=from_archive_name)
    package_histories = build_archive.getPublishedSources(
        source_name='juju-core', status='Published')
    package_histories = [
        package for package in package_histories
        if package.source_package_version.startswith(version)]
    juju_team = lp.people['juju']
    public_archive = juju_team.getPPAByName(name=to_archive_name)
    for package in package_histories:
        public_archive.copyPackage(
            from_archive=build_archive,
            source_name=package.source_package_name,
            version=package.source_package_version,
            to_pocket='Release', include_binaries=True, unembargo=True)
    return 0


if __name__ == '__main__':
    if len(sys.argv) != 3:
        print('Usage: %s <version> <devel|stable>')
        sys.exit(1)
    version = sys.argv[1]
    from_archive_name = sys.argv[2]
    to_archive_name = sys.argv[3]
    lp = Launchpad.login_with(
        'lp-copy-packages', service_root='https://api.launchpad.net',
        version='devel')
    sys.exit(copy_packages(lp, version, from_archive_name, to_archive_name))<commit_msg>Use argparser to enforce args.<commit_after>#!/usr/bin/python

from __future__ import print_function

from argparse import ArgumentParser
import sys

from launchpadlib.launchpad import Launchpad


def copy_packages(lp, version, from_archive_name, to_archive_name):
    packaging_team = lp.people['juju-packaging']
    build_archive = packaging_team.getPPAByName(name=from_archive_name)
    package_histories = build_archive.getPublishedSources(
        source_name='juju-core', status='Published')
    package_histories = [
        package for package in package_histories
        if package.source_package_version.startswith(version)]
    juju_team = lp.people['juju']
    public_archive = juju_team.getPPAByName(name=to_archive_name)
    for package in package_histories:
        public_archive.copyPackage(
            from_archive=build_archive,
            source_name=package.source_package_name,
            version=package.source_package_version,
            to_pocket='Release', include_binaries=True, unembargo=True)
    return 0


def get_option_parser():
    """Return the option parser for this program."""
    parser = ArgumentParser('Copy juju-core from one archive to another')
    parser.add_argument('version', help='The package version like 1.20.8')
    parser.add_argument('from_archive_name',
        help='The archive to copy source and binary packages from')
    parser.add_argument('to_archive_name',
        help='The archive to copy the source and binary packages to')
    return parser


if __name__ == '__main__':
    parser = get_option_parser()
    args = parser.parse_args()
    lp = Launchpad.login_with(
        'lp-copy-packages', service_root='https://api.launchpad.net',
        version='devel')
    sys.exit(copy_packages(
        lp, args.version, args.from_archive_name, args.to_archive_name))
{'fraction_non_alphanumeric': 0.09491525423728814, 'fraction_numerical': 0.003389830508474576, 'mean_word_length': 3.918181818181818, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '875627', 'n_tokens_mistral': 998, 'n_tokens_neox': 964, 'n_words': 194}