<commit_before>"""
    wtforms.form
    ~~~~~~~~~~~~
    
    TODO
    
    :copyright: 2007 by <NAME>, <NAME>.
    :license: MIT, see LICENSE.txt for details.
"""
from wtforms.validators import ValidationError

class Form(object):
    def __init__(self, formdata=None, obj=None, prefix='', idprefix='', **kwargs):
        if prefix:
            prefix += '_'
        self._idprefix = idprefix

        # populate data from form and optional instance and defaults
        self.errors = {}
        self._fields = {}
        has_formdata = bool(formdata)
        for name in dir(self.__class__):
            f = getattr(self.__class__, name, None)
            if name.startswith('_') or not getattr(f, '_formfield', False):
                continue

            form_name = prefix + name
            self._fields[name] = field = f(name=form_name, form=self)
            setattr(self, name, field)

            if name in kwargs:
                field.process_data(kwargs[name], has_formdata)
            if hasattr(obj, name):
                field.process_data(getattr(obj, name), has_formdata)
            if has_formdata and form_name in formdata:
                field.process_formdata(formdata.getlist(form_name))
            
    def validate(self):
        success = True
        for name, field in self._fields.iteritems():
            field.errors = []
            validators = list(field.validators)<commit_msg>Make form iterable, yielding the fields, based on suggestion from benoitc. Fixes #6.<commit_after>"""
    wtforms.form
    ~~~~~~~~~~~~
    
    TODO
    
    :copyright: 2007 by <NAME>, <NAME>.
    :license: MIT, see LICENSE.txt for details.
"""
from wtforms.validators import ValidationError

class Form(object):
    def __init__(self, formdata=None, obj=None, prefix='', idprefix='', **kwargs):
        if prefix:
            prefix += '_'
        self._idprefix = idprefix

        # populate data from form and optional instance and defaults
        self.errors = {}
        self._fields = {}
        has_formdata = bool(formdata)
        for name in dir(self.__class__):
            f = getattr(self.__class__, name, None)
            if name.startswith('_') or not getattr(f, '_formfield', False):
                continue

            form_name = prefix + name
            self._fields[name] = field = f(name=form_name, form=self)
            setattr(self, name, field)

            if name in kwargs:
                field.process_data(kwargs[name], has_formdata)
            if hasattr(obj, name):
                field.process_data(getattr(obj, name), has_formdata)
            if has_formdata and form_name in formdata:
                field.process_formdata(formdata.getlist(form_name))


 	def __iter__(self): 
        for name, field in self._fields.itervalues(): 
            yield field

    def validate(self):
        success = True
        for name, field in self._fields.iteritems():
            field.errors = []
            validators = list(field.validators)
{'fraction_non_alphanumeric': 0.109296901032989, 'fraction_numerical': 0.002999000333222259, 'mean_word_length': 2.1012396694214877, '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': '756470', 'n_tokens_mistral': 863, 'n_tokens_neox': 827, 'n_words': 224}