Search Penn Libraries Franklin for documents
    The maximum pagesize currently is 50.
500859
def search(query):
    
    params = {
        's.cmd': 'setTextQuery(%s)setPageSize(50)setHoldingsOnly(true)' % query
    }
    return requests.get(BASE_URL, params=params, timeout=10).json()
1117636
public SearchOptions setPage(int page, int pageSize) {
    checkArgument(page >= 1, "Page must be greater or equal to 1 (got " + page + ")");
    int lastResultIndex = page * pageSize;
    checkArgument(lastResultIndex <= MAX_RETURNABLE_RESULTS, "Can return only the first %s results. %sth result asked.", MAX_RETURNABLE_RESULTS, lastResultIndex);
    setLimit(pageSize);
    setOffset((page * this.limit) - this.limit);
    return this;
  }
785303
def _get_max_page(self, url):
        
        html = requests.get(url).text
        pq = PyQuery(html)
        try:
            tds = int(pq("h2").text().split()[-1])
            if tds % 25:
                return tds / 25 + 1
            return tds / 25
        except ValueError:
            raise ValueError("No results found!")
1292682
def search_all(self, quota=50, format='json'):
        '''
        
        '''
        quota_left = quota
        results = []
        while quota_left > 0:
            more_results = self._search(quota_left, format)
            if not more_results:
                break
            results += more_results
            quota_left = quota_left - len(more_results)
            time.sleep(1)
        results = results[0:quota]
        return results
506545
def searchForPages(self, name, limit=10):
        
        params = {"search": name, "limit": limit}
        j = self.graphql_request(GraphQL(query=GraphQL.SEARCH_PAGE, params=params))

        return [Page._from_graphql(node) for node in j[name]["pages"]["nodes"]]
1332104
def get_all_file_report_pages(self, query):
        
        responses = []
        r = self.get_hashes_from_search(query)
        responses.append(r)

        if ('results' in r.keys()) and ('next_page' in r['results'].keys()):
            next_page = r['results']['next_page']
        else:
            next_page = None

        while next_page:
            r = self.get_hashes_from_search(query, next_page)

            if ('results' in r.keys()) and ('next_page' in r['results'].keys()):
                next_page = r['results']['next_page']
            else:
                next_page = None

            responses.append(r)
        return dict(results=responses)
538305
def content_size_exceeded_max(self, content_bytes):
        '''
        
        '''
        content_size = sys.getsizeof(content_bytes)
        if content_size > self.item_size_max():
            return (True, content_size)

        return (False, content_size)
144093
def search(request, template="search_results.html", extra_context=None):
    
    query = request.GET.get("q", "")
    page = request.GET.get("page", 1)
    per_page = settings.SEARCH_PER_PAGE
    max_paging_links = settings.MAX_PAGING_LINKS
    try:
        parts = request.GET.get("type", "").split(".", 1)
        search_model = apps.get_model(*parts)
        search_model.objects.search  # Attribute check
    except (ValueError, TypeError, LookupError, AttributeError):
        search_model = Displayable
        search_type = _("Everything")
    else:
        search_type = search_model._meta.verbose_name_plural.capitalize()
    results = search_model.objects.search(query, for_user=request.user)
    paginated = paginate(results, page, per_page, max_paging_links)
    context = {"query": query, "results": paginated,
               "search_type": search_type}
    context.update(extra_context or {})
    return TemplateResponse(request, template, context)
1019150
def find_documents(self, sentence, limit=None, must_sort=True,
                       search_type='fuzzy'):
        
        sentence = sentence.strip()
        sentence = strip_accents(sentence)

        if sentence == u"":
            return self.get_all_docs()

        result_list_list = []
        total_results = 0

        for query_parser in self.search_param_list[search_type]:
            query = query_parser["query_parser"].parse(sentence)

            sortedby = None
            if must_sort and "sortedby" in query_parser:
                sortedby = query_parser['sortedby']
            if sortedby:
                results = self.__searcher.search(
                    query, limit=limit, sortedby=sortedby
                )
            else:
                results = self.__searcher.search(
                    query, limit=limit
                )
            results = [
                (result['docid'], result['doctype'])
                for result in results
            ]

            result_list_list.append(results)
            total_results += len(results)

            if not must_sort and total_results >= limit:
                break

        # merging results
        docs = set()
        for result_intermediate in result_list_list:
            for result in result_intermediate:
                doc = self._docs_by_id.get(result[0])
                if doc is None:
                    continue
                docs.add(doc)

        docs = [d for d in docs]

        if not must_sort and limit is not None:
            docs = docs[:limit]

        return docs
738548
function () {
                var items = this.items;
                var itemsLength = items.length;
                var pageSize = this.pageSize;
                if (pageSize <= 0) {
                    pageSize = -1;
                }
                var pages = [], pageLength = 0;
                var pageIndex = 0;
                var nbElementsInPage = 0;
                var firstElement = -1;
                for (var i = 0; i < itemsLength; i++) {
                    var elt = items[i];
                    if (elt.filteredIn) {
                        if (nbElementsInPage === 0) {
                            firstElement = i;
                        }
                        nbElementsInPage++;
                        elt.pageIndex = pageIndex;
                        if (nbElementsInPage == pageSize) {
                            pages[pageLength++] = {
                                pageIndex : pageIndex,
                                pageNumber : pageIndex + 1,
                                firstItemIndex : firstElement,
                                lastItemIndex : i,
                                firstItemNumber : pageIndex * pageSize + 1,
                                lastItemNumber : (pageIndex + 1) * pageSize
                            };
                            pageIndex++;
                            nbElementsInPage = 0;
                        }
                    } else {
                        elt.pageIndex = -1;
                    }
                }
                this._currentState.pageSize = pageSize;
                this.pageMode = (pageSize > 0);
                this.filteredInCount = pageIndex * pageSize + nbElementsInPage; // true even when pageMode == false (as
                // pageIndex == 0)
                if (nbElementsInPage > 0) {
                    pages[pageLength++] = {
                        pageIndex : pageIndex,
                        pageNumber : pageIndex + 1,
                        firstItemIndex : firstElement,
                        lastItemIndex : itemsLength - 1,
                        firstItemNumber : pageIndex * pageSize + 1,
                        lastItemNumber : this.filteredInCount
                    };
                }
                if (pageLength === 0) {
                    // there always must be at least one page
                    pages = this.EMPTY_PAGES;
                }
                this.pages = pages;
            }
1178955
def search(self):
        """"""
        search = self.document_class().search()  # pylint: disable=not-callable

        search = self.custom_filter(search)

        search = self.filter_search(search)
        search = self.order_search(search)
        search = self.filter_permissions(search)

        if search.count() > ELASTICSEARCH_SIZE:
            limit = self.paginator.get_limit(self.request)

            if not limit or limit > ELASTICSEARCH_SIZE:
                raise TooManyResults()

        search = search.extra(size=ELASTICSEARCH_SIZE)
        return search
824002
protected long scanPagesToSend(long maxClientReplicatedPageVersion, FastUnsafeOffHeapIntList pagesToSend)
    {
        long maxPageVersion = 0;
        boolean upgraded = false;
        for(int i=0;i<this.pageVersionList.size();i++)
        {
            if (pageVersionList.get(i) == 0 && !upgraded)
            {
                boolean originalLockWasReleased = this.readWriteLock.upgradeToWriteLock();
                this.currentPageVersion++;
                if (originalLockWasReleased)
                {
                    pagesToSend.clear();
                    for(int j=0;j<i;j++)
                    {
                        maxPageVersion = markAndAddPageIfRequired(maxClientReplicatedPageVersion, pagesToSend, maxPageVersion, j);
                    }
                }
                upgraded = true;
            }
            maxPageVersion = markAndAddPageIfRequired(maxClientReplicatedPageVersion, pagesToSend, maxPageVersion, i);
        }
        return maxPageVersion;
    }
758684
def corpus_page_generator(corpus_files, tmp_dir, max_page_size_exp):
  
  for remote_filepath in corpus_files:

    filepath = maybe_copy_file_to_directory(remote_filepath, tmp_dir)
    tf.logging.info("Reading from " + filepath)

    command = ["7z", "x", "-so", filepath]
    tf.logging.info("Running command: %s", command)

    p = subprocess.Popen(command, stdout=subprocess.PIPE, bufsize=-1)

    for page in file_page_generator(p.stdout, 2**max_page_size_exp):
      yield page
366321
function list(pageSize, callback) {
    var limit = 100;
    if (!isFunction(pageSize)) {
      limit = pageSize;
    }else {
      callback = pageSize;
    }
    commons.get(format('/%s/apps?limit=%s', deis.version, limit), callback);
  }
280898
def apply_pagination(self, q):
        
        # type: (Query)->Query
        assert self.record_count >= 0, "Record count must be set."
        return q.limit(self.page_size).offset(self.offset)
155884
def make_pagination_headers(request, limit, curpage, total, links=False):
    """"""
    lastpage = math.ceil(total / limit) - 1
    headers = {'X-Total-Count': str(total), 'X-Limit': str(limit),
               'X-Page-Last': str(lastpage), 'X-Page': str(curpage)}
    if links:
        base = "{}?%s".format(request.path)
        links = {}
        links['first'] = base % urlencode(dict(request.query, **{VAR_PAGE: 0}))
        links['last'] = base % urlencode(dict(request.query, **{VAR_PAGE: lastpage}))
        if curpage:
            links['prev'] = base % urlencode(dict(request.query, **{VAR_PAGE: curpage - 1}))
        if curpage < lastpage:
            links['next'] = base % urlencode(dict(request.query, **{VAR_PAGE: curpage + 1}))
        headers['Link'] = ",".join(['<%s>; rel="%s"' % (v, n) for n, v in links.items()])
    return headers
625459
def searchFor(page, text, hit_max = 16, quads = False):
    
    CheckParent(page)
    dl = page.getDisplayList()         # create DisplayList
    tp = dl.getTextPage()              # create TextPage
    # return list of hitting reactangles
    rlist = tp.search(text, hit_max = hit_max, quads = quads)
    dl = None
    tp = None
    return rlist