Gets the number of items to return in a page.

        :param max_take: the maximum number of items to return.

        :return: the number of items to return.
766342
def get_take(self, max_take):
        
        if self.take == None:
            return max_take
        if self.take < 0:
            return 0
        if self.take > max_take:
            return max_take
        return self.take
1084315
def page_count(self):
        
        postcount = self.post_set.count()
        max_pages = (postcount / get_paginate_by())
        if postcount % get_paginate_by() != 0:
            max_pages += 1
        return max_pages
399955
def get_sort_limit():
    
    limit = _.convert(get("sort_limit"), _.to_int)
    if (limit < 1):
        limit = None  # catalog raises IndexError if limit < 1
    return limit
212448
def fetch_items(self):
        
        offset = self.per_page * (self.page - 1)
        items = self._query.limit(self.per_page).offset(offset).all()
        return items
1220288
def validate_MAXLEN(value, restriction):
    
    #Sometimes restriction values can accidentally be put in the template <item>100</items>,
    #Making them a list, not a number. Rather than blowing up, just get value 1 from the list.
    if type(restriction) is list:
        restriction = restriction[0]
    else:
        return

    if len(value) > restriction:
        raise ValidationError("MAXLEN: %s"%(restriction))
1009767
def page_size(self) -> int:
        
        page_count = self.page_count
        return self.paginator.max_size + len(f'\nPage {page_count}/{page_count}')
777412
def results(self, limit=100):
        
        limited = True if self.high_mark is not None else False
        rmax = self.high_mark - self.low_mark if limited else None
        rnum = 0

        params = self.get_params()
        params["offset"] = self.low_mark
        params["limit"] = limit

        while not limited and rmax is None or rnum < rmax:
            if limited or rmax is not None:
                rleft = rmax - rnum
                params["limit"] = rleft if rleft < limit else limit

            r = self.resource._meta.api.http_resource("GET", self.resource._meta.resource_name, params=params)
            data = self.resource._meta.api.resource_deserialize(r.text)

            if not limited:
                rmax = data["meta"]["total_count"]

            if data["meta"]["total_count"] < rmax:
                rmax = data["meta"]["total_count"]

            params["offset"] = data["meta"]["offset"] + data["meta"]["limit"]

            for item in data["objects"]:
                rnum += 1
                yield item
216916
def max_pv_count(self):
        
        self.open()
        count = lvm_vg_get_max_pv(self.handle)
        self.close()
        return count
339973
def max(self):
        
        results = [x.ufuncs.max() for x in self.elem]
        return np.max(results)
1026027
def paginate(objects, page_num, per_page, max_paging_links):
    
    if not per_page:
        return Paginator(objects, 0)
    paginator = Paginator(objects, per_page)
    try:
        page_num = int(page_num)
    except ValueError:
        page_num = 1
    try:
        objects = paginator.page(page_num)
    except (EmptyPage, InvalidPage):
        objects = paginator.page(paginator.num_pages)
    page_range = objects.paginator.page_range
    if len(page_range) > max_paging_links:
        start = min(objects.paginator.num_pages - max_paging_links,
            max(0, objects.number - (max_paging_links // 2) - 1))
        page_range = list(page_range)[start:start + max_paging_links]
    objects.visible_page_range = page_range
    return objects
585193
def loadMoreItems(self, excludeRead=False, continuation=None, loadLimit=20, since=None, until=None):
        
        self.lastLoadOk     = False
        self.lastLoadLength = 0
        if not continuation and not self.continuation:
            return
        self._itemsLoadedDone(self._getContent(excludeRead, continuation or self.continuation, loadLimit, since, until))
211042
def _get_limit_and_offset(page, page_size):
    
    if page < 1:
        raise ValueError('page must be >= 1')
    limit = page_size
    offset = (page - 1) * page_size
    return limit, offset
1120772
def max(self):
        """"""
        try:
            res = {
                'target': self.target.max(),
                'params': dict(
                    zip(self.keys, self.params[self.target.argmax()])
                )
            }
        except ValueError:
            res = {}
        return res
1351730
def last(self):
        

        if self.limit > self.total:
            return None
        elif self.offset >= self.total:
            return None
        else:
            offset = (self.total / self.limit) * self.limit
            return {'page[offset]': offset, 'page[limit]': self.limit}
1161552
def values(self, limit=None, page=None):
        
        return self.get(limit=limit, page=page).values()
1245217
def read_var_bytes(self, max_size=sys.maxsize) -> bytes:
        
        length = self.read_var_int(max_size)
        return self.read_bytes(length)
264678
def _heappop_max(heap):
    """"""
    lastelt = heap.pop()    # raises appropriate IndexError if heap is empty
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        _siftup_max(heap, 0)
        return returnitem
    return lastelt