Files
aitsc/.venv/Lib/site-packages/flask_sqlalchemy/__pycache__/pagination.cpython-312.pyc

160 lines
14 KiB
Plaintext
Raw Normal View History

2025-02-23 09:07:52 +08:00
<EFBFBD>
2025-08-29 00:34:40 +08:00
<00><19>ho+<00><01><><00>ddlmZddlZddlmZddlZddlm Z
2025-02-23 09:07:52 +08:00
ddl m Z ddl m Z Gd<06>d<07>ZGd<08>d e<0E>ZGd
<EFBFBD>d e<0E>Zy) <0C>)<01> annotationsN)<01>ceil)<01>abort)<01>requestc<01>X<00>eZdZdZ d dd<04>Zeddddd<05> dd<06><06>Zedd<07><04>Zdd<08>Z dd <09>Z
edd
<EFBFBD><04>Z edd <0B><04>Z edd <0C><04>Z edd <0A><04>Zed d<0E><04>Zdd<10>d!d<11>Zedd<12><04>Zed d<13><04>Zdd<10>d!d<14>Zddddd<17> d"d<18>Zd#d<19>Zy)$<24>
PaginationaUApply an offset and limit to the query based on the current page and number of
items per page.
Don't create pagination objects manually. They are created by
:meth:`.SQLAlchemy.paginate` and :meth:`.Query.paginate`.
This is a base class, a subclass must implement :meth:`_query_items` and
:meth:`_query_count`. Those methods will use arguments passed as ``kwargs`` to
perform the queries.
:param page: The current page, used to calculate the offset. Defaults to the
``page`` query arg during a request, or 1 otherwise.
:param per_page: The maximum number of items on a page, used to calculate the
offset and limit. Defaults to the ``per_page`` query arg during a request,
or 20 otherwise.
:param max_per_page: The maximum allowed value for ``per_page``, to limit a
user-provided value. Use ``None`` for no limit. Defaults to 100.
:param error_out: Abort with a ``404 Not Found`` error if no items are returned
and ``page`` is not 1, or if ``page`` or ``per_page`` is less than 1, or if
either are not ints.
:param count: Calculate the total number of values by issuing an extra count
query. For very complex queries this may be inaccurate or slow, so it can be
disabled and set manually if necessary.
:param kwargs: Information about the query to paginate. Different subclasses will
require different arguments.
.. versionchanged:: 3.0
Iterating over a pagination object iterates over its items.
.. versionchanged:: 3.0
Creating instances manually is not a public API.
NTc <01><00>||_|j||||<04><01>\}}||_ ||_ ||_ |j <00>}|s|dk7r |r t d<03>||_ |r|j<00>}||_ yd}||_ y)N<><04>page<67>per_page<67> max_per_page<67> error_out<75><00><>)
2025-08-29 00:34:40 +08:00
<EFBFBD> _query_args<67>_prepare_page_argsr r r <00> _query_itemsr<00>items<6D> _query_count<6E>total) <09>selfr r r r<00>count<6E>kwargsrrs <20>HD:\pythonpj\aitsc\.venv\Lib\site-packages\flask_sqlalchemy/pagination.py<70>__init__zPagination.__init__.s<><00><00>"<22><04><18><1D>0<>0<><15><1D>%<25><1F> 1<>
2025-02-23 09:07:52 +08:00
<EFBFBD><0E><04>h<EFBFBD><1E><04> <09><1F>%<25><04> <0A>4<>(4<><04><19>9<><14>!<21>!<21>#<23><05><14><14><11><19>y<EFBFBD> <11>#<23>J<EFBFBD>"'<27><04>
<EFBFBD> <0C> <11><18>%<25>%<25>'<27>E<EFBFBD>"'<27><04>
<EFBFBD>9<><19>E<EFBFBD>!&<26><04>
<EFBFBD>9<>r
c<01><><00>trY|<00>* ttjjdd<02><00>}|<01>3 ttjjdd<05><00>}n|<00>d}|<01>d}|<02> t||<02>}|dkr|r t d<03>nd}|dkr|rt d<03>||fSd}||fS#tt
f$r|r t d<03>d}Y<00><>wxYw#tt
f$r|r t d<03>d}Y<00><>wxYw)Nr rrr <00>)r<00>int<6E>args<67>get<65> TypeError<6F>
ValueErrorr<00>minr
s rrzPagination._prepare_page_argsZs <00><00> <13><13>|<7C><1D><1E>w<EFBFBD>|<7C>|<7C>/<2F>/<2F><06><01>:<3A>;<3B>D<EFBFBD><18><1F>"<22>"<22>7<EFBFBD><<3C><<3C>#3<>#3<>J<EFBFBD><02>#C<>D<>H<EFBFBD><14>|<7C><18><04><17><1F><1D><08> <17> #<23><1A>8<EFBFBD>\<5C>2<>H<EFBFBD> <0F>!<21>8<EFBFBD><18><15>c<EFBFBD>
<EFBFBD><18><04> <13>a<EFBFBD><<3C><18><15>c<EFBFBD>
<EFBFBD><14>X<EFBFBD>~<7E><1D><1E><08><13>X<EFBFBD>~<7E><1D><>I"<22>:<3A>.<2E><1D> <20><1D>c<EFBFBD>
<EFBFBD><1C>D<EFBFBD> <1D><>"<22>:<3A>.<2E>"<22> <20><1D>c<EFBFBD>
<EFBFBD>!<21>H<EFBFBD> "<22>s"<00>)B'<00>)C <00>'C<03>C<03> C,<03>+C,c<01>:<00>|jdz
|jzS)z}The index of the first item to query, passed to ``offset()``.
:meta private:
.. versionadded:: 3.0
r)r r <00>rs r<00> _query_offsetzPagination._query_offset<65>s<00><00><15> <09> <09>A<EFBFBD> <0A><14><1D><1D>.<2E>.rc<01><00>t<00>)z<>Execute the query to get the items on the current page.
Uses init arguments stored in :attr:`_query_args`.
:meta private:
.. versionadded:: 3.0
<20><01>NotImplementedErrorr&s rrzPagination._query_items<6D><00>
<00><00>"<22>!rc<01><00>t<00>)z<>Execute the query to get the total number of items.
Uses init arguments stored in :attr:`_query_args`.
:meta private:
.. versionadded:: 3.0
r)r&s rrzPagination._query_count<6E>r+rc<01>r<00>t|j<00>dk(ry|jdz
|jzdzS)z<>The number of the first item on the page, starting from 1, or 0 if there are
no items.
.. versionadded:: 3.0
rr)<04>lenrr r r&s r<00>firstzPagination.first<73>s3<00><00> <0F>t<EFBFBD>z<EFBFBD>z<EFBFBD>?<3F>a<EFBFBD> <1F><14><14> <09> <09>A<EFBFBD> <0A><14><1D><1D>.<2E><11>2<>2rc<01>d<00>|j}t||t|j<00>zdz
<00>S)z<>The number of the last item on the page, starting from 1, inclusive, or 0 if
there are no items.
.. versionadded:: 3.0
r)r/<00>maxr.r)rr/s r<00>lastzPagination.last<73>s,<00><00><15>
<EFBFBD>
<EFBFBD><05><12>5<EFBFBD>%<25>#<23>d<EFBFBD>j<EFBFBD>j<EFBFBD>/<2F>1<>A<EFBFBD>5<>6<>6rc<01>~<00>|jdk(s |j<00>yt|j|jz <00>S)zThe total number of pages.r)rrr r&s r<00>pageszPagination.pages<65>s3<00><00> <10>:<3A>:<3A><11>?<3F>d<EFBFBD>j<EFBFBD>j<EFBFBD>0<><14><13>D<EFBFBD>J<EFBFBD>J<EFBFBD><14><1D><1D>.<2E>/<2F>/rc<01> <00>|jdkDS)z'``True`` if this is not the first page.r)r r&s r<00>has_prevzPagination.has_prev<65>s<00><00><14>y<EFBFBD>y<EFBFBD>1<EFBFBD>}<7D>rc<01>:<00>|jsy|jdz
S)z@The previous page number, or ``None`` if this is the first page.Nr)r6r r&s r<00>prev_numzPagination.prev_num<75><00><00><00><14>}<7D>}<7D><17><13>y<EFBFBD>y<EFBFBD>1<EFBFBD>}<7D>rF)rc<01><><00>t|<00>d|jdz
|j|dd<03>|j<00><01>}|j|_|S)aQuery the :class:`Pagination` object for the previous page.
:param error_out: Abort with a ``404 Not Found`` error if no items are returned
and ``page`` is not 1, or if ``page`` or ``per_page`` is less than 1, or if
either are not ints.
rF)r r rr<00>)<05>typer r rr<00>rr<00>ps r<00>prevzPagination.prev<65>sS<00><00> <17>D<EFBFBD><14>J<EFBFBD>
<EFBFBD><15><19><19>Q<EFBFBD><1D><19>]<5D>]<5D><1F><17> 
<EFBFBD>
<13><1E><1E> 
<EFBFBD><01><17>*<2A>*<2A><01><07><10>rc<01>4<00>|j|jkS)z&``True`` if this is not the last page.)r r4r&s r<00>has_nextzPagination.has_next<78>s<00><00><14>y<EFBFBD>y<EFBFBD>4<EFBFBD>:<3A>:<3A>%<25>%rc<01>:<00>|jsy|jdzS)z;The next page number, or ``None`` if this is the last page.Nr)rAr r&s r<00>next_numzPagination.next_num<75>r9rc <01><><00>t|<00>d|jdz|j|j|dd<03>|j<00><01>}|j
|_|S)aQuery the :class:`Pagination` object for the next page.
:param error_out: Abort with a ``404 Not Found`` error if no items are returned
and ``page`` is not 1, or if ``page`` or ``per_page`` is less than 1, or if
either are not ints.
rF)r r r rrr;)r<r r r rrr=s r<00>nextzPagination.next<78>s\<00><00> <17>D<EFBFBD><14>J<EFBFBD>
<EFBFBD><15><19><19>Q<EFBFBD><1D><19>]<5D>]<5D><1D>*<2A>*<2A><1F><17> 
<EFBFBD> <13><1E><1E> 
<EFBFBD><01><17>*<2A>*<2A><01><07><10>r<00><00>)<04> left_edge<67> left_current<6E> right_current<6E>
right_edgec#<01><>K<00>|jdz}|dk(rytd|z|<05>}td|<06>Ed{<00><02><02>||k(ryt||j|z
<00>}t|j|zdz|<05>}||z
dkDrd<02><01>t||<08>Ed{<00><02><02>||k(ryt|||z
<00>} | |z
dkDrd<02><01>t| |<05>Ed{<00><02><02>y7<00><>7<00><7<00> <09>w)a<>Yield page numbers for a pagination widget. Skipped pages between the edges
and middle are represented by a ``None``.
For example, if there are 20 pages and the current page is 7, the following
values are yielded.
.. code-block:: python
1, 2, None, 5, 6, 7, 8, 9, 10, 11, None, 19, 20
:param left_edge: How many pages to show from the first page.
:param left_current: How many pages to show left of the current page.
:param right_current: How many pages to show right of the current page.
:param right_edge: How many pages to show from the last page.
.. versionchanged:: 3.0
Improved efficiency of calculating what to yield.
.. versionchanged:: 3.0
``right_current`` boundary is inclusive.
.. versionchanged:: 3.0
All parameters are keyword-only.
rNr)r4r$<00>ranger1r )
rrHrIrJrK<00> pages_end<6E>left_end<6E> mid_start<72>mid_end<6E> right_starts
r<00>
iter_pageszPagination.iter_pagess<><00><00><><00>@<19>J<EFBFBD>J<EFBFBD><11>N<EFBFBD> <09> <14><01>><3E> <12><16>q<EFBFBD>9<EFBFBD>}<7D>i<EFBFBD>0<><08><18><11>H<EFBFBD>%<25>%<25>%<25> <13>y<EFBFBD> <20> <12><17><08>$<24>)<29>)<29>l<EFBFBD>":<3A>;<3B> <09><15>d<EFBFBD>i<EFBFBD>i<EFBFBD>-<2D>/<2F>!<21>3<>Y<EFBFBD>?<3F><07> <14>x<EFBFBD> <1F>!<21> #<23><16>J<EFBFBD><18><19>G<EFBFBD>,<2C>,<2C>,<2C> <12>i<EFBFBD> <1F> <12><19>'<27>9<EFBFBD>z<EFBFBD>#9<>:<3A> <0B> <16><17> <20>1<EFBFBD> $<24><16>J<EFBFBD><18><1B>i<EFBFBD>0<>0<>0<>+ &<26><> -<2D><> 1<>s4<00>4C<01>C <04>AC<01>C<04>4C<01>C<04>C<01>C<01>Cc#<01>8K<00>|jEd{<00><02><02>y7<00><05>w)N)rr&s r<00>__iter__zPagination.__iter__Ds<00><00><><00><17>:<3A>:<3A><1D><1D>s <00><01><04>)NN<4E>dTT)r <00>
int | Noner rWr rWr<00>boolrrXrzt.Any<6E>return<72>None)
r rWr rWr rWrrXrYztuple[int, int]<5D>rYr<00>rYz list[t.Any])rYrX)rYrW)rrXrYr)
rHrrIrrJrrKrrYzt.Iterator[int | None])rYzt.Iterator[t.Any])<16>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__r<00> staticmethodr<00>propertyr'rrr/r2r4r6r8r?rArCrErSrUr;rrrr s<><00><00><08>F <20>#<23>#&<26><1E><1A> *:<3A><18>*:<3A><1D>*:<3A>!<21> *:<3A>
<18> *:<3A> <14> *:<3A><18>*:<3A>
<0E>*:<3A>X<12> <20>#<23>#'<27><1E> /<1E><18>/<1E><1D>/<1E>!<21> /<1E>
<18> /<1E>
<19> /<1E><12>/<1E>b<0E>/<2F><0E>/<2F> "<22> "<22><0E> 3<><0E> 3<><0E>7<><0E>7<><0E>0<><0E>0<><0E><1D><0E><1D><0E><1D><0E><1D>).<2E><11>"<0E>&<26><0E>&<26><0E><1D><0E><1D>).<2E><11>*<1B><1D><1E><1B> ;1<><17>;1<><1A> ;1<>
<1B> ;1<> <18> ;1<>
<20>;1<>zrrc<01> <00>eZdZdZdd<02>Zdd<03>Zy)<07>SelectPaginationz<6E>Returned by :meth:`.SQLAlchemy.paginate`. Takes ``select`` and ``session``
arguments in addition to the :class:`Pagination` arguments.
.. versionadded:: 3.0
c<01><00>|jd}|j|j<00>j|j<00>}|jd}t |j |<01>j<00>j<00><00>S)N<>select<63>session) r<00>limitr <00>offsetr'<00>list<73>execute<74>unique<75>scalars)rrfrgs rrzSelectPagination._query_itemsOsk<00><00><15>!<21>!<21>(<28>+<2B><06><17><1C><1C>d<EFBFBD>m<EFBFBD>m<EFBFBD>,<2C>3<>3<>D<EFBFBD>4F<34>4F<34>G<><06><16>"<22>"<22>9<EFBFBD>-<2D><07><13>G<EFBFBD>O<EFBFBD>O<EFBFBD>F<EFBFBD>+<2B>2<>2<>4<><<3C><<3C>><3E>?<3F>?rc<01>~<00>|jd}|jtjd<02><00>j d<00>j <00>}|jd}|j tjtjj<00><00>j|<02><00>j<00>}|S)Nrf<00>*rg) r<00>options<6E>sa_orm<72>lazyload<61>order_by<62>subqueryrk<00>sarf<00>funcr<00> select_from<6F>scalar)rrf<00>subrg<00>outs rrzSelectPagination._query_countUs<><00><00><15>!<21>!<21>(<28>+<2B><06><14>n<EFBFBD>n<EFBFBD>V<EFBFBD>_<EFBFBD>_<EFBFBD>S<EFBFBD>1<>2<>;<3B>;<3B>D<EFBFBD>A<>J<>J<>L<><03><16>"<22>"<22>9<EFBFBD>-<2D><07><15>o<EFBFBD>o<EFBFBD>b<EFBFBD>i<EFBFBD>i<EFBFBD><02><07><07> <0A> <0A><0F>8<>D<>D<>S<EFBFBD>I<>J<>Q<>Q<>S<><03><12>
rNr\r[<00>r]r^r_r`rrr;rrrdrdHs<00><00><08> @<01> rrdc<01> <00>eZdZdZdd<02>Zdd<03>Zy)<07>QueryPaginationz<6E>Returned by :meth:`.Query.paginate`. Takes a ``query`` argument in addition to
the :class:`Pagination` arguments.
.. versionadded:: 3.0
c<01><><00>|jd}|j|j<00>j|j<00>j <00>}|S<00>N<>query)rrhr rir'<00>all)rr<>rzs rrzQueryPagination._query_itemsdsC<00><00><14> <20> <20><17>)<29><05><13>k<EFBFBD>k<EFBFBD>$<24>-<2D>-<2D>(<28>/<2F>/<2F><04>0B<30>0B<30>C<>G<>G<>I<><03><12>
rc<01>^<00>|jdjd<00>j<00>}|Sr)rrsr)rrzs rrzQueryPagination._query_countis+<00><00><12><1E><1E>w<EFBFBD>'<27>0<>0<><14>6<><<3C><<3C>><3E><03><12>
rNr\r[r{r;rrr}r}]s<00><00><08> <13>
rr})<11>
__future__r<00>typing<6E>t<>mathr<00>
sqlalchemyru<00>sqlalchemy.orm<72>ormrq<00>flaskrrrrdr}r;rr<00><module>r<>s?<00><01>"<22><12><15><17><1F><17><19>y<1E>y<1E>x <13>z<EFBFBD><13>*<13>j<EFBFBD>r