<commit_before>from django.db import transaction
from django.shortcuts import render_to_response
from django.template import RequestContext
import reversion
from social.pipeline.partial import partial
from judge.forms import ProfileForm
from judge.models import Profile, Language
import logging

logger = logging.getLogger('judge.social_auth')


@partial
def make_profile(backend, user, response, is_new=False, *args, **kwargs):
    logger.info('Info from %s: %s', backend.name, response)

    if is_new:
        if not hasattr(user, 'profile'):
            profile = Profile(user=user)
            profile.language = Language.get_python2()
            logger.info('Creating profile for %s', user.username)
            if backend.name == 'google-oauth2':
                logger.info('Using display name from %s: %s', backend.name, response['displayName'])
                profile.name = response['displayName']
            profile.save()
            form = ProfileForm(instance=profile)
        else:
            data = backend.strategy.request_data()
            logger.info(data)<commit_msg>Get name from GitHub. #50<commit_after>from django.db import transaction
from django.shortcuts import render_to_response
from django.template import RequestContext
import reversion
from social.pipeline.partial import partial
from judge.forms import ProfileForm
from judge.models import Profile, Language
import logging

logger = logging.getLogger('judge.social_auth')


@partial
def make_profile(backend, user, response, is_new=False, *args, **kwargs):
    logger.info('Info from %s: %s', backend.name, response)

    if is_new:
        if not hasattr(user, 'profile'):
            profile = Profile(user=user)
            profile.language = Language.get_python2()
            logger.info('Creating profile for %s', user.username)
            if backend.name == 'google-oauth2':
                logger.info('Using display name from %s: %s', backend.name, response['displayName'])
                profile.name = response['displayName']
            elif backend.name == 'github':
                logger.info('Using display name from %s: %s', backend.name, response['name'])
                profile.name = response['name']
            profile.save()
            form = ProfileForm(instance=profile)
        else:
            data = backend.strategy.request_data()
            logger.info(data)
{'fraction_non_alphanumeric': 0.10449013848090642, 'fraction_numerical': 0.002517834662190516, 'mean_word_length': 2.966722129783694, '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': '7426934', 'n_tokens_mistral': 629, 'n_tokens_neox': 611, 'n_words': 176}