<commit_before>from wtforms import Form

from pyramid.renderers import render

#http://groups.google.com/group/wtforms/browse_thread/thread/8382c40040b69702
class ExtendedForm(Form): 
    def clean(self): 
        """Override me to validate a whole form.""" 
        pass

    def validate(self): 
        if not super(ExtendedForm, self).validate(): 
            return False 
        errors = self.clean() 
        if errors: 
            self._errors = {'whole_form': errors} 
            return False 
        return True
        
    def render(self, **kwargs):
        action = kwargs.pop('action', '')
        submit_text = kwargs.pop('submit_text', 'Submit')

        return render('pyramid_apex:templates/forms/tableform.mako', {
            'form': self,
            'action': action,
            'submit_text': submit_text,
            'args': kwargs,
        })<commit_msg>Added more form library functions<commit_after>import cgi

from wtforms import Form
from wtforms import validators

from pyramid.renderers import render

#http://groups.google.com/group/wtforms/msg/d6e5aca36a69ff5d
class ExtendedForm(Form):    
    def clean(self): 
        """Override me to validate a whole form.""" 
        pass

    def validate(self): 
        if not super(ExtendedForm, self).validate(): 
            return False 
        errors = self.clean() 
        if errors: 
            self._errors = {'whole_form': errors} 
            return False 
        return True
        
    def render(self, **kwargs):
        action = kwargs.pop('action', '')
        submit_text = kwargs.pop('submit_text', 'Submit')

        return render('pyramid_apex:templates/forms/tableform.mako', {
            'form': self,
            'action': action,
            'submit_text': submit_text,
            'args': kwargs,
        })

#http://groups.google.com/group/wtforms/msg/6c7dd4dc7fee872d
class StyledWidget(object): 
    def __init__(self, widget=None, **kwargs): 
        self.widget = widget
        self.kw = kwargs

    def __call__(self, field, **kwargs):
        if not self.widget:
            self.widget = field.__class__.widget

        return self.widget(field, **dict(self.kw, **kwargs)) 

#http://groups.google.com/group/wtforms/msg/666254426eff1102
class FileRequired(validators.Required): 
    """ 
    Required validator for file upload fields. 
    """ 
    def __call__(self, form, field): 
        if not isinstance(field.data, cgi.FieldStorage): 
            if self.message is None: 
                self.message = field.gettext(u'This field is required.') 
            field.errors[:] = [] 
            raise validators.StopValidation(self.message)
{'fraction_non_alphanumeric': 0.11411411411411411, 'fraction_numerical': 0.01539039039039039, 'mean_word_length': 2.2579462102689485, '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': '2816722', 'n_tokens_mistral': 807, 'n_tokens_neox': 743, 'n_words': 179}