<commit_before>from pprint import pprint
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger

from utils.functions import coalesce


class MyPaginator(Paginator):
    def __init__(self, *args, pag_neib=None, orphans=1, **kwargs):
        self.__pag_neib = coalesce(pag_neib, 5)
        super().__init__(*args, orphans=orphans, **kwargs)

    @property
    def pag_neib(self):
        return self.__pag_neib


def paginator_basic(data, nrows, page, pag_neib=None):
    paginator = MyPaginator(data, nrows, pag_neib=pag_neib)
    try:
        return paginator.page(page)
    except PageNotAnInteger:
        return paginator.page(1)
    except EmptyPage:
        return paginator.page(paginator.num_pages)<commit_msg>criado list_paginator_basic que devolve um dict_list e a list paginada<commit_after>from pprint import pprint
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger

from utils.functions import coalesce


class MyPaginator(Paginator):
    def __init__(self, *args, pag_neib=None, orphans=1, **kwargs):
        self.__pag_neib = coalesce(pag_neib, 5)
        super().__init__(*args, orphans=orphans, **kwargs)

    @property
    def pag_neib(self):
        return self.__pag_neib


def paginator_basic(data, nrows, page, pag_neib=None):
    paginator = MyPaginator(data, nrows, pag_neib=pag_neib)
    try:
        return paginator.page(page)
    except PageNotAnInteger:
        return paginator.page(1)
    except EmptyPage:
        return paginator.page(paginator.num_pages)


def list_paginator_basic(data_list, nrows, page, pag_neib=None):
    data = [
        {'value': value}
        for value in data_list
    ]
    data = paginator_basic(data, nrows, page, pag_neib)
    values_list = [
        row['value']
        for row in data
    ]
    return data, values_list
{'fraction_non_alphanumeric': 0.09250136836343732, 'fraction_numerical': 0.003284072249589491, 'mean_word_length': 3.6513994910941476, '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': '5793019', 'n_tokens_mistral': 620, 'n_tokens_neox': 608, 'n_words': 140}