<commit_before>from django.core.urlresolvers import reverse_lazy


class UserSocialAuthUserData(object):
    """
    Implements methods for UserData models that use Python Social Auth to
    connect users.
    """

    # TODO: this duplicates the AppConfig's verbose_name attribute
    text_name = None

    # TODO: when this is no longer used as a model mixin:
    # 1. remove hasattr check
    # 2. remove default None parameter
    def __init__(self, provider=None, user=None):
        if not hasattr(self, 'provider'):
            self.provider = provider
            self.user = user

    def __unicode__(self):
        return '<UserSocialAuthUserData:{}>'.format(self.provider)

    @property
    def href_connect(self):
        return reverse_lazy('social:begin', args=(self.provider,))

    @property
    def href_next(self):
        return reverse_lazy('activities:{}:finalize-import'
                            .format(self.provider))

    @property
    def retrieval_url(self):
        return reverse_lazy('activities:{}:request-data-retrieval'
                            .format(self.provider))

    @property
    def is_connected(self):
        # filter in Python to benefit from prefetched data
        return len([s for s in self.user.social_auth.all()
                    if s.provider == self.provider]) > 0

    def disconnect(self):
        self.user.social_auth.filter(provider=self.provider).delete()

    def get_retrieval_params(self):
        return {
            'access_token': self.get_access_token(),
        }

    def get_access_token(self):
        """
        Get the access token from the most recent RunKeeeper association.
        """
        user_social_auth = (self.user.social_auth.filter(
            provider=self.provider).order_by('-id')[0])
<commit_msg>🔧 fix copy-pasta<commit_after>from django.core.urlresolvers import reverse_lazy


class UserSocialAuthUserData(object):
    """
    Implements methods for UserData models that use Python Social Auth to
    connect users.
    """

    # TODO: this duplicates the AppConfig's verbose_name attribute
    text_name = None

    # TODO: when this is no longer used as a model mixin:
    # 1. remove hasattr check
    # 2. remove default None parameter
    def __init__(self, provider=None, user=None):
        if not hasattr(self, 'provider'):
            self.provider = provider
            self.user = user

    def __unicode__(self):
        return '<UserSocialAuthUserData:{}>'.format(self.provider)

    @property
    def href_connect(self):
        return reverse_lazy('social:begin', args=(self.provider,))

    @property
    def href_next(self):
        return reverse_lazy('activities:{}:finalize-import'
                            .format(self.provider))

    @property
    def retrieval_url(self):
        return reverse_lazy('activities:{}:request-data-retrieval'
                            .format(self.provider))

    @property
    def is_connected(self):
        # filter in Python to benefit from prefetched data
        return len([s for s in self.user.social_auth.all()
                    if s.provider == self.provider]) > 0

    def disconnect(self):
        self.user.social_auth.filter(provider=self.provider).delete()

    def get_retrieval_params(self):
        return {
            'access_token': self.get_access_token(),
        }

    def get_access_token(self):
        """
        Get the access token from the most recent association with this
        provider.
        """
        user_social_auth = (self.user.social_auth.filter(
            provider=self.provider).order_by('-id')[0])

{'fraction_non_alphanumeric': 0.0995850622406639, 'fraction_numerical': 0.0022130013831258644, 'mean_word_length': 2.470249520153551, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6164597', 'n_tokens_mistral': 1044, 'n_tokens_neox': 994, 'n_words': 256}