<s> def get_paginated_data ( data , start , count , order = '<STR_LIT>' ) : <EOL> if order . startswith ( '<STR_LIT:->' ) : <EOL> asc = False <EOL> order_field = order [ <NUM_LIT:1> : ] <EOL> else : <EOL> asc = True <EOL> order_field = order <EOL> ordered_data = data . order_by ( order ) <EOL> if start : <EOL> filter_fields = { <EOL> order_field + ( '<STR_LIT>' if asc else '<STR_LIT>' ) : start <EOL> } <EOL> ordered_data = ordered_data . filter ( ** filter_fields ) <EOL> retval = list ( ordered_data [ : count + <NUM_LIT:1> ] ) <EOL> if len ( retval ) > count : <EOL> obj = retval [ count ] <EOL> while '<STR_LIT>' in order_field : <EOL> prefix , order_field = order_field . split ( '<STR_LIT>' , <NUM_LIT:1> ) <EOL> obj = getattr ( obj , prefix ) <EOL> next = getattr ( obj , order_field ) <EOL> retval = retval [ : - <NUM_LIT:1> ] <EOL> else : <EOL> next = None <EOL> return ( retval , next ) </s>
