<commit_before>"""Provide the forms for the My_Info widget."""
import re

from django import forms
from django.contrib.localflavor.us.forms import USPhoneNumberField

from apps.managers.player_mgr.models import Profile
from apps.widgets.smartgrid.models import TextReminder


class ProfileForm(forms.Form):
    """Define the form for the My_Info widget."""
    def __init__(self, *args, **kwargs):
        """Override init to take a user argument."""
        self.user = kwargs.pop('user', None)
        super(ProfileForm, self).__init__(*args, **kwargs)

    display_name = forms.CharField(required=True, max_length=20, min_length=1)

    # Event notifications
    contact_email = forms.EmailField(required=False)
    contact_text = USPhoneNumberField(required=False, widget=forms.TextInput(attrs={
        "style": "width: 100px",
        }))
    contact_carrier = forms.ChoiceField(choices=TextReminder.TEXT_CARRIERS)

    def clean_display_name(self):
        """Check if this profile name is valid."""
        name = self.cleaned_data['display_name'].strip()
        # Remove extra whitespace from the name.
        spaces = re.compile(r'\s+')
        name = spaces.sub(' ', name)

        # Check for name that is just whitespace.
        if name == '':
            raise forms.ValidationError('This field is required')

        # Check for duplicate name
        if Profile.objects.exclude(user=self.user).filter(name=name).count() > 0:
            raise forms.ValidationError("%s is taken.  Please use another name.")

        return name
<commit_msg>add declaration to please pylint in Travis<commit_after>"""Provide the forms for the My_Info widget."""
import re

from django import forms
from django.contrib.localflavor.us.forms import USPhoneNumberField

from apps.managers.player_mgr.models import Profile
from apps.widgets.smartgrid.models import TextReminder


class ProfileForm(forms.Form):
    """Define the form for the My_Info widget."""
    def __init__(self, *args, **kwargs):
        """Override init to take a user argument."""
        self.user = kwargs.pop('user', None)
        self.message = None
        super(ProfileForm, self).__init__(*args, **kwargs)

    display_name = forms.CharField(required=True, max_length=20, min_length=1)

    # Event notifications
    contact_email = forms.EmailField(required=False)
    contact_text = USPhoneNumberField(required=False, widget=forms.TextInput(attrs={
        "style": "width: 100px",
        }))
    contact_carrier = forms.ChoiceField(choices=TextReminder.TEXT_CARRIERS)

    def clean_display_name(self):
        """Check if this profile name is valid."""
        name = self.cleaned_data['display_name'].strip()
        # Remove extra whitespace from the name.
        spaces = re.compile(r'\s+')
        name = spaces.sub(' ', name)

        # Check for name that is just whitespace.
        if name == '':
            raise forms.ValidationError('This field is required')

        # Check for duplicate name
        if Profile.objects.exclude(user=self.user).filter(name=name).count() > 0:
            raise forms.ValidationError("%s is taken.  Please use another name.")

        return name

{'fraction_non_alphanumeric': 0.11149606299212599, 'fraction_numerical': 0.004409448818897638, 'mean_word_length': 3.263087248322148, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, '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': '6068229', 'n_tokens_mistral': 909, 'n_tokens_neox': 872, 'n_words': 248}