def summary(processors, metrics, context):
    def display_header(processors, before='', after=''):
        print(before, end=' ')
        for processor in processors:
            processor.display_header()
        print(after)
    def display_separator(processors, before='', after=''):
        print(before, end=' ')
        for processor in processors:
            processor.display_separator()
        print(after)
    def display_metrics(processors, before='', after='', metrics=[]):
        print(before, end=' ')
        for processor in processors:
            processor.display_metrics(metrics)
        print(after)
    summary = {}
    for m in metrics:
        lang = metrics[m]['language']
        has_key = lang in summary
        if not has_key:
            summary[lang] = {'file_count': 0, 'language': lang}
        summary[lang]['file_count'] += 1
        for i in metrics[m]:
            if i not in ['sloc', 'comments', 'mccabe']:
                continue
            if not has_key:
                summary[lang][i] = 0
            summary[lang][i] += metrics[m][i]
    total = {'language': 'Total'}
    for m in summary:
        for i in summary[m]:
            if i == 'language':
                continue
            if i not in total:
                total[i] = 0
            total[i] += summary[m][i]
    print('Metrics Summary:')
    display_header(processors, 'Files', '')
    display_separator(processors, '-'*5, '')
    for k in sorted(summary.keys(), key=str.lower):
        display_metrics(processors, '%5d' %
                        summary[k]['file_count'], '', summary[k])
    display_separator(processors, '-'*5, '')
    display_metrics(processors, '%5d' % total['file_count'],
                    '', total)