def _parse_arguments(self, method, parameters):
    """Parse arguments to method, returning a dictionary."""

    # TODO: Consider raising an exception if there are extra arguments.

    arguments = _fetch_arguments(self, method)

    arg_dict = {}
    errors = []
    for key, properties in parameters:
        if key in arguments:
            value = arguments[key]
            try:
                arg_dict[key] = _apply_validator_chain(
                    properties.get('validators', []), value, self)
            except validators.ValidationError as err:
                errors.append(err)
        else:
            if properties.get('required', False):
                raise web.HTTPError(
                    400,
                    ('Missing required parameter: %s'
                     % (key, ))
                    )
            else:
                if properties.get('default', None) is not None:
                    arg_dict[key] = properties['default']
                else:
                    arg_dict[key] = None
    if errors:
        raise web.HTTPError(400, 'There were %s errors' % len(errors))

    return arg_dict
dataset/ETHPy150Open refinery29/chassis/chassis/util/params.py/_parse_arguments/original