<commit_before>#! /usr/bin/env python
import jinja2
import sys
import re
import os


KEY_REGEX = re.compile('([A-Z]+)=(\w+)')


def main():
    args = sys.argv[1:]
    if len(args) < 1:
        raise Exception('args too short {}'.format(args))

    template_file = args[0]
    keyword_args = args[1:]

    if not os.path.exists(template_file):
        raise Exception('File "{}" does not exist'.format(template_file))

    context = {}
    for arg in keyword_args:
        match = KEY_REGEX.match(arg)
        if match:
            (key, val) = match.groups()
            context[key] = val

    with open(template_file, 'r') as file_reader:
        text = file_reader.read()
        print jinja2.Template(text).render(context)<commit_msg>Fix the regex so that it catches all characters to the right of the equals-sign.<commit_after>#! /usr/bin/env python
import jinja2
import sys
import re
import os


KEY_REGEX = re.compile('([A-Z]+)=(.+)')


def main():
    args = sys.argv[1:]
    if len(args) < 1:
        raise Exception('args too short {}'.format(args))

    template_file = args[0]
    keyword_args = args[1:]

    if not os.path.exists(template_file):
        raise Exception('File "{}" does not exist'.format(template_file))

    context = {}
    for arg in keyword_args:
        match = KEY_REGEX.match(arg)
        if match:
            (key, val) = match.groups()
            context[key] = val

    with open(template_file, 'r') as file_reader:
        text = file_reader.read()
        print jinja2.Template(text).render(context)
{'fraction_non_alphanumeric': 0.13601036269430053, 'fraction_numerical': 0.007772020725388601, 'mean_word_length': 2.7228915662650603, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3658223', 'n_tokens_mistral': 518, 'n_tokens_neox': 488, 'n_words': 133}