<commit_before>#!/usr/bin/env python
from __future__ import print_function

from argparse import ArgumentParser
import os
import xml.etree.ElementTree as ET

from jenkins import Jenkins


def get_args():
    parser = ArgumentParser()
    return parser.parse_args()


def get_releases(root):
    release_path = os.path.join(root, 'old-juju')
    for entry in os.listdir(release_path):
        if not os.path.isdir(os.path.join(release_path, entry)):
            continue
        yield entry


def calculate_jobs(root):
    releases = list(get_releases(root))
    candidates = ['master', 'stable']
    for candidate in candidates:
        for release in releases:
            if release == candidate:
                continue
            yield {
                'old_version': release,
                'candidate': candidate,
                'new_to_old': 'true'
            }
            yield {
                'old_version': release,
                'candidate': candidate,
                'new_to_old': 'false'
            }


def build_jobs(root, jobs):
    jenkins = Jenkins('http://localhost:8080')
    tree = ET.parse(os.path.join(root,
                                 'jobs/compatibility-control/config.xml'))
    token = tree.getroot().find('authToken').text
    for job in jobs:
        jenkins.build_job('compatibility-control', job, token=token)


def main():
    args = get_args()
    root_dir = os.environ['HOME']
    build_jobs(root_dir, calculate_jobs(root_dir))


if __name__ == '__main__':<commit_msg>Restore root_dir.<commit_after>#!/usr/bin/env python
from __future__ import print_function

from argparse import ArgumentParser
import os
import xml.etree.ElementTree as ET

from jenkins import Jenkins


def get_args():
    parser = ArgumentParser()
    parser.add_argument(
        'root_dir', help='Directory containing releases and candidates dir')
    return parser.parse_args()


def get_releases(root):
    release_path = os.path.join(root, 'old-juju')
    for entry in os.listdir(release_path):
        if not os.path.isdir(os.path.join(release_path, entry)):
            continue
        yield entry


def calculate_jobs(root):
    releases = list(get_releases(root))
    candidates = ['master', 'stable']
    for candidate in candidates:
        for release in releases:
            if release == candidate:
                continue
            yield {
                'old_version': release,
                'candidate': candidate,
                'new_to_old': 'true'
            }
            yield {
                'old_version': release,
                'candidate': candidate,
                'new_to_old': 'false'
            }


def build_jobs(root, jobs):
    jenkins = Jenkins('http://localhost:8080')
    tree = ET.parse(os.path.join(root,
                                 'jobs/compatibility-control/config.xml'))
    token = tree.getroot().find('authToken').text
    for job in jobs:
        jenkins.build_job('compatibility-control', job, token=token)


def main():
    args = get_args()
    build_jobs(args.root_dir, calculate_jobs(args.root_dir))


if __name__ == '__main__':
{'fraction_non_alphanumeric': 0.10833333333333334, 'fraction_numerical': 0.002564102564102564, 'mean_word_length': 2.292194092827004, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2330318', 'n_tokens_mistral': 943, 'n_tokens_neox': 883, 'n_words': 212}