<commit_before>#!/usr/bin/env python2
# (C) 2015  <NAME>
# Released under BSD
import glob
import os
import subprocess as sp

import rospkg
import tqdm


def get_launch_dir(package):
    return os.path.join(rospkg.RosPack().get_path(package), "launch")


def get_file_root(path):
    """
    >>> get_file_root("/tmp/test.txt")
    'test'

    """
    return os.path.split(path[:path.rindex(".")])[1]


def compile_xacro(inpath, outpath, stdout):
    sp.call("rosrun xacro xacro {inpath} --inorder -o {outpath}"
            .format(inpath=inpath, outpath=outpath).split(),
            stdout=stdout)


def main():
    launch_dir = get_launch_dir("spirit")
    os.chdir(launch_dir)
    with open(os.devnull, "w") as DEVNULL:
        for path in tqdm.tqdm(glob.glob("xacro/*.xacro"),
                              desc="Regenerating launch files"):
            root = get_file_root(path)
            compile_xacro(path, os.path.join("launchers", root), DEVNULL)


if __name__ == "__main__":
    main()<commit_msg>Leave progress bar on screen when regeneration complete.<commit_after>#!/usr/bin/env python2
# (C) 2015  <NAME>
# Released under BSD
import glob
import os
import subprocess as sp

import rospkg
import tqdm


def get_launch_dir(package):
    return os.path.join(rospkg.RosPack().get_path(package), "launch")


def get_file_root(path):
    """
    >>> get_file_root("/tmp/test.txt")
    'test'

    """
    return os.path.split(path[:path.rindex(".")])[1]


def compile_xacro(inpath, outpath, stdout):
    sp.call("rosrun xacro xacro {inpath} --inorder -o {outpath}"
            .format(inpath=inpath, outpath=outpath).split(),
            stdout=stdout)


def main():
    launch_dir = get_launch_dir("spirit")
    os.chdir(launch_dir)
    with open(os.devnull, "w") as DEVNULL:
        for path in tqdm.tqdm(glob.glob("xacro/*.xacro"),
                              desc="Regenerating launch files",
                              leave=True):
            root = get_file_root(path)
            compile_xacro(path, os.path.join("launchers", root), DEVNULL)


if __name__ == "__main__":
    main()
{'fraction_non_alphanumeric': 0.1431288635282929, 'fraction_numerical': 0.005706134094151213, 'mean_word_length': 2.8962962962962964, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, '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': '5608177', 'n_tokens_mistral': 768, 'n_tokens_neox': 729, 'n_words': 151}