Main function for pagination process.

def cool_paginate(context, **kwargs) -> dict:
    """Main function for pagination process."""

    names = (
        'size',
        'next_name',
        'previous_name',
        'elastic',
        'page_obj',
    )

    return_dict = {name: value for name, value in zip(names, map(kwargs.get, names))}

    if context.get('request'):
        return_dict['request'] = context['request']
    else:
        raise RequestNotExists(
            'Unable to find request in your template context,'
            'please make sure that you have the request context processor enabled'
        )

    if not return_dict.get('page_obj'):
        if context.get('page_obj'):
            return_dict['page_obj'] = context['page_obj']
        else:
            raise PageNotSpecified(
                'You customized paginator standard name, '
                "but haven't specified it in {% cool_paginate %} tag."
            )

    if not return_dict.get('elastic'):
        return_dict['elastic'] = getattr(settings, 'COOL_PAGINATOR_ELASTIC', 10)

    return return_dict