<s> from __future__ import unicode_literals <EOL> from django . core . paginator import InvalidPage , Paginator <EOL> from django . http import Http404 <EOL> from django . utils . http import urlencode <EOL> from . yt_paginator import YTPaginator , YTPage <EOL> def get_page_number ( obj_number , per_page ) : <EOL> if obj_number < per_page : <EOL> return <NUM_LIT:1> <EOL> elif obj_number % per_page : <EOL> return obj_number // per_page + <NUM_LIT:1> <EOL> else : <EOL> return obj_number // per_page <EOL> def get_url ( url , obj_number , per_page , page_var ) : <EOL> page = get_page_number ( obj_number , per_page ) <EOL> data = urlencode ( { page_var : page , } ) <EOL> if page == <NUM_LIT:1> : <EOL> return "<STR_LIT>" . join ( ( url , '<STR_LIT>' , str ( obj_number ) ) ) <EOL> return "<STR_LIT>" . join ( ( url , '<STR_LIT:?>' , data , '<STR_LIT>' , str ( obj_number ) ) ) <EOL> def _paginate ( paginator_class , object_list , per_page = <NUM_LIT:15> , page_number = None ) : <EOL> page_number = page_number or <NUM_LIT:1> <EOL> paginator = paginator_class ( object_list , per_page ) <EOL> try : <EOL> return paginator . page ( page_number ) <EOL> except InvalidPage as err : <EOL> raise Http404 ( err ) <EOL> def paginate ( * args , ** kwargs ) : <EOL> return _paginate ( Paginator , * args , ** kwargs ) <EOL> def yt_paginate ( * args , ** kwargs ) : <EOL> return _paginate ( YTPaginator , * args , ** kwargs ) </s>
