<commit_before>from django import template
from django.template.defaultfilters import stringfilter

import string

register = template.Library()

@register.filter
@stringfilter
def obfuscate_email(email):
    obfuscated = ""
    for char in email:
        try:
            output = (string.ascii_lowercase.index(char) + 97
                    if char in string.ascii_lowercase else None)
            output = (string.ascii_uppercase.index(char) + 65
                    if char in string.ascii_uppercase else output)
        except ValueError:
            output = None
        if output:
            output = "&#%s;" % output
        elif char == '@':
            output = '&#0064;'
        else:
            output = char
        obfuscated += output
    return obfuscated

class PartialNode(template.Node):
    def __init__(self, partial, params):
        super(PartialNode, self).__init__()
        self.partial = partial
        self.params = params

    def render(self, context):
        context_params = {}
        for k, v in self.params.items():
            try:
                context_params[k] = eval(v)
            except:
                context_params[k] = template.Variable(v).resolve(context)
        t = template.loader.get_template(self.partial)
        return t.render(template.Context(context_params))

@register.tag
def render_partial(parser, token):
    parts = token.split_contents()
    params = {}
    try:
        tag_name, partial = parts[:2]<commit_msg>Don't escape obfuscated emails.<commit_after>from django import template
from django.utils.safestring import mark_safe
from django.template.defaultfilters import stringfilter

import string

register = template.Library()

@register.filter
@stringfilter
def obfuscate_email(email):
    obfuscated = ""
    for char in email:
        try:
            output = (string.ascii_lowercase.index(char) + 97
                    if char in string.ascii_lowercase else None)
            output = (string.ascii_uppercase.index(char) + 65
                    if char in string.ascii_uppercase else output)
        except ValueError:
            output = None
        if output:
            output = "&#%s;" % output
        elif char == '@':
            output = '&#0064;'
        else:
            output = char
        obfuscated += output
    return mark_safe(obfuscated)

class PartialNode(template.Node):
    def __init__(self, partial, params):
        super(PartialNode, self).__init__()
        self.partial = partial
        self.params = params

    def render(self, context):
        context_params = {}
        for k, v in self.params.items():
            try:
                context_params[k] = eval(v)
            except:
                context_params[k] = template.Variable(v).resolve(context)
        t = template.loader.get_template(self.partial)
        return t.render(template.Context(context_params))

@register.tag
def render_partial(parser, token):
    parts = token.split_contents()
    params = {}
    try:
        tag_name, partial = parts[:2]
{'fraction_non_alphanumeric': 0.09667872410391319, 'fraction_numerical': 0.00591910555738244, 'mean_word_length': 2.1987381703470033, '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': '7544639', 'n_tokens_mistral': 861, 'n_tokens_neox': 831, 'n_words': 210}