<commit_before>"""
Flask-Upwork
-----------
Adds Upwork API support to Flask.

flask-upwork version 1.0
"""

from __future__ import absolute_import
from functools import wraps
from flask import Module, request, redirect, session, flash,\
    url_for, current_app
from upwork import Client


ODESK_REQUEST_TOKEN = <PASSWORD>'
ODESK_ACCESS_TOKEN = <PASSWORD>'

odesk = Module(__name__)


def is_authorized():
    """
    Check authorization for current user
    """
    return session.get(ODESK_ACCESS_TOKEN, False) and True
odesk.is_authorized = is_authorized


@odesk.app_context_processor
def inject_is_authorized():
    """
    Context processor for is_authorized method
    """
    return {'odesk_is_authorized': is_authorized()}


def get_access_token():
    """
    Get current access token and access token secret
    """
    return session.get(ODESK_ACCESS_TOKEN, [None] * 2)
odesk.get_access_token = get_access_token


def get_client(*access_token):
    """
    Get Upwork Client instance
    """
    try:
        key = current_app.config['ODESK_KEY']
        secret = current_app.config['ODESK_SECRET']
    except KeyError:
        raise Exception(\
                    "ODESK_KEY and ODESK_SECRET were not found in app.config")
    c = Client(key, secret, auth='oauth')
    if access_token:
        c.oauth_access_token, c.oauth_access_token_secret = access_token
    elif ODESK_ACCESS_TOKEN in session:
        c.oauth_access_token, c.oauth_access_token_secret = session.get(\
            ODESK_ACCESS_TOKEN, [None] * 2)
    return c
odesk.get_client = get_client


def login_required(f):
    """
    Decorator for checking current user authorization
    """
    @wraps(f)
    def decorated(*args, **kwargs):
        if ODESK_ACCESS_TOKEN in session:
            return f(*args, **kwargs)
        return login(next=request.url)
    return decorated
odesk.login_required = login_required


def after_login(f):
    """
    Decorator that indicates function, which will be called after successfully
    authorization
    """
    odesk.after_login_func = f
    return f<commit_msg>Removed auth parameter from Client constructor<commit_after>"""
Flask-Upwork
-----------
Adds Upwork API support to Flask.

flask-upwork version 1.0
"""

from __future__ import absolute_import
from functools import wraps
from flask import Module, request, redirect, session, flash,\
    url_for, current_app
from upwork import Client


ODESK_REQUEST_TOKEN = <PASSWORD>'
ODESK_ACCESS_TOKEN = '_<PASSWORD>'

odesk = Module(__name__)


def is_authorized():
    """
    Check authorization for current user
    """
    return session.get(ODESK_ACCESS_TOKEN, False) and True
odesk.is_authorized = is_authorized


@odesk.app_context_processor
def inject_is_authorized():
    """
    Context processor for is_authorized method
    """
    return {'odesk_is_authorized': is_authorized()}


def get_access_token():
    """
    Get current access token and access token secret
    """
    return session.get(ODESK_ACCESS_TOKEN, [None] * 2)
odesk.get_access_token = get_access_token


def get_client(*access_token):
    """
    Get Upwork Client instance
    """
    try:
        key = current_app.config['ODESK_KEY']
        secret = current_app.config['ODESK_SECRET']
    except KeyError:
        raise Exception(\
                    "ODESK_KEY and ODESK_SECRET were not found in app.config")
    c = Client(key, secret)
    if access_token:
        c.oauth_access_token, c.oauth_access_token_secret = access_token
    elif ODESK_ACCESS_TOKEN in session:
        c.oauth_access_token, c.oauth_access_token_secret = session.get(\
            ODESK_ACCESS_TOKEN, [None] * 2)
    return c
odesk.get_client = get_client


def login_required(f):
    """
    Decorator for checking current user authorization
    """
    @wraps(f)
    def decorated(*args, **kwargs):
        if ODESK_ACCESS_TOKEN in session:
            return f(*args, **kwargs)
        return login(next=request.url)
    return decorated
odesk.login_required = login_required


def after_login(f):
    """
    Decorator that indicates function, which will be called after successfully
    authorization
    """
    odesk.after_login_func = f
    return f
{'fraction_non_alphanumeric': 0.09220872051465333, 'fraction_numerical': 0.0019061234214915416, 'mean_word_length': 3.314491264131552, 'pattern_counts': {'":': 0, '<': 7, '<?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': '7103588', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1298, 'n_words': 339}