Decide what method to use for paging through text.
507888
def pager(text, color=None):
    """"""
    stdout = _default_text_stdout()
    if not isatty(sys.stdin) or not isatty(stdout):
        return _nullpager(stdout, text, color)
    if 'PAGER' in os.environ:
        if WIN:
            return _tempfilepager(text, os.environ['PAGER'], color)
        return _pipepager(text, os.environ['PAGER'], color)
    if os.environ.get('TERM') in ('dumb', 'emacs'):
        return _nullpager(stdout, text, color)
    if WIN or sys.platform.startswith('os2'):
        return _tempfilepager(text, 'more <', color)
    if hasattr(os, 'system') and os.system('(less) 2>/dev/null') == 0:
        return _pipepager(text, 'less', color)

    import tempfile
    fd, filename = tempfile.mkstemp()
    os.close(fd)
    try:
        if hasattr(os, 'system') and os.system('more "%s"' % filename) == 0:
            return _pipepager(text, 'more', color)
        return _nullpager(stdout, text, color)
    finally:
        os.unlink(filename)
540072
def _evaluate(self):
        """"""
        if self._elements:
            for element in self._elements:
                yield element
        else:
            for page in itertools.count():
                raw_elements = self._retrieve_raw_elements(page)

                for raw_element in raw_elements:
                    element = self._parse_raw_element(raw_element)
                    self._elements.append(element)
                    yield element
                    if self.__limit and len(self._elements) >= self.__limit:
                        break

                if any([
                    len(raw_elements) < self.page_size,
                    (self.__limit and len(self._elements) >= self.__limit)
                ]):
                    break
1023778
def next_page(self):
        """"""
        if self.history.position < self.history.size and self.history.bottom:
            mid = min(len(self.history.bottom),
                      int(math.ceil(self.lines * self.history.ratio)))

            self.history.top.extend(self.buffer[y] for y in range(mid))
            self.history = self.history \
                ._replace(position=self.history.position + mid)

            for y in range(self.lines - mid):
                self.buffer[y] = self.buffer[y + mid]
            for y in range(self.lines - mid, self.lines):
                self.buffer[y] = self.history.bottom.popleft()

            self.dirty = set(range(self.lines))
426221
def auto_paging_each(&blk)
      return enum_for(:auto_paging_each) unless block_given?

      page = self
      loop do
        page.each(&blk)
        page = page.next_page
        break if page.empty?
      end
    end
1153272
def findViewWithTextOrRaise(self, text, root="ROOT"):
        '''
        
        '''

        if DEBUG:
            print >>sys.stderr, "findViewWithTextOrRaise(%s, %s)" % (text, root)
        view = self.findViewWithText(text, root)
        if view:
            return view
        else:
            raise ViewNotFoundException("text", text, root)
719788
def extract_paging(response)
      paging            = response.to_h['paging']
      next_page_url     = paging && paging['next']      # gives nil when any one of the keys doens't exist
      previous_page_url = paging && paging['previous']  # can be replaced with Hash#dig for ruby >= 2.3.0
      @paging_next      = extract_endpoint_from(next_page_url)
      @paging_previous  = extract_endpoint_from(previous_page_url)
    end
21408
function(type, text) {
            var parser = parsers.get(type);

            return parser.parsePage(text)
                .get('content');
        }
223614
public void doFinally() {
        try {
            // If we exposed a Reader in doStartTag(), close it.
            if (varReader != null) {
                // 'r' can be null if an exception was thrown...
                if (r != null) {
                    r.close();
                }
                pageContext.removeAttribute(varReader, PageContext.PAGE_SCOPE);
            }
        } catch (IOException ex) {
            // ignore it; close() failed, but there's nothing more we can do
        }
    }
70735
def needs_pagination(self):
        """"""
        if self.objects_per_page == 0:
            return False
        if len(self.items) > self.objects_per_page \
                or len(self.get_pages[0]) > self.objects_per_page:
            return True
        return False
719028
function (pageIndex, callback, noPageCheck) {

            if (this.$loadingPage) {
                if (callback) {
                    callback();
                }
                return;
            }
            var self = this;

            function cb(err) {
                if (callback) {
                    callback(err);
                }
                self.$loadingPage = false;
            }

            if (this.hasPage(pageIndex)) {
                this.$loadingPage = true;

                var i;
                pageIndex = pageIndex || 0;
                noPageCheck = _.isUndefined(noPageCheck) ? true : noPageCheck;

                if (!this.$.baseList || (!noPageCheck && pageIndex === this.$.page)) {
                    // nothing to do
                    cb();
                    return;
                }

                var list = this.$.list;
                var baseList = this.$.baseList;

                list.clear();

                // add items
                var startIndex = this.$.pageSize * pageIndex;
                if (baseList.$items.length > startIndex) {
                    for (i = 0; i < this.$.pageSize; i++) {
                        list.add(baseList.at(startIndex + i));
                    }
                }


                if (baseList instanceof Collection) {
                    // determinate pages to load based on the page size
                    var collectionPageSize = this.$.baseList.$.pageSize;

                    var collectionStartPage = this._itemIndexToPageIndex(this._pageIndexToItemIndex(pageIndex), collectionPageSize);
                    var collectionEndPage = this._itemIndexToPageIndex(this._pageIndexToItemIndex(pageIndex + 1) - 1, collectionPageSize);

                    var pageIndices = {};
                    for (i = collectionStartPage; i <= collectionEndPage; i++) {
                        pageIndices[i] = i;
                    }


                    flow()
                        .seq("execId", function () {
                            return ++self.$execId;
                        })
                        .parEach(pageIndices, function (pageIndex, cb) {
                            baseList.fetchPage(pageIndex, null, cb);
                        })
                        .exec(function (err, results) {

                            if (!err && results.execId == self.$execId) {
                                var items = [];
                                for (i = collectionStartPage; i <= collectionEndPage; i++) {
                                    items = items.concat(results[i].$items);
                                }

                                self._calculatePageCount();


                                var viewStartIndex = self._pageIndexToItemIndex(pageIndex, self.$.pageSize);
                                viewStartIndex -= collectionStartPage * collectionPageSize;
                                if (viewStartIndex < items.length) {
                                    // remove overlapping at start and end
                                    items = items.slice(viewStartIndex, viewStartIndex + self.$.pageSize);

                                    // and reset list
                                    self.$.list.reset(items);
                                }
                            }
                            self.set('page', pageIndex);
                            cb(err);
                        });

                } else {
                    self._calculatePageCount();
                    self.set('page', pageIndex);
                    cb();
                }
            } else {
                this._calculatePageCount();
                cb();
            }

        }
292674
def get_page(self, index=None):
        """"""
        if index is None:
            widget = self.pages_widget.currentWidget()
        else:
            widget = self.pages_widget.widget(index)
        return widget.widget()
744745
def _page(q, chunk=1000):
    

    offset = 0
    while True:
        r = False
        for elem in q.limit(chunk).offset(offset):
            r = True
            yield elem
        offset += chunk
        if not r:
            break
823481
def paginator(context, adjacent_pages=2):
    
    current_page = context.get('page')
    paginator    = context.get('paginator')
    if not paginator:
        return
    pages        = paginator.num_pages
    current_range = range(current_page - adjacent_pages, current_page + adjacent_pages + 1)
    page_numbers = [n for n in current_range if n > 0 and n <= pages]
    slugtype = ''

    if 'topic_slug' in context:
        page_url = context["topic"].get_short_url()
        slugtype = 'topic'
    elif 'forum_slug' in context:
        page_url = '/forum/%s/' % context["forum_slug"]
        slugtype = 'forum'
    else:
        page_url = context['request'].get_full_path()

    return {
        "is_paginated": context["is_paginated"],
        "page": current_page,
        "pages": pages,
        "page_obj": context['page_obj'],
        "page_numbers": page_numbers,
        "has_next": context["page_obj"].has_next(),
        "has_previous": context["page_obj"].has_previous(),
        "page_url" : page_url,
        'slugtype' : slugtype,
    }
1303214
@Override
    public void selectTab(final String text) {
        for (int i = 0; i < tabs.size(); i++) {
            if (text.equals(tabs.get(i).getText())) {
                selectTab(i);
                return;
            }
        }

        // not found in visible tabs, should be in off-page
        for (OffPageText opt : offPageContainer.getTexts()) {
            if (text.equals(opt.getText())) {
                if (opt.getIndex() == 0) {
                    // the first off-page needs special treatment
                    offPageContainer.selectDeck(opt.getIndex());
                    if (getSelectedIndex() == PAGE_LIMIT - 1) {
                        SelectionEvent.fire(this, PAGE_LIMIT - 1);
                    }
                    tabs.lastTab().setText(opt.getText());
                    selectTab(PAGE_LIMIT - 1);
                } else {
                    selectTab(PAGE_LIMIT - 1 + opt.getIndex());
                }
            }
        }
    }
1261895
def find(self, text):
        """"""
        for key, value in self:
            if (text in key) or (text in value):
                print(key, value)
266260
def page_slice(self):
        """"""
        return (
            None
            if self.query is None
            else (self.query.get("from", 0), self.query.get("size", 10))
        )
167891
function canPageForward () {
    var elements = getElements();
    var lastTab = elements.tabs[ elements.tabs.length - 1 ];

    if (isRtl()) {
      return ctrl.offsetLeft < elements.paging.offsetWidth - elements.canvas.offsetWidth;
    }

    return lastTab && lastTab.offsetLeft + lastTab.offsetWidth > elements.canvas.clientWidth +
        ctrl.offsetLeft;
  }