<commit_before>"""
    wtforms.fields
    ~~~~~~~~~~~~~~
    
    TODO
    
    :copyright: 2007 by <NAME>, <NAME>.
    :license: MIT, see LICENSE.txt for details.
"""
from datetime import datetime
from cgi import escape
from functools import partial

from wtforms.validators import ValidationError

def html_params(**params):
    return str.join(' ', (u'%s="%s"' % (unicode(k), escape(unicode(v), quote=True)) for k,v in params.iteritems()))

class Field(object):
    _formfield = True
    def __new__(cls, *args, **kwargs):
        if 'name' not in kwargs:
            x = partial(cls, *args, **kwargs)
            x._formfield = True
            return x
        else:
            return super(Field, cls).__new__(cls, *args, **kwargs)

    def __init__(self, *args, **kwargs):
        form = kwargs['form']
        self.name = kwargs['name']
        self.id = kwargs.get('id', form._idprefix + self.name)
        self._label = args[0]
        self.validators = args[1:]<commit_msg>Add specific support for class_, class__ to html_params, to play nice with mako and genshi. These will strip the final underscore in the output, so class_ becomes class and class__ becomes class_.<commit_after>"""
    wtforms.fields
    ~~~~~~~~~~~~~~
    
    TODO
    
    :copyright: 2007 by <NAME>, <NAME>.
    :license: MIT, see LICENSE.txt for details.
"""
from datetime import datetime
from cgi import escape
from functools import partial

from wtforms.validators import ValidationError

def html_params(**kwargs):
    params = []
    for k,v in kwargs.iteritems():
        if k in ('class_', 'class__'):
            k = k[:-1]
        k = unicode(k)
        v = escape(unicode(v), quote=True)
        params.append(u'%s="%s"' % (k, v))
    return str.join(' ', params)

class Field(object):
    _formfield = True
    def __new__(cls, *args, **kwargs):
        if 'name' not in kwargs:
            x = partial(cls, *args, **kwargs)
            x._formfield = True
            return x
        else:
            return super(Field, cls).__new__(cls, *args, **kwargs)

    def __init__(self, *args, **kwargs):
        form = kwargs['form']
        self.name = kwargs['name']
        self.id = kwargs.get('id', form._idprefix + self.name)
        self._label = args[0]
        self.validators = args[1:]
{'fraction_non_alphanumeric': 0.1417975567190227, 'fraction_numerical': 0.005671902268760907, 'mean_word_length': 2.5828125, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1155515', 'n_tokens_mistral': 717, 'n_tokens_neox': 704, 'n_words': 213}