#NEWLINE# def format_groups( metric_names , today_timestamp , offsets , current_values , metric_data ) : #NEWLINE# #INDENT# metric_presenters = dict ( ( ( metric_name , MetricPresenter . from_data ( metric_name , today_timestamp , offsets , current_values , metric_data ) ) for metric_name in metric_names ) ) #NEWLINE# defined_groups = [ GroupPresenter ( group . name , tuple ( ( metric_presenters [ metric_name ] for metric_name in metric_names if group . contains ( metric_name ) ) ) ) for group in groups ] #NEWLINE# uncategorized_group = GroupPresenter ( 'Uncategorized' , tuple ( ( metric_presenters [ metric_name ] for metric_name in metric_names if ( not any ( ( group . contains ( metric_name ) for group in groups ) ) ) ) ) ) #NEWLINE# all_group = GroupPresenter ( 'All' , tuple ( ( metric_presenters [ metric_name ] for metric_name in metric_names ) ) ) #NEWLINE# all_groups = ( metric_names + [ uncategorized_group , all_group ] ) #NEWLINE# return [ group for group in all_groups if group . metrics ]