<s> from totalimpactwebapp . cards_factory import * <EOL> import os <EOL> def get_all_cards ( profile ) : <EOL> cards = [ ] <EOL> cards += make_product_new_metrics_cards ( profile . products_not_removed , url_slug = profile . url_slug ) <EOL> cards += make_profile_new_metrics_cards ( profile . products_not_removed , url_slug = profile . url_slug ) <EOL> return cards <EOL> def make ( profile ) : <EOL> cards = get_all_cards ( profile ) <EOL> cards = filter_cards ( cards ) <EOL> cards = sort_cards ( cards ) <EOL> cards = cards [ <NUM_LIT:0> : <NUM_LIT:10> ] <EOL> response = { <EOL> "<STR_LIT>" : profile , <EOL> "<STR_LIT>" : get_css ( ) , <EOL> "<STR_LIT>" : cards <EOL> } <EOL> return response <EOL> def get_css ( ) : <EOL> path = os . path . join ( <EOL> os . path . dirname ( __file__ ) , <EOL> '<STR_LIT>' <EOL> ) <EOL> file = open ( path , "<STR_LIT:r>" ) <EOL> return file . read ( ) <EOL> def sort_cards ( cards ) : <EOL> sorted_cards = sorted ( cards , key = lambda card : card . sort_by , reverse = True ) <EOL> return sorted_cards <EOL> def filter_cards ( cards ) : <EOL> ret = [ ] <EOL> for card in cards : <EOL> try : <EOL> if card . provider != "<STR_LIT>" : <EOL> ret . append ( card ) <EOL> except AttributeError : <EOL> pass <EOL> return ret </s>
