<commit_before>"""
Common base elements.
"""
import warnings
import types
from functools import wraps

# rave is stylized, yo.
class raveError(Exception):
    """ Base class for any exception that happens in the rave engine. """
    pass

# Deprecated stuff.
def deprecated(replacement=None):
    """ Deprecate functionality. Calling this function or instantiating this class will issue a warning. """
    if not isinstance(replacement, str):
        replacement = replacement.__qualname__

    def inner(f):
        nonlocal replacement

        # Format message.
        message = '{f} is deprecated and may be removed in future releases.'.format(f=f.__qualname__)
        if replacement:
            message += ' Use {repl} instead.'.format(repl=replacement)
        warn = DeprecationWarning(message)

        # Function?
        if isinstance(f, types.FunctionType):
            @wraps(f)
            def wrapper(*args, **kwargs):
                warnings.warn(warn, stacklevel=2)
                return f(*args, **kwargs)<commit_msg>Remove redundant nonlocal statement.<commit_after>"""
Common base elements.
"""
import warnings
import types
from functools import wraps

# rave is stylized, yo.
class raveError(Exception):
    """ Base class for any exception that happens in the rave engine. """
    pass

# Deprecated stuff.
def deprecated(replacement=None):
    """ Deprecate functionality. Calling this function or instantiating this class will issue a warning. """
    if not isinstance(replacement, str):
        replacement = replacement.__qualname__

    def inner(f):
        # Format message.
        message = '{f} is deprecated and may be removed in future releases.'.format(f=f.__qualname__)
        if replacement:
            message += ' Use {repl} instead.'.format(repl=replacement)
        warn = DeprecationWarning(message)

        # Function?
        if isinstance(f, types.FunctionType):
            @wraps(f)
            def wrapper(*args, **kwargs):
                warnings.warn(warn, stacklevel=2)
                return f(*args, **kwargs)
{'fraction_non_alphanumeric': 0.09898599710284886, 'fraction_numerical': 0.0009657170449058426, 'mean_word_length': 2.7948717948717947, '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': '6460465', 'n_tokens_mistral': 555, 'n_tokens_neox': 538, 'n_words': 182}