<commit_before># coding=utf-8
"""
Useful decorators for web views.
"""
from __future__ import absolute_import, division, print_function, \
    unicode_literals

import warnings
from functools import wraps

from flask import render_template, request

__all__ = ['templated']


# Copy/pasted from: http://flask.pocoo.org/docs/patterns/viewdecorators/
def templated(template=None):
    """The idea of this decorator is that you return a dictionary with the values
    passed to the template from the view function and the template is automatically rendered.

    @deprecated
    """

    def decorator(f):

        @wraps(f)
        def decorated_function(*args, **kwargs):
            template_name = template
            if template_name is None:
                template_name = request.endpoint.replace('.', '/') + '.html'
            ctx = f(*args, **kwargs)
            if ctx is None:
                ctx = {}
            elif not isinstance(ctx, dict):
                return ctx
            return render_template(template_name, **ctx)

        return decorated_function

    return decorator


# Copy/pasted from:
# https://wiki.python.org/moin/PythonDecoratorLibrary#Generating_Deprecation_Warnings
def deprecated(func):
    """This decorator can be used to mark functions as deprecated.

    It will result in a warning being emitted when the function is used.
    """

    @wraps(func)
    def new_func(*args, **kwargs):
        warnings.warn_explicit(
            "Call to deprecated function {}.".format(func.__name__),
            category=DeprecationWarning,
            filename=func.__code__.co_filename,
            lineno=func.__code__.co_firstlineno + 1,
        )
        return func(*args, **kwargs)

    return new_func<commit_msg>Remove deprecated decorator.<commit_after># coding=utf-8
"""
Useful decorators for web views.
"""
from __future__ import absolute_import, division, print_function, \
    unicode_literals

import warnings
from functools import wraps


# Copy/pasted from:
# https://wiki.python.org/moin/PythonDecoratorLibrary#Generating_Deprecation_Warnings
def deprecated(func):
    """This decorator can be used to mark functions as deprecated.

    It will result in a warning being emitted when the function is used.
    """

    @wraps(func)
    def new_func(*args, **kwargs):
        warnings.warn_explicit(
            "Call to deprecated function {}.".format(func.__name__),
            category=DeprecationWarning,
            filename=func.__code__.co_filename,
            lineno=func.__code__.co_firstlineno + 1,
        )
        return func(*args, **kwargs)

    return new_func
{'fraction_non_alphanumeric': 0.09215536938309216, 'fraction_numerical': 0.0015232292460015233, 'mean_word_length': 2.8462664714494874, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '4407261', 'n_tokens_mistral': 747, 'n_tokens_neox': 718, 'n_words': 212}