mirror of
https://github.com/django/django.git
synced 2025-10-27 07:36:08 +00:00
Refs #27656 -- Updated django.core docstring verbs according to PEP 257.
This commit is contained in:
committed by
Tim Graham
parent
3eb679a869
commit
5a6f70b428
@@ -33,9 +33,7 @@ class Paginator:
|
||||
self.allow_empty_first_page = allow_empty_first_page
|
||||
|
||||
def validate_number(self, number):
|
||||
"""
|
||||
Validates the given 1-based page number.
|
||||
"""
|
||||
"""Validate the given 1-based page number."""
|
||||
try:
|
||||
number = int(number)
|
||||
except (TypeError, ValueError):
|
||||
@@ -50,9 +48,7 @@ class Paginator:
|
||||
return number
|
||||
|
||||
def page(self, number):
|
||||
"""
|
||||
Returns a Page object for the given 1-based page number.
|
||||
"""
|
||||
"""Return a Page object for the given 1-based page number."""
|
||||
number = self.validate_number(number)
|
||||
bottom = (number - 1) * self.per_page
|
||||
top = bottom + self.per_page
|
||||
@@ -62,7 +58,7 @@ class Paginator:
|
||||
|
||||
def _get_page(self, *args, **kwargs):
|
||||
"""
|
||||
Returns an instance of a single page.
|
||||
Return an instance of a single page.
|
||||
|
||||
This hook can be used by subclasses to use an alternative to the
|
||||
standard :cls:`Page` object.
|
||||
@@ -71,9 +67,7 @@ class Paginator:
|
||||
|
||||
@cached_property
|
||||
def count(self):
|
||||
"""
|
||||
Returns the total number of objects, across all pages.
|
||||
"""
|
||||
"""Return the total number of objects, across all pages."""
|
||||
try:
|
||||
return self.object_list.count()
|
||||
except (AttributeError, TypeError):
|
||||
@@ -84,9 +78,7 @@ class Paginator:
|
||||
|
||||
@cached_property
|
||||
def num_pages(self):
|
||||
"""
|
||||
Returns the total number of pages.
|
||||
"""
|
||||
"""Return the total number of pages."""
|
||||
if self.count == 0 and not self.allow_empty_first_page:
|
||||
return 0
|
||||
hits = max(1, self.count - self.orphans)
|
||||
@@ -95,7 +87,7 @@ class Paginator:
|
||||
@property
|
||||
def page_range(self):
|
||||
"""
|
||||
Returns a 1-based range of pages for iterating through within
|
||||
Return a 1-based range of pages for iterating through within
|
||||
a template for loop.
|
||||
"""
|
||||
return range(1, self.num_pages + 1)
|
||||
@@ -154,7 +146,7 @@ class Page(collections.Sequence):
|
||||
|
||||
def start_index(self):
|
||||
"""
|
||||
Returns the 1-based index of the first object on this page,
|
||||
Return the 1-based index of the first object on this page,
|
||||
relative to total objects in the paginator.
|
||||
"""
|
||||
# Special case, return zero if no items.
|
||||
@@ -164,7 +156,7 @@ class Page(collections.Sequence):
|
||||
|
||||
def end_index(self):
|
||||
"""
|
||||
Returns the 1-based index of the last object on this page,
|
||||
Return the 1-based index of the last object on this page,
|
||||
relative to total objects found (hits).
|
||||
"""
|
||||
# Special case for the last page because there can be orphans.
|
||||
|
||||
Reference in New Issue
Block a user