def calculate_pages(self):
        has_max_record_limit = (self.get_max_record_limit() is not False)
        max_record_limit = self.get_max_record_limit()

        if has_max_record_limit:
            self.set_nb_results(min(self.results_counter, max_record_limit))
        else:
            self.set_nb_results(self.results_counter)

        page = self.get_page()
        if (0 == self.get_page()) or (0 == self.get_max_per_page()):
            self.set_last_page(0)
        else:
            self.set_last_page(int(ceil(self.get_nb_results() / float(self.get_max_per_page()))))
            self.offset = (page - 1) * self.get_max_per_page()
            if has_max_record_limit:
                max_record_limit -= self.offset
                if max_record_limit > self.get_max_per_page():
                    self.limit = self.get_max_per_page()
                else:
                    self.limit = max_record_limit
            else:
                self.limit = self.get_max_per_page()
dataset/ETHPy150Open lightningwolf/Flask-LwAdmin/flask_lwadmin/pager.py/Pager.calculate_pages/original