<commit_before># -*- coding: utf-8 -*-
import framework
from . import rubeus  # Keep me: Makes rubeus importable from website.util

from website import settings



def api_url_for(view_name, _absolute=False, *args, **kwargs):
    """Reverse URL lookup for API routes (those that use the JSONRenderer).
    Takes the same arguments as Flask's url_for, with the addition of
    `_absolute`, which will make an absolute URL with the correct HTTP scheme
    based on whether the app is in debug mode.
    """
    if _absolute:
        # Pop off kwargs to ensure that keyword arguments are only passed
        # once
        _external = kwargs.pop('_external', True)
        scheme = 'http' if settings.DEBUG_MODE else 'https'
        _scheme = kwargs.pop('_scheme', scheme)
    else:
        _external = kwargs.pop('_external', False)
        _scheme = kwargs.pop('_scheme', None)
    return framework.url_for('JSONRenderer__{0}'.format(view_name),
        _external=_external, _scheme=_scheme,
        *args, **kwargs)


def web_url_for(view_name, _absolute=False, *args, **kwargs):
    """Reverse URL lookup for web routes (those that use the OsfWebRenderer).
    Takes the same arguments as Flask's url_for, with the addition of
    `_absolute`, which will make an absolute URL with the correct HTTP scheme
    based on whether the app is in debug mode.
    """
    if _absolute:
        _external = kwargs.pop('_external', True)
        scheme = 'http' if settings.DEBUG_MODE else 'https'
        _scheme = kwargs.pop('_scheme', scheme)
    else:
        _external = kwargs.pop('_external', False)
        _scheme = kwargs.pop('_scheme', None)
    return framework.url_for('OsfWebRenderer__{0}'.format(view_name),
        _external=_external, _scheme=_scheme,
        *args, **kwargs)


def is_json_request():
    """Return True if the current request is a JSON/AJAX request."""
    return framework.flask.request.content_type == 'application/json'<commit_msg>Minor fix to is_json_request<commit_after># -*- coding: utf-8 -*-
import framework
# Keep me: Makes rubeus importable from website.util
from . import rubeus  # noqa

from website import settings


def api_url_for(view_name, _absolute=False, *args, **kwargs):
    """Reverse URL lookup for API routes (those that use the JSONRenderer).
    Takes the same arguments as Flask's url_for, with the addition of
    `_absolute`, which will make an absolute URL with the correct HTTP scheme
    based on whether the app is in debug mode.
    """
    if _absolute:
        # Pop off kwargs to ensure that keyword arguments are only passed
        # once
        _external = kwargs.pop('_external', True)
        scheme = 'http' if settings.DEBUG_MODE else 'https'
        _scheme = kwargs.pop('_scheme', scheme)
    else:
        _external = kwargs.pop('_external', False)
        _scheme = kwargs.pop('_scheme', None)
    return framework.url_for('JSONRenderer__{0}'.format(view_name),
        _external=_external, _scheme=_scheme,
        *args, **kwargs)


def web_url_for(view_name, _absolute=False, *args, **kwargs):
    """Reverse URL lookup for web routes (those that use the OsfWebRenderer).
    Takes the same arguments as Flask's url_for, with the addition of
    `_absolute`, which will make an absolute URL with the correct HTTP scheme
    based on whether the app is in debug mode.
    """
    if _absolute:
        _external = kwargs.pop('_external', True)
        scheme = 'http' if settings.DEBUG_MODE else 'https'
        _scheme = kwargs.pop('_scheme', scheme)
    else:
        _external = kwargs.pop('_external', False)
        _scheme = kwargs.pop('_scheme', None)
    return framework.url_for('OsfWebRenderer__{0}'.format(view_name),
        _external=_external, _scheme=_scheme,
        *args, **kwargs)


def is_json_request():
    """Return True if the current request is a JSON/AJAX request."""
    return 'application/json' in framework.flask.request.content_type
{'fraction_non_alphanumeric': 0.09972088302461304, 'fraction_numerical': 0.0015224562293834052, 'mean_word_length': 3.31763417305586, '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': '6056770', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1138, 'n_words': 396}