<commit_before>class Template:
    @staticmethod
    def render(file_name, model = {}):
        import re
        source = ["buf = []\n"]
        with open(file_name) as f:
            data = f.read()
        for line in data.split('\n'):  
            while True:
                m = re.search(r'\{\{(\w+)\}\}', line)
                if not bool(m):
                    break
                source.append("buf.append('%s')\n" % line[:m.start()])
                source.append("buf.append(%s)\n" % m.group(1))
                line = line[m.end():]
            if len(line) > 0:
                source.append("buf.append('%s\\n')\n" % line)
        source.append("buf = ''.join(buf)")
        code = compile(''.join(source), '<string>', 'exec')
        exec code in model<commit_msg>.tpl can use % for define python native command. % end must be used after defining the command.<commit_after>class Template:
    @staticmethod
    def render(file_name, model = {}):
        import re
        source = ['buf = []\n']
        with open(file_name) as f:
            data = f.read()
        indent = ''
        for line in data.split('\n'):  
            command_index = line.find('%')
            if command_index >= 0:
                if line.find('end') >= 0:
                    indent = indent[4:]
                else:
                    source.append(indent + line[command_index + 1:].lstrip() + '\n')
                    indent += '    '
                continue
            while True:
                m = re.search(r'\{\{(\w+)\}\}', line)
                if not bool(m):
                    break
                source.append(indent + 'buf.append("%s")\n' % line[:m.start()])
                source.append(indent + 'buf.append(%s)\n' % m.group(1))
                line = line[m.end():]
            if len(line) > 0:
                source.append(indent + 'buf.append("%s\\n")\n' % line)
        source.append('buf = "".join(buf)')
        code = compile(''.join(source), '<string>', 'exec')
        exec code in model
{'fraction_non_alphanumeric': 0.16847826086956522, 'fraction_numerical': 0.003952569169960474, 'mean_word_length': 1.4665042630937881, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '5641771', 'n_tokens_mistral': 610, 'n_tokens_neox': 586, 'n_words': 137}