<commit_before># -*- coding: utf-8 -*-
"""
Forms
"""
from django import forms
from django.utils.translation import ugettext
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse

from crispy_forms.layout import Layout, Fieldset, Div
from crispy_forms.bootstrap import AppendedText

from sveeaccounts.forms import AppendedLink, UserProfileBaseLayout, UserProfileBaseForm

from accounts.models import UserProfile

class AppendedLink(AppendedText):
    """
    Use the AppendedText element to put a link with an optionnal icon
    
    'icon' attribute in kwargs must be set to a valid named icon from 
    bootstrap (or your css theme if any).
    
    TODO: should not reside here, put it in a crispy fork ?
    """
    def __init__(self, field, link, text, *args, **kwargs):
        self.link = link
        self.icon = None
        if 'icon' in kwargs:
            self.icon = kwargs.pop('icon')

        super(AppendedLink, self).__init__(field, text, *args, **kwargs)

    def render(self, *args, **kwargs):
        content = self.text
        if self.icon is not None:
            content = u'<i class="{icon_name}"></i>'.format(icon_name=self.icon)
        self.text = u'<a href="{link}" title="{text}">{content}</a>'.format(link=self.link, content=content, text=self.text)
        return super(AppendedLink, self).render(*args, **kwargs)

def UserProfileLayout():<commit_msg>Bugfixes for a bad import<commit_after># -*- coding: utf-8 -*-
"""
Forms
"""
from django import forms
from django.utils.translation import ugettext
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse

from crispy_forms.layout import Layout, Fieldset, Div
from crispy_forms.bootstrap import AppendedText

from sveeaccounts.forms import UserProfileBaseLayout, UserProfileBaseForm

from accounts.models import UserProfile

class AppendedLink(AppendedText):
    """
    Use the AppendedText element to put a link with an optionnal icon
    
    'icon' attribute in kwargs must be set to a valid named icon from 
    bootstrap (or your css theme if any).
    
    TODO: should not reside here, put it in a crispy fork ?
    """
    def __init__(self, field, link, text, *args, **kwargs):
        self.link = link
        self.icon = None
        if 'icon' in kwargs:
            self.icon = kwargs.pop('icon')

        super(AppendedLink, self).__init__(field, text, *args, **kwargs)

    def render(self, *args, **kwargs):
        content = self.text
        if self.icon is not None:
            content = u'<i class="{icon_name}"></i>'.format(icon_name=self.icon)
        self.text = u'<a href="{link}" title="{text}">{content}</a>'.format(link=self.link, content=content, text=self.text)
        return super(AppendedLink, self).render(*args, **kwargs)

def UserProfileLayout():
{'fraction_non_alphanumeric': 0.11342756183745584, 'fraction_numerical': 0.0007067137809187279, 'mean_word_length': 3.45125786163522, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '1020769', 'n_tokens_mistral': 836, 'n_tokens_neox': 826, 'n_words': 268}