<commit_before>import sys

allowed_undefined_variables = [
    'activity.data_source',
    'activity.share_data',
    'css_classes.label',
    'css_classes.wrap',
    'error',
    'form.code.value',
    'form.email.errors',
    'form.email.value',
    'form.name.errors',
    'form.name.value',
    'form.non_field_errors',
    'form.password.errors',
    'form.password.value',
    'form.password_confirm.errors',
    'form.password_confirm.value',
    'form.terms.errors',
    'form.username.errors',
    'form.username.value',
    'form_submit_value',
    'panel_offset',
    'panel_width',
    'quiz_complete',
    'section',
    'source',
    'source.href_next',
    'user_data.href_next',
]


class InvalidString(str):
    """
    Raise an exception if an invalid template string is encountered.
    """

    def __mod__(self, other):
        if getattr(other, 'var') in allowed_undefined_variables:
            return super(InvalidString, self).__mod__(other)

        from django.template.base import TemplateSyntaxError

        raise TemplateSyntaxError(
            'Undefined variable or unknown value for "{}" ({})'.format(
                other, other.var))


def has_migration(app, migration):
    if 'migrate' in sys.argv:
        return False

    if 'test' not in sys.argv:
        return True

    from django.db.migrations.recorder import MigrationRecorder

    try:
        MigrationRecorder.Migration.objects.get(app=app, name=migration)
    except MigrationRecorder.Migration.DoesNotExist:
        return False

    return True
<commit_msg>💚 fix failing template variable test<commit_after>import sys

allowed_undefined_variables = [
    'activity.data_source',
    'activity.share_data',
    'css_classes.label',
    'css_classes.wrap',
    'error',
    'form.code.value',
    'form.email.errors',
    'form.email.value',
    'form.name.errors',
    'form.name.value',
    'form.non_field_errors',
    'form.password.errors',
    'form.password.value',
    'form.password_confirm.errors',
    'form.password_confirm.value',
    'form.terms.errors',
    'form.username.errors',
    'form.username.value',
    'form_submit_value',
    'next',
    'panel_offset',
    'panel_width',
    'quiz_complete',
    'section',
    'source',
    'source.href_next',
    'user_data.href_next',
]


class InvalidString(str):
    """
    Raise an exception if an invalid template string is encountered.
    """

    def __mod__(self, other):
        if getattr(other, 'var') in allowed_undefined_variables:
            return super(InvalidString, self).__mod__(other)

        from django.template.base import TemplateSyntaxError

        raise TemplateSyntaxError(
            'Undefined variable or unknown value for "{}" ({})'.format(
                other, other.var))


def has_migration(app, migration):
    if 'migrate' in sys.argv:
        return False

    if 'test' not in sys.argv:
        return True

    from django.db.migrations.recorder import MigrationRecorder

    try:
        MigrationRecorder.Migration.objects.get(app=app, name=migration)
    except MigrationRecorder.Migration.DoesNotExist:
        return False

    return True

{'fraction_non_alphanumeric': 0.11958241062954761, 'fraction_numerical': 0.0, 'mean_word_length': 2.88929889298893, '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': '6237044', 'n_tokens_mistral': 982, 'n_tokens_neox': 960, 'n_words': 198}