Created
December 10, 2015 03:21
-
-
Save djmunro/b4f2a72b888ac14362f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_grid(columns, values): | |
# pop columns on top of values, since we want to print them as well | |
values = [columns] + values | |
# calculate the format string for printing a row | |
row_format = '' | |
for index in range(len(columns)): | |
longest = max([len(str(row[index])) for row in values]) | |
row_format += '{:' + str(longest) + '} ' | |
# print the row! | |
for row in values: | |
print row_format.format(*row) | |
print_grid(('Function', 'Occurences', 'Sender'), [(x['function'], x['sender']) for x in messages if 'function' in x]) | |
print '\n\n\n' | |
#print '{0: <30}{1: <15}{2:}'.format('Function', 'Occurrence', 'Sender') | |
# this prints out all the signal names, and their respective occurences | |
grouped = itertools.groupby(sorted(function_messages, key=groupby_key), groupby_key) | |
for group, items in grouped: | |
items = list(items) | |
print '{func:<30}{occurences:<15}{path}'.format( | |
func=items[0]['function'], | |
occurences=len(items), | |
path=items[0]['path'] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment