graviti.paging.page#

Page related class.

Module Contents#

Classes#

PageBase

PageBase is the base class of array wrapper and represents a page in paging list.

Page

Page is an array wrapper and represents a page in paging list.

SlicedPage

SlicedPage is an array wrapper and represents a sliced page in paging list.

LazyPage

LazyPage is a placeholder when the paging list page is not loaded yet.

LazySlicedPage

LazySlicedPage is a placeholder when the sliced paging list page is not loaded yet.

class graviti.paging.page.PageBase[source]#

Bases: Sequence[_T]

PageBase is the base class of array wrapper and represents a page in paging list.

get_item(self, index)[source]#

Return the item at the given index.

Parameters

index (int) – Position of the mutable sequence.

Returns

The item at the given index.

Return type

_T

abstract get_slice(self, start=None, stop=None, step=None)[source]#

Return a sliced page according to the given start and stop index.

Parameters
  • start (Optional[int]) – The start index.

  • stop (Optional[int]) – The stop index.

  • step (Optional[int]) – The slice step.

Raises

NotImplementedError – The method of the base class should not be called.

Return type

PageBase[_T]

abstract get_array(self)[source]#

Get the array inside the page.

Raises

NotImplementedError – The method of the base class should not be called.

Return type

Sequence[_T]

class graviti.paging.page.Page(array)[source]#

Bases: PageBase[_T]

Page is an array wrapper and represents a page in paging list.

Parameters

array (Sequence[_T]) – The internal sequence of page.

get_slice(self, start=None, stop=None, step=None)[source]#

Return a sliced page according to the given start and stop index.

Parameters
  • start (Optional[int]) – The start index.

  • stop (Optional[int]) – The stop index.

  • step (Optional[int]) – The slice step.

Returns

A sliced page according to the given start and stop index.

Return type

SlicedPage[_T]

get_array(self)[source]#

Get the array inside the page.

Returns

The array inside the page.

Return type

Sequence[_T]

class graviti.paging.page.SlicedPage(ranging, source_array)[source]#

Bases: PageBase[_T]

SlicedPage is an array wrapper and represents a sliced page in paging list.

Parameters
  • ranging (range) – The range instance of this page.

  • array – The internal sequence of page.

  • source_array (Sequence[_T]) –

get_slice(self, start=None, stop=None, step=None)[source]#

Return a sliced page according to the given start and stop index.

Parameters
  • start (Optional[int]) – The start index.

  • stop (Optional[int]) – The stop index.

  • step (Optional[int]) – The slice step.

Returns

A sliced page according to the given start and stop index.

Return type

SlicedPage[_T]

get_array(self)[source]#

Get the array inside the page.

Returns

The array inside the page.

Return type

Sequence[_T]

class graviti.paging.page.LazyPage(ranging, pos, array_getter)[source]#

Bases: PageBase[_T]

LazyPage is a placeholder when the paging list page is not loaded yet.

Parameters
  • pos (int) – The page number.

  • ranging (range) – The range instance of this page.

  • parent – The parent paging list.

  • array_getter (Callable[[int], Sequence[_T]]) –

get_slice(self, start=None, stop=None, step=None)[source]#

Return a lazy sliced page according to the given start and stop index.

Parameters
  • start (Optional[int]) – The start index.

  • stop (Optional[int]) – The stop index.

  • step (Optional[int]) – The slice step.

Returns

A sliced page according to the given start and stop index.

Return type

Union[LazySlicedPage[_T], SlicedPage[_T]]

get_array(self)[source]#

Get the array inside the page.

Returns

The array inside the page.

Return type

Sequence[_T]

class graviti.paging.page.LazySlicedPage(ranging, pos, array_getter)[source]#

Bases: LazyPage[_T]

LazySlicedPage is a placeholder when the sliced paging list page is not loaded yet.

Parameters
  • ranging (range) –

  • pos (int) –

  • array_getter (Callable[[int], Sequence[_T]]) –

get_array(self)[source]#

Get the array inside the page.

Returns

The array inside the page.

Return type

Sequence[_T]