<commit_before># -*- coding: utf-8 -*-
"""
RESTFul module.
"""
import flask_restful as restful

# Alias common Flask-RESTful names
Resource = restful.Resource


class Api(restful.Api):

    def route(self, *args, **kwargs):
        """
        Routing via decorators: http://flask.pocoo.org/snippets/129/
        """
        def wrapper(cls):
            self.add_resource(cls, *args, **kwargs)
            return cls
        return wrapper<commit_msg>Some rest functions to parse request arguments.<commit_after># -*- coding: utf-8 -*-
"""
RESTFul module.
"""
import flask_restful as restful
from flask_restful.reqparse import Argument, RequestParser

# Alias common Flask-RESTful names
Resource = restful.Resource


class Api(restful.Api):

    def route(self, *args, **kwargs):
        """
        Routing via decorators: http://flask.pocoo.org/snippets/129/
        """
        def wrapper(cls):
            self.add_resource(cls, *args, **kwargs)
            return cls
        return wrapper


def create_parser(select, arguments, sep=' '):
    parser = RequestParser()

    if isinstance(select, str) and select != '*':
        select = select.split(sep)

    if isinstance(arguments, dict):
        for name, values in arguments.items():
            if select == '*' or name in select:
                parser.add_argument(name, values)
        return parser

    for argument in arguments:
        if select == '*' or argument.name in select:
            parser.add_argument(argument)

    return parser


def parse(select, arguments):
    return create_parser(select, arguments).parse_args()
{'fraction_non_alphanumeric': 0.118125, 'fraction_numerical': 0.005, 'mean_word_length': 2.613995485327314, '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': '2590932', 'n_tokens_mistral': 477, 'n_tokens_neox': 453, 'n_words': 128}