Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(7)  |  Call(6)  |  Derive(0)  |  Import(1)

        def get_page_ranges(number, num_pages):
    if num_pages <=11:
        return [range(1, num_pages+1)]
    elif number <=6:
        return [range(1, 8+1), range(num_pages-2, num_pages+1)]
    elif number > num_pages-6:
        return [range(1, 3+1), range(num_pages-7, num_pages+1)]
    else:
        return [range(1, 3+1), range(number-2, number+2+1), range(num_pages-2, num_pages+1)]
        


src/d/j/django-pager-0.1.7/django_pager/tests.py   django-pager(Download)
import  unittest2
from django_pager.pager import get_page_ranges
 
 
class GetPageRangesTest(unittest2.TestCase):
 
 
    def test_page1of11(self):
        ranges = get_page_ranges(1, 11)
    def test_page1of200(self):
        ranges = get_page_ranges(1, 11)
        self.assertEquals(ranges, [[1,2,3,4,5,6,7,8,9,10,11]])
 
    def test_page1of200(self):
        ranges = get_page_ranges(1,200)
        self.assertEquals(ranges, [[1,2,3,4,5,6,7,8], [198,199,200]])
 
    def test_page57of200(self):
        ranges = get_page_ranges(57, 200)