#NEWLINE# def get_page_numbers( current_page , num_pages , extremes = DEFAULT_CALLABLE_EXTREMES , arounds = DEFAULT_CALLABLE_AROUNDS , arrows = DEFAULT_CALLABLE_ARROWS ) : #NEWLINE# #INDENT# 'Default callable for page listing.\n\n    Produce a Digg-style pagination.\n    ' #NEWLINE# page_range = range ( 1 , ( num_pages + 1 ) ) #NEWLINE# pages = [ ] #NEWLINE# if ( current_page != 1 ) : #NEWLINE# #INDENT# if arrows : #NEWLINE# #INDENT# pages . append ( 'first' ) #NEWLINE# #UNINDENT# pages . append ( 'previous' ) #NEWLINE# #UNINDENT# first = page_range [ : extremes ] #NEWLINE# pages . extend ( first ) #NEWLINE# last = page_range [ ( - extremes ) : ] #NEWLINE# current_start = ( ( current_page - 1 ) - arounds ) #NEWLINE# if ( current_start < 0 ) : #NEWLINE# #INDENT# current_start = 0 #NEWLINE# #UNINDENT# current_end = ( current_page + arounds ) #NEWLINE# if ( current_end > num_pages ) : #NEWLINE# #INDENT# current_end = num_pages #NEWLINE# #UNINDENT# current = page_range [ current_start : current_end ] #NEWLINE# to_add = current #NEWLINE# if extremes : #NEWLINE# #INDENT# diff = ( current [ 0 ] - first [ ( - 1 ) ] ) #NEWLINE# if ( diff > 1 ) : #NEWLINE# #INDENT# pages . append ( None ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( diff < 1 ) : #NEWLINE# #INDENT# to_add = current [ ( abs ( diff ) + 1 ) : ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# pages . extend ( to_add ) #NEWLINE# if extremes : #NEWLINE# #INDENT# diff = ( last [ 0 ] - current [ ( - 1 ) ] ) #NEWLINE# to_add = last #NEWLINE# if ( diff > 1 ) : #NEWLINE# #INDENT# pages . append ( None ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( diff < 1 ) : #NEWLINE# #INDENT# to_add = last [ ( abs ( diff ) + 1 ) : ] #NEWLINE# #UNINDENT# #UNINDENT# pages . extend ( to_add ) #NEWLINE# #UNINDENT# if ( current_page != num_pages ) : #NEWLINE# #INDENT# pages . append ( 'next' ) #NEWLINE# if arrows : #NEWLINE# #INDENT# pages . append ( 'last' ) #NEWLINE# #UNINDENT# #UNINDENT# return pages