def report_by_type_stats(sect, stats, old_stats):
    'make a report of\n\n    * percentage of different types documented\n    * percentage of different types with a bad name\n    '
    nice_stats = {}
    for node_type in ('module', 'class', 'method', 'function'):
        try:
            total = stats[node_type]
        except KeyError as e:
            raise exceptions.EmptyReportError() from e
        nice_stats[node_type] = {}
        if (total != 0):
            try:
                documented = (total - stats[('undocumented_' + node_type)])
                percent = ((documented * 100.0) / total)
                nice_stats[node_type]['percent_documented'] = ('%.2f' % percent)
            except KeyError:
                nice_stats[node_type]['percent_documented'] = 'NC'
            try:
                percent = ((stats[('badname_' + node_type)] * 100.0) / total)
                nice_stats[node_type]['percent_badname'] = ('%.2f' % percent)
            except KeyError:
                nice_stats[node_type]['percent_badname'] = 'NC'
    lines = ('type', 'number', 'old number', 'difference', '%documented', '%badname')
    for node_type in ('module', 'class', 'method', 'function'):
        new = stats[node_type]
        old = old_stats.get(node_type, None)
        if (old is not None):
            diff_str = lint_utils.diff_string(old, new)
        else:
            (old, diff_str) = ('NC', 'NC')
        lines += (node_type, str(new), str(old), diff_str, nice_stats[node_type].get('percent_documented', '0'), nice_stats[node_type].get('percent_badname', '0'))
    sect.append(reporter_nodes.Table(children=lines, cols=6, rheaders=1))
make a report of

* percentage of different types documented
* percentage of different types with a bad name
def report_by_type_stats(sect, stats, old_stats):
    'make a report of\n\n    * percentage of different types documented\n    * percentage of different types with a bad name\n    '
    nice_stats = {}
    for node_type in ('module', 'class', 'method', 'function'):
        try:
            total = stats[node_type]
        except KeyError as e:
            raise exceptions.EmptyReportError() from e
        nice_stats[node_type] = {}
        if (total != 0):
            try:
                documented = (total - stats[('undocumented_' + node_type)])
                percent = ((documented * 100.0) / total)
                nice_stats[node_type]['percent_documented'] = ('%.2f' % percent)
            except KeyError:
                nice_stats[node_type]['percent_documented'] = 'NC'
            try:
                percent = ((stats[('badname_' + node_type)] * 100.0) / total)
                nice_stats[node_type]['percent_badname'] = ('%.2f' % percent)
            except KeyError:
                nice_stats[node_type]['percent_badname'] = 'NC'
    lines = ('type', 'number', 'old number', 'difference', '%documented', '%badname')
    for node_type in ('module', 'class', 'method', 'function'):
        new = stats[node_type]
        old = old_stats.get(node_type, None)
        if (old is not None):
            diff_str = lint_utils.diff_string(old, new)
        else:
            (old, diff_str) = ('NC', 'NC')
        lines += (node_type, str(new), str(old), diff_str, nice_stats[node_type].get('percent_documented', '0'), nice_stats[node_type].get('percent_badname', '0'))
    sect.append(reporter_nodes.Table(children=lines, cols=6, rheaders=1))