<commit_before>import uflash
import argparse
import sys
import os

_HELP_TEXT = """
A simple utility script intended for creating hexified versions of MicroPython
scripts on the local filesystem _NOT_ the microbit.  Does not autodetect a
microbit.  Accepts multiple input scripts and optionally one output directory.
"""


def main(argv=None):
    if not argv:
            argv = sys.argv[1:]

    parser = argparse.ArgumentParser(description=_HELP_TEXT)
    parser.add_argument('source', nargs='*', default=None)
    parser.add_argument('-o', '--outdir', default=None,
                        help="Output directory")
    args = parser.parse_args(argv)

    for file in args.source:
        if not args.outdir:
            (script_path, script_name) = os.path.split(file)
            args.outdir = script_path
        uflash.flash(path_to_python=file,
                     paths_to_microbits=[args.outdir], keepname=True)


if __name__ == '__main__':
    main(sys.argv[1:])<commit_msg>Add runtime and minify support<commit_after>import uflash
import argparse
import sys
import os

_HELP_TEXT = """
A simple utility script intended for creating hexified versions of MicroPython
scripts on the local filesystem _NOT_ the microbit.  Does not autodetect a
microbit.  Accepts multiple input scripts and optionally one output directory.
"""


def main(argv=None):
    if not argv:
            argv = sys.argv[1:]

    parser = argparse.ArgumentParser(description=_HELP_TEXT)
    parser.add_argument('source', nargs='*', default=None)
    parser.add_argument('-r', '--runtime', default=None,
                        help="Use the referenced MicroPython runtime.")
    parser.add_argument('-o', '--outdir', default=None,
                        help="Output directory")
    parser.add_argument('-m', '--minify',
                        action='store_true',
                        help='Minify the source')
    args = parser.parse_args(argv)

    for file in args.source:
        if not args.outdir:
            (script_path, script_name) = os.path.split(file)
            args.outdir = script_path
        uflash.flash(path_to_python=file,
                     path_to_runtime=args.runtime,
                     paths_to_microbits=[args.outdir],
                     minify=args.minify,
                     keepname=True) # keepname is always True in hexify


if __name__ == '__main__':
    main(sys.argv[1:])
{'fraction_non_alphanumeric': 0.09900166389351081, 'fraction_numerical': 0.0016638935108153079, 'mean_word_length': 2.621987951807229, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4381961', 'n_tokens_mistral': 710, 'n_tokens_neox': 677, 'n_words': 185}