<commit_before># -*- coding: utf-8 -*-
import os
import urlparse

from django.db import models
import markupsafe

from addons.base import exceptions
from addons.base.models import (BaseOAuthNodeSettings, BaseOAuthUserSettings,
                                BaseStorageAddon)
from addons.gitlab import utils
from addons.gitlab.api import GitLabClient
from addons.gitlab.serializer import GitLabSerializer
from addons.gitlab import settings as gitlab_settings
from addons.gitlab.exceptions import ApiError, NotFoundError, GitLabError
from framework.auth import Auth
from osf.models.files import File, Folder, BaseFileNode
from website import settings
from website.util import web_url_for

hook_domain = gitlab_settings.HOOK_DOMAIN or settings.DOMAIN


class GitLabFileNode(BaseFileNode):
    _provider = 'gitlab'


class GitLabFolder(GitLabFileNode, Folder):
    pass


class GitLabFile(GitLabFileNode, File):
    version_identifier = 'branch'

    def touch(self, auth_header, revision=None, ref=None, branch=None, **kwargs):
        revision = revision or ref or branch
        return super(GitLabFile, self).touch(auth_header, revision=revision, **kwargs)

class GitLabProvider(object):
    name = 'GitLab'
    short_name = 'gitlab'
    serializer = GitLabSerializer

    def __init__(self, account=None):
        super(GitLabProvider, self).__init__()  # this does exactly nothing...
        # provide an unauthenticated session by default
        self.account = account

    def __repr__(self):
        return '<{name}: {status}>'.format(
            name=self.__class__.__name__,
            status=self.account.display_name if self.account else 'anonymous'
        )


class UserSettings(BaseOAuthUserSettings):
    oauth_provider = GitLabProvider
    serializer = GitLabSerializer


class NodeSettings(BaseOAuthNodeSettings, BaseStorageAddon):
    oauth_provider = GitLabProvider
    serializer = GitLabSerializer
<commit_msg>Show correct GitLab file version<commit_after># -*- coding: utf-8 -*-
import os
import urlparse

from django.db import models
import markupsafe

from addons.base import exceptions
from addons.base.models import (BaseOAuthNodeSettings, BaseOAuthUserSettings,
                                BaseStorageAddon)
from addons.gitlab import utils
from addons.gitlab.api import GitLabClient
from addons.gitlab.serializer import GitLabSerializer
from addons.gitlab import settings as gitlab_settings
from addons.gitlab.exceptions import ApiError, NotFoundError, GitLabError
from framework.auth import Auth
from osf.models.files import File, Folder, BaseFileNode
from website import settings
from website.util import web_url_for

hook_domain = gitlab_settings.HOOK_DOMAIN or settings.DOMAIN


class GitLabFileNode(BaseFileNode):
    _provider = 'gitlab'


class GitLabFolder(GitLabFileNode, Folder):
    pass


class GitLabFile(GitLabFileNode, File):
    version_identifier = 'commitSha'

    def touch(self, auth_header, revision=None, ref=None, branch=None, **kwargs):
        revision = revision or ref or branch
        return super(GitLabFile, self).touch(auth_header, revision=revision, **kwargs)

class GitLabProvider(object):
    name = 'GitLab'
    short_name = 'gitlab'
    serializer = GitLabSerializer

    def __init__(self, account=None):
        super(GitLabProvider, self).__init__()  # this does exactly nothing...
        # provide an unauthenticated session by default
        self.account = account

    def __repr__(self):
        return '<{name}: {status}>'.format(
            name=self.__class__.__name__,
            status=self.account.display_name if self.account else 'anonymous'
        )


class UserSettings(BaseOAuthUserSettings):
    oauth_provider = GitLabProvider
    serializer = GitLabSerializer


class NodeSettings(BaseOAuthNodeSettings, BaseStorageAddon):
    oauth_provider = GitLabProvider
    serializer = GitLabSerializer

{'fraction_non_alphanumeric': 0.07455012853470437, 'fraction_numerical': 0.0005141388174807198, 'mean_word_length': 4.046692607003891, 'pattern_counts': {'":': 0, '<': 5, '<?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': '319419', 'n_tokens_mistral': 1147, 'n_tokens_neox': 1085, 'n_words': 302}