#!/usr/bin/env python3 import argparse import defusedxml.ElementTree as ET def get_counts(tree): category_counts = {} category_names = {} for child in tree.getroot(): if child.tag == "BugInstance": category = child.attrib['category'] if category in category_counts: category_counts[category] = category_counts[category] + 1 else: category_counts[category] = 1 elif child.tag == "BugCategory": category = child.attrib['category'] category_names[category] = child[0].text summary = {} for category in category_counts.keys(): summary[category_names[category]] = category_counts[category] return summary def print_html(summary): output = "
Category | Count |
---|---|
{category} | " output += f"{summary[category]} | " output += "
Total | " output += f"{sum(summary.values())} | " output += "