<commit_before>from urllib import urlencode
import binascii
import datetime
import exceptions
import hashlib
import hmac
import logging
import pickle
import providers
import random
import sys
import time
import urllib
import urlparse


# taken from anyjson.py
try:
    import simplejson as json
except ImportError: # pragma: no cover
    try:
        # Try to import from django, should work on App Engine
        from django.utils import simplejson as json
    except ImportError:
        # Should work for Python2.6 and higher.
        import json


def login(adapter, provider_name, callback=None, report_errors=True,
          logging_level=20, scope=[], **kwargs):
    
    # retrieve required settings for current provider and raise exceptions if missing
    provider_settings = adapter.config.get(provider_name)
    if not provider_settings:
        raise exceptions.ConfigError('Provider name "{}" not specified!'.format(provider_name))
    
    provider_class = provider_settings.get('class_name')
    if not provider_class:
        raise exceptions.ConfigError('Class name not specified for provider {}!'.format(provider_name))
        
    # merge scopes from config and argument
    scope = provider_settings.get('scope', []) + scope
    
    # create consumer
    consumer = Consumer(provider_settings.get('consumer_key'),
                        provider_settings.get('consumer_secret'),
                        scope)
        
    ProviderClass = resolve_provider_class(provider_class)
    
    # instantiate provider class
    provider = ProviderClass(adapter, provider_name, consumer, callback, provider_settings.get('short_name'),
                             report_errors=report_errors,
                             logging_level=logging_level)
    
    # return login result
    return provider.login(**kwargs)


class Counter(object):
    count = 0
    def __call__(self):
        self.count += 1<commit_msg>Fixed a bug when there was no scope.<commit_after>from urllib import urlencode
import binascii
import datetime
import exceptions
import hashlib
import hmac
import logging
import pickle
import providers
import random
import sys
import time
import urllib
import urlparse


# taken from anyjson.py
try:
    import simplejson as json
except ImportError: # pragma: no cover
    try:
        # Try to import from django, should work on App Engine
        from django.utils import simplejson as json
    except ImportError:
        # Should work for Python2.6 and higher.
        import json


def login(adapter, provider_name, callback=None, report_errors=True,
          logging_level=20, scope=[], **kwargs):
    
    # retrieve required settings for current provider and raise exceptions if missing
    provider_settings = adapter.config.get(provider_name)
    if not provider_settings:
        raise exceptions.ConfigError('Provider name "{}" not specified!'.format(provider_name))
    
    provider_class = provider_settings.get('class_name')
    if not provider_class:
        raise exceptions.ConfigError('Class name not specified for provider {}!'.format(provider_name))
        
    # merge scopes from config and argument
    scope = provider_settings.get('scope', []) + scope if scope else None
    
    # create consumer
    consumer = Consumer(provider_settings.get('consumer_key'),
                        provider_settings.get('consumer_secret'),
                        scope)
        
    ProviderClass = resolve_provider_class(provider_class)
    
    # instantiate provider class
    provider = ProviderClass(adapter, provider_name, consumer, callback, provider_settings.get('short_name'),
                             report_errors=report_errors,
                             logging_level=logging_level)
    
    # return login result
    return provider.login(**kwargs)


class Counter(object):
    count = 0
    def __call__(self):
        self.count += 1
{'fraction_non_alphanumeric': 0.06945156330087135, 'fraction_numerical': 0.0030753459764223477, 'mean_word_length': 2.96243654822335, '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': '1842732', 'n_tokens_mistral': 998, 'n_tokens_neox': 961, 'n_words': 316}