<commit_before>from __future__ import with_statement
import inspect, traceback
import logging
import sys

from django.conf import settings
from django.forms.forms import BoundField
from django.template import Context
from django.template.loader import get_template
from django.utils.html import conditional_escape
try:  # avoid RemovedInDjango19Warning by using lru_cache where available
    from django.utils.lru_cache import lru_cache
    def memoize(function, *args):
        return lru_cache()(function)
except:
    from django.utils.functional import memoize

from .base import KeepContext
from .compatibility import text_type, PY2

# Global field template, default template used for rendering a field.

TEMPLATE_PACK = getattr(settings, 'CRISPY_TEMPLATE_PACK', 'bootstrap')

# By memoizeing we avoid loading the template every time render_field
# is called without a template
def default_field_template(template_pack=TEMPLATE_PACK):
    return get_template("%s/field.html" % template_pack)
default_field_template = memoize(default_field_template, {}, 1)

def set_hidden(widget):
    '''
    set widget to hidden

    different starting in Django 1.7, when is_hidden ceases to be a
    true attribute and is determined by the input_type attribute
    '''
    if hasattr(widget, 'input_type'):
        widget.input_type = 'hidden'
    if not widget.is_hidden:
        widget.is_hidden = True

def render_field(
    field, form, form_style, context, template=None, labelclass=None,
    layout_object=None, attrs=None, template_pack=TEMPLATE_PACK,
    extra_context=None, **kwargs<commit_msg>no need for hasattr<commit_after>from __future__ import with_statement
import inspect, traceback
import logging
import sys

from django.conf import settings
from django.forms.forms import BoundField
from django.template import Context
from django.template.loader import get_template
from django.utils.html import conditional_escape
try:  # avoid RemovedInDjango19Warning by using lru_cache where available
    from django.utils.lru_cache import lru_cache
    def memoize(function, *args):
        return lru_cache()(function)
except:
    from django.utils.functional import memoize

from .base import KeepContext
from .compatibility import text_type, PY2

# Global field template, default template used for rendering a field.

TEMPLATE_PACK = getattr(settings, 'CRISPY_TEMPLATE_PACK', 'bootstrap')

# By memoizeing we avoid loading the template every time render_field
# is called without a template
def default_field_template(template_pack=TEMPLATE_PACK):
    return get_template("%s/field.html" % template_pack)
default_field_template = memoize(default_field_template, {}, 1)

def set_hidden(widget):
    '''
    set widget to hidden

    different starting in Django 1.7, when is_hidden ceases to be a
    true attribute and is determined by the input_type attribute
    '''
    widget.input_type = 'hidden'
    if not widget.is_hidden:
        widget.is_hidden = True

def render_field(
    field, form, form_style, context, template=None, labelclass=None,
    layout_object=None, attrs=None, template_pack=TEMPLATE_PACK,
    extra_context=None, **kwargs
{'fraction_non_alphanumeric': 0.06662436548223351, 'fraction_numerical': 0.0038071065989847717, 'mean_word_length': 4.937853107344632, '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': '2932367', 'n_tokens_mistral': 900, 'n_tokens_neox': 885, 'n_words': 295}