def extract_record_set(records, filters, sorting, pagination_rules=None, limit=None, id_field=DEFAULT_ID_FIELD, deleted_field=DEFAULT_DELETED_FIELD):
 filtered = list(apply_filters(records, (filters or [])))
 total_records = len(filtered)
 paginated = {}
 for rule in (pagination_rules or []):
  values = list(apply_filters(filtered, rule))
  paginated.update(dict(((x[id_field], x) for x in values)))
 if paginated:
  paginated = paginated.values()
 else:
  paginated = filtered
 sorted_ = apply_sorting(paginated, (sorting or []))
 filtered_deleted = len([r for r in sorted_ if (r.get(deleted_field) is True)])
 if limit:
  sorted_ = list(sorted_)[:limit]
 return (sorted_, (total_records - filtered_deleted))

def extract_record_set ( records , filters , sorting , pagination_rules = None , limit = None , id_field = DEFAULT_ID_FIELD , deleted_field = DEFAULT_DELETED_FIELD ) : filtered = list ( apply_filters ( records , ( filters or [ ] ) ) ) total_records = len ( filtered ) paginated = { } for rule in ( pagination_rules or [ ] ) : values = list ( apply_filters ( filtered , rule ) ) paginated . update ( dict ( ( ( x [ id_field ] , x ) for x in values ) ) ) if paginated : paginated = paginated . values ( ) else : paginated = filtered sorted_ = apply_sorting ( paginated , ( sorting or [ ] ) ) filtered_deleted = len ( [ r for r in sorted_ if ( r . get ( deleted_field ) is True ) ] ) if limit : sorted_ = list ( sorted_ ) [ : limit ] return ( sorted_ , ( total_records - filtered_deleted ) )
apply filters .