<commit_before># -*- coding: utf-8 -*-

import functools

from flask_apispec import utils
from flask_apispec.wrapper import Wrapper

def use_kwargs(args, locations=None, inherit=None, apply=None, **kwargs):
    """Inject keyword arguments from the specified webargs arguments into the
    decorated view function.

    Usage:

    .. code-block:: python

        from marshmallow import fields

        @use_kwargs({'name': fields.Str(), 'category': fields.Str()})
        def get_pets(**kwargs):
            return Pet.query.filter_by(**kwargs).all()

    :param args: Mapping of argument names to :class:`Field <marshmallow.fields.Field>`
        objects, or :class:`Schema <marshmallow.Schema>`
    :param locations: Default request locations to parse
    :param inherit: Inherit args from parent classes
    :param apply: Parse request with specified args
    """
    kwargs.update({'locations': locations})

    def wrapper(func):
        options = {
            'args': args,
            'kwargs': kwargs,
        }
        annotate(func, 'args', [options], inherit=inherit, apply=apply)
        return activate(func)
    return wrapper


def marshal_with(schema, code='default', description='', inherit=None, apply=None):
    """Marshal the return value of the decorated view function using the
    specified schema.

    Usage:<commit_msg>Documented that use_kwargs can accept a callable as a param arg<commit_after># -*- coding: utf-8 -*-

import functools

from flask_apispec import utils
from flask_apispec.wrapper import Wrapper

def use_kwargs(args, locations=None, inherit=None, apply=None, **kwargs):
    """Inject keyword arguments from the specified webargs arguments into the
    decorated view function.

    Usage:

    .. code-block:: python

        from marshmallow import fields

        @use_kwargs({'name': fields.Str(), 'category': fields.Str()})
        def get_pets(**kwargs):
            return Pet.query.filter_by(**kwargs).all()

    :param args: Mapping of argument names to :class:`Field <marshmallow.fields.Field>`
        objects, :class:`Schema <marshmallow.Schema>`, or a callable which accepts a
        request and returns a :class:`Schema <marshmallow.Schema>`
    :param locations: Default request locations to parse
    :param inherit: Inherit args from parent classes
    :param apply: Parse request with specified args
    """
    kwargs.update({'locations': locations})

    def wrapper(func):
        options = {
            'args': args,
            'kwargs': kwargs,
        }
        annotate(func, 'args', [options], inherit=inherit, apply=apply)
        return activate(func)
    return wrapper


def marshal_with(schema, code='default', description='', inherit=None, apply=None):
    """Marshal the return value of the decorated view function using the
    specified schema.

    Usage:
{'fraction_non_alphanumeric': 0.10848890454385347, 'fraction_numerical': 0.0007044734061289186, 'mean_word_length': 3.2706766917293235, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '4094038', 'n_tokens_mistral': 786, 'n_tokens_neox': 755, 'n_words': 258}